R5 the server's own settings: instance, rules, announcements, relays, media limits, the staff's log
Build / Build (push) Successful in 1m3s
Build / Build (push) Successful in 1m3s
A singleton ServerSettings (title, descriptions, contact, thumbnail, privacy policy, terms, rules, relays, media overrides, PublishActivity), cached by InstanceSettings and read by the instance API, NodeInfo, the instance actor, the web pages and the mailer; its defaults are the old literals, so nothing changes until an administrator edits. /clientapi/admin/settings (and /thumbnail), /announcements, /relays for administrators; /clientapi/moderator/log, the staff's log (AdminAction, written by domain blocks, backups, settings and the CLI; no IP, never a root paired with its personas). The Mastodon API's rules, extended description, privacy policy, terms of service, domain blocks (Published, Obfuscate), announcements (dismiss, reactions, streaming) and activity (only when published). Reports carry rule ids. Media overrides clamped to hard caps. Relays named by the settings reconcile next to the configured ones. Verified: interop.sh instance accounts relay with mastodon, relay, aoderelay and mailpit, 119 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
This commit is contained in:
1 parent
f67e2ae35e
commit
70d1ffe9a2
46 files changed
+2223
-107
No files matched your search
@@ -14,8 +14,8 @@ namespace PrivaPub.Domain.Relationships
|
||||
{
|
||||
public interface IReportService
|
||||
{
|
||||
Task<Report> File(LocalActor reporter, string targetAccountId, IReadOnlyList<string> postIds, string comment, string category, bool forward,
|
||||
CancellationToken token);
|
||||
Task<Report> File(LocalActor reporter, string targetAccountId, IReadOnlyList<string> postIds, string comment, string category,
|
||||
IReadOnlyList<string> ruleIds, bool forward, CancellationToken token);
|
||||
}
|
||||
|
||||
public class ReportService : IReportService
|
||||
@@ -23,17 +23,29 @@ namespace PrivaPub.Domain.Relationships
|
||||
readonly DbEntities _dbEntities;
|
||||
readonly ILocalActorService _localActors;
|
||||
readonly IDeliveryService _delivery;
|
||||
readonly Instance.IInstanceSettings _settings;
|
||||
|
||||
public ReportService(DbEntities dbEntities, ILocalActorService localActors, IDeliveryService delivery)
|
||||
public ReportService(DbEntities dbEntities, ILocalActorService localActors, IDeliveryService delivery, Instance.IInstanceSettings settings)
|
||||
{
|
||||
_dbEntities = dbEntities;
|
||||
_localActors = localActors;
|
||||
_delivery = delivery;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public async Task<Report> File(LocalActor reporter, string targetAccountId, IReadOnlyList<string> postIds, string comment, string category,
|
||||
bool forward, CancellationToken token)
|
||||
IReadOnlyList<string> ruleIds, bool forward, CancellationToken token)
|
||||
{
|
||||
// the server's rules it names, deleted ones too (they may have been listed when the reader opened the dialog); a
|
||||
// report naming rules is a violation unless it says what else it is, and only a violation names rules, as on Mastodon
|
||||
var known = _settings.Current.Rules.Select(r => r.Id).ToHashSet(StringComparer.Ordinal);
|
||||
var rules = (ruleIds ?? Array.Empty<string>()).Where(known.Contains).Distinct().ToList();
|
||||
if (rules.Count > 0 && string.IsNullOrEmpty(category))
|
||||
category = "violation";
|
||||
category = category is "spam" or "legal" or "violation" ? category : "other";
|
||||
if (category != "violation")
|
||||
rules.Clear();
|
||||
|
||||
var localTarget = await _dbEntities.Avatars.MatchID(targetAccountId).ExecuteFirstAsync(token);
|
||||
var remoteTarget = localTarget == default ? await _dbEntities.ForeignAvatars.MatchID(targetAccountId).ExecuteFirstAsync(token) : default;
|
||||
if (localTarget == default && remoteTarget == default)
|
||||
@@ -51,7 +63,8 @@ namespace PrivaPub.Domain.Relationships
|
||||
PostIds = posts.Select(p => p.ID).ToList(),
|
||||
ObjectURIs = posts.Select(p => p.ObjectURI).ToList(),
|
||||
Comment = comment?.Trim(),
|
||||
Category = category is "spam" or "legal" or "violation" ? category : "other"
|
||||
Category = category,
|
||||
RuleIds = rules
|
||||
};
|
||||
await DB.Default.SaveAsync(report, token);
|
||||
if (!forward || remoteTarget == default)
|
||||
|
||||
Reference in new issue
Block a user