Every route is a constant in ApiPaths
Build / Build (push) Successful in 35s

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:
thepraandClaude Opus 5.5 committed 2026-11-10 01:59:20 +01:00
1 parent 0f73f69239
commit 739a1603ca
47 files changed
+952 -373

No files matched your search

@@ -29,7 +29,7 @@ namespace PrivaPub.Controllers.ClientToServer
// login's two-factor sign-in off. Every act is kept in the staff's log; an entry about a login names none of its
// personas.
[ApiController,
Route("clientapi/admin"),
Route(ApiPaths.Admin.Prefix),
Authorize(Policy = Policies.IsAdmin)]
public class AdminController(
ILogger<RootUserController> logger,
@@ -58,7 +58,7 @@ namespace PrivaPub.Controllers.ClientToServer
: (await DB.Default.Find<RootUser>().Match(u => ids.Contains(u.ID) && u.DeletedAt == null).ExecuteAsync(token)).ToDictionary(u => u.ID, u => u.UserName);
}
[HttpDelete, Route("/clientapi/admin/remove/users")]
[HttpDelete, Route(ApiPaths.Admin.DELETE_RemoveUsers)]
public async Task<IActionResult> RemoveUsers([Required] UsersIds usersIds, CancellationToken token)
{
var result = new WebResult();
@@ -82,7 +82,7 @@ namespace PrivaPub.Controllers.ClientToServer
// A ban ends the login's sessions and holds its personas back as suspended ones (Restrictions), without writing a word
// on any of them; unbanning gives them back as they were.
[HttpPost, Route("/clientapi/admin/ban/users")]
[HttpPost, Route(ApiPaths.Admin.POST_BanUsers)]
public async Task<IActionResult> BanUsers([Required] UsersIds usersIds, [FromServices] IRootSessions sessions, CancellationToken token)
{
if (!ModelState.IsValid)
@@ -114,7 +114,7 @@ namespace PrivaPub.Controllers.ClientToServer
}
}
[HttpPost, Route("/clientapi/admin/unban/users")]
[HttpPost, Route(ApiPaths.Admin.POST_UnbanUsers)]
public async Task<IActionResult> UnbanUsers([Required] UsersIds usersIds, CancellationToken token)
{
if (!ModelState.IsValid)
@@ -142,7 +142,7 @@ namespace PrivaPub.Controllers.ClientToServer
// The logins, newest first, each with its personas and the groups they own; q finds a login by its name, or by the
// name of one of its personas.
[HttpGet, Route("/clientapi/admin/roots")]
[HttpGet, Route(ApiPaths.Admin.GET_Roots)]
public async Task<IActionResult> Roots([FromQuery] string q, [FromQuery] string before, [FromQuery] int limit = 50, CancellationToken token = default)
{
limit = Math.Clamp(limit, 1, MaxRootsPage);
@@ -171,7 +171,7 @@ namespace PrivaPub.Controllers.ClientToServer
});
}
[HttpGet, Route("/clientapi/admin/roots/{id}")]
[HttpGet, Route(ApiPaths.Admin.GET_M_Root)]
public async Task<IActionResult> Root(string id, CancellationToken token)
{
var root = await DB.Default.Find<RootUser>().MatchID(id).Match(u => u.DeletedAt == null).ExecuteFirstAsync(token);
@@ -179,7 +179,7 @@ namespace PrivaPub.Controllers.ClientToServer
}
// A login's role: user, moderator or administrator. Never one's own, and never the last administrator's.
[HttpPost, Route("/clientapi/admin/roots/{id}/role")]
[HttpPost, Route(ApiPaths.Admin.POST_M_Role)]
public async Task<IActionResult> Role(string id, RootRoleForm form, CancellationToken token)
{
if (!ModelState.IsValid || !RootUser.TryParseRole(form.Role, out var role))
@@ -217,7 +217,7 @@ namespace PrivaPub.Controllers.ClientToServer
// A login that lost its authenticator and its recovery codes, as `PrivaPub admin reset-totp` does it: its two-factor
// sign-in goes, its password and sessions stay. Never one's own (that is /clientapi/user/totp/disable, with a code).
[HttpPost, Route("/clientapi/admin/roots/{id}/totp/reset")]
[HttpPost, Route(ApiPaths.Admin.POST_M_ResetTotp)]
public async Task<IActionResult> ResetTotp(string id, CancellationToken token)
{
if (id == User.GetUserId())
@@ -232,7 +232,7 @@ namespace PrivaPub.Controllers.ClientToServer
// A persona deleted by an administrator, who types their own password again: as its login would delete it
// (PersonaRemoval), the groups it owns with it. The log keeps it without who acted when it is the administrator's own.
[HttpPost, Route("/clientapi/admin/personas/{id}/delete")]
[HttpPost, Route(ApiPaths.Admin.POST_M_DeletePersona)]
public async Task<IActionResult> DeletePersona(string id, AdminPasswordForm form, [FromServices] IPersonaRemoval personas, CancellationToken token)
{
if (!ModelState.IsValid)
@@ -249,7 +249,7 @@ namespace PrivaPub.Controllers.ClientToServer
return Ok();
}
[HttpPost, Route("/clientapi/admin/groups/{id}/delete")]
[HttpPost, Route(ApiPaths.Admin.POST_M_DeleteGroup)]
public async Task<IActionResult> DeleteGroup(string id, AdminPasswordForm form, [FromServices] IGroupRemoval groups, CancellationToken token)
{
if (!ModelState.IsValid)