All 384 routes, the Mastodon API, the client API and the frozen federation paths, are read from one class with one nested class per controller. Their values are unchanged, checked one by one against the old literals; decePubClient keeps its own APIs class. Checked against GoToSocial in the pasture: 64 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
1 parent
0f73f69239
commit
739a1603ca
47 files changed
+952
-373
No files matched your search
@@ -15,7 +15,7 @@ using PrivaPub.Models.User;
|
||||
namespace PrivaPub.Controllers.ClientToServer
|
||||
{
|
||||
[ApiController,
|
||||
Route("clientapi/moderator"),
|
||||
Route(ApiPaths.Moderator.Prefix),
|
||||
Authorize(Policy = Policies.IsModerator)]
|
||||
public class ModeratorController(
|
||||
IInstanceSettings settings,
|
||||
@@ -29,7 +29,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
const int MaxAccountsPage = 100;
|
||||
|
||||
|
||||
[HttpGet, Route("/clientapi/moderator/reports")]
|
||||
[HttpGet, Route(ApiPaths.Moderator.GET_Reports)]
|
||||
public async Task<IActionResult> Reports([FromQuery] bool resolved, CancellationToken token)
|
||||
{
|
||||
var rules = settings.Current.Rules.ToDictionary(r => r.Id, r => r.Text ?? string.Empty);
|
||||
@@ -60,7 +60,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
// A report resolved, and with it what the staff does about it (R6): nothing more, the reported account silenced or
|
||||
// suspended, or the reported posts removed. The act comes first: one that fails leaves the report open. The body is
|
||||
// optional (a report only marked resolved, as before R6).
|
||||
[HttpPost, Route("/clientapi/moderator/reports/{id}/resolve")]
|
||||
[HttpPost, Route(ApiPaths.Moderator.POST_M_Resolve)]
|
||||
public async Task<IActionResult> Resolve(string id, [FromBody(EmptyBodyBehavior = Microsoft.AspNetCore.Mvc.ModelBinding.EmptyBodyBehavior.Allow)] ResolveReportForm form,
|
||||
CancellationToken token)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
|
||||
// Accounts to moderate, found by a name (a persona's, or user@host for an account elsewhere) or an actor's address:
|
||||
// personas here, never their logins, and accounts elsewhere PrivaPub holds
|
||||
[HttpGet, Route("/clientapi/moderator/accounts")]
|
||||
[HttpGet, Route(ApiPaths.Moderator.GET_Accounts)]
|
||||
public async Task<IActionResult> Accounts([FromQuery] string q, [FromQuery] int limit = 20, CancellationToken token = default)
|
||||
{
|
||||
limit = Math.Clamp(limit, 1, 40);
|
||||
@@ -145,7 +145,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
|
||||
// what the staff silenced or suspended, here and elsewhere, most recently moderated first (a banned login's personas
|
||||
// are never among them: the ban is the login's, and only administrators see logins)
|
||||
[HttpGet, Route("/clientapi/moderator/accounts/moderated")]
|
||||
[HttpGet, Route(ApiPaths.Moderator.GET_Moderated)]
|
||||
public async Task<IActionResult> Moderated([FromQuery] int offset = 0, [FromQuery] int limit = 50, CancellationToken token = default)
|
||||
{
|
||||
offset = Math.Max(0, offset);
|
||||
@@ -163,12 +163,12 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
|
||||
static DateTime Latest(DateTime? a, DateTime? b) => (a ?? DateTime.MinValue) > (b ?? DateTime.MinValue) ? a ?? DateTime.MinValue : b ?? DateTime.MinValue;
|
||||
|
||||
[HttpGet, Route("/clientapi/moderator/accounts/{id}")]
|
||||
[HttpGet, Route(ApiPaths.Moderator.GET_M_Account)]
|
||||
public async Task<IActionResult> Account(string id, CancellationToken token) =>
|
||||
await accountModeration.View(id, token) is { } account ? Ok(account) : NotFound();
|
||||
|
||||
// silence, unsilence, suspend or unsuspend a persona here or an account elsewhere
|
||||
[HttpPost, Route("/clientapi/moderator/accounts/moderate")]
|
||||
[HttpPost, Route(ApiPaths.Moderator.POST_Moderate)]
|
||||
public async Task<IActionResult> Moderate(ModerateAccountForm form, CancellationToken token)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@@ -178,7 +178,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// a post taken down: deleted when it is ours (the deletion federates), hidden here when it is a copy
|
||||
[HttpPost, Route("/clientapi/moderator/posts/remove")]
|
||||
[HttpPost, Route(ApiPaths.Moderator.POST_RemovePost)]
|
||||
public async Task<IActionResult> RemovePost(RemovePostForm form, CancellationToken token)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@@ -190,7 +190,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
// The staff's log, newest first, a page at a time (before: the last id of the page before). Administrators read all
|
||||
// of it; a moderator who isn't one reads what isn't about a login, and who acted only when it was the command line or
|
||||
// themselves.
|
||||
[HttpGet, Route("/clientapi/moderator/log")]
|
||||
[HttpGet, Route(ApiPaths.Moderator.GET_Log)]
|
||||
public async Task<IActionResult> Log([FromQuery] string before, [FromQuery] int limit = 50, CancellationToken token = default)
|
||||
{
|
||||
var me = await DB.Default.Find<RootUser>().MatchID(User.GetUserId()).ExecuteFirstAsync(token);
|
||||
|
||||
Reference in new issue
Block a user