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
@@ -6,7 +6,10 @@ using MongoDB.Entities;
|
||||
|
||||
using PrivaPub.ClientModels;
|
||||
using PrivaPub.ClientModels.Admin;
|
||||
using PrivaPub.Domain.Moderation;
|
||||
using PrivaPub.Extensions;
|
||||
using PrivaPub.Federation.Moderation;
|
||||
using PrivaPub.Models;
|
||||
using PrivaPub.Models.Federation;
|
||||
using PrivaPub.Resources;
|
||||
|
||||
@@ -20,12 +23,14 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
readonly IDomainBlocks _domainBlocks;
|
||||
readonly IStringLocalizer _localizer;
|
||||
readonly Domain.Media.IMediaProxy _proxy;
|
||||
readonly IModerationLog _log;
|
||||
|
||||
public DomainBlockController(IDomainBlocks domainBlocks, IStringLocalizer<GenericRes> localizer, Domain.Media.IMediaProxy proxy)
|
||||
public DomainBlockController(IDomainBlocks domainBlocks, IStringLocalizer<GenericRes> localizer, Domain.Media.IMediaProxy proxy, IModerationLog log)
|
||||
{
|
||||
_domainBlocks = domainBlocks;
|
||||
_localizer = localizer;
|
||||
_proxy = proxy;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
[HttpGet, Route("/clientapi/admin/domainblocks/list")]
|
||||
@@ -46,6 +51,8 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
.Modify(b => b.RejectMedia, form.RejectMedia)
|
||||
.Modify(b => b.PublicComment, form.PublicComment)
|
||||
.Modify(b => b.PrivateComment, form.PrivateComment)
|
||||
.Modify(b => b.Published, form.Published)
|
||||
.Modify(b => b.Obfuscate, form.Obfuscate)
|
||||
.Modify(b => b.SetOnInsert(x => x.CreatedAt, DateTime.UtcNow))
|
||||
.Option(o => o.IsUpsert = true)
|
||||
.ExecuteAsync(token);
|
||||
@@ -53,6 +60,9 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
// what the media proxy holds of it goes with the block
|
||||
if (block.Severity == DomainBlockSeverity.Suspend || block.RejectMedia)
|
||||
_proxy.Purge(domain);
|
||||
await _log.Write(User.GetUserId(), AdminActions.DomainBlockInsert, AdminTargets.Domain, domain, domain,
|
||||
note: string.Join(", ", new[] { block.Severity.ToString().ToLowerInvariant(), block.RejectMedia ? "media rejected" : default,
|
||||
block.Published ? (block.Obfuscate ? "published, obfuscated" : "published") : default }.Where(n => n != default)), token: token);
|
||||
return Ok(ToView(block));
|
||||
}
|
||||
|
||||
@@ -60,8 +70,10 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
public async Task<IActionResult> Delete([FromQuery] string domain, CancellationToken token)
|
||||
{
|
||||
domain = DomainBlocks.Normalise(domain);
|
||||
await DB.Default.DeleteAsync<DomainBlock>(b => b.Domain == domain);
|
||||
var deleted = await DB.Default.DeleteAsync<DomainBlock>(b => b.Domain == domain);
|
||||
await _domainBlocks.Reload(token);
|
||||
if (deleted.DeletedCount > 0)
|
||||
await _log.Write(User.GetUserId(), AdminActions.DomainBlockDelete, AdminTargets.Domain, domain, domain, token: token);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -73,6 +85,8 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
RejectMedia = block.RejectMedia,
|
||||
PublicComment = block.PublicComment,
|
||||
PrivateComment = block.PrivateComment,
|
||||
Published = block.Published,
|
||||
Obfuscate = block.Obfuscate,
|
||||
CreatedAt = block.CreatedAt
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user