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

@@ -24,7 +24,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
AccountSearch accountSearch) : MastodonController
{
// Anyone may search, as on Mastodon; only resolving (which fetches from other servers) and paging need a sign-in.
[HttpGet("/api/v2/search"), Scope("read:search", requiresUser: false), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Search.GET_Search), Scope("read:search", requiresUser: false), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<IActionResult> Search(CancellationToken token)
{
var q = Params.Get("q")?.Trim();
@@ -130,58 +130,58 @@ namespace PrivaPub.Api.Mastodon.Controllers
{
// Routes Mastodon answers that we have nothing behind: an empty or default answer lets clients degrade, where a
// 404 breaks some of them (Mastodon invariant 5)
[HttpGet("/api/v1/timelines/link"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Stubs.GET_LinkTimeline), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult LinkTimeline() => Json(Array.Empty<object>());
[HttpGet("/api/v1/accounts/{id}/identity_proofs"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Stubs.GET_M_IdentityProofs), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult IdentityProofs(string id) => Json(Array.Empty<object>());
[HttpGet("/api/v1/instance/languages"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Stubs.GET_Languages), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult Languages() => Json(InstanceController.LanguageCodes(HttpContext.RequestServices)
.Select(code => new { code, name = System.Globalization.CultureInfo.GetCultureInfo(code).EnglishName }));
[HttpGet("/api/v1/instance/translation_languages"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Stubs.GET_TranslationLanguages), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult TranslationLanguages() => Json(new { });
// translation is cut (owner decision 2026-10-17): no language offers any (translation_languages), and a client that
// asks anyway is told so, as Mastodon tells it when it can't translate
[HttpPost("/api/v1/statuses/{id}/translate"), Scope("read:statuses")]
[HttpPost(ApiPaths.Stubs.POST_M_Translate), Scope("read:statuses")]
public IActionResult Translate(string id) => Error(StatusCodes.Status422UnprocessableEntity, "Translation is not available on this server");
// Mastodon 4.3's yearly reports (Wrapstodon): none are made here, so there are never any to show, for any year (4.4's
// show), and marking one read changes nothing
[HttpGet("/api/v1/annual_reports"), HttpGet("/api/v1/annual_reports/{year}"), Scope("read:accounts")]
[HttpGet(ApiPaths.Stubs.GET_AnnualReports), HttpGet(ApiPaths.Stubs.GET_M_AnnualReports), Scope("read:accounts")]
public IActionResult AnnualReports(string year) => Json(new { annual_reports = Array.Empty<object>(), accounts = Array.Empty<object>(), statuses = Array.Empty<object>() });
[HttpPost("/api/v1/annual_reports/{year}/read"), Scope("write:accounts")]
[HttpPost(ApiPaths.Stubs.POST_M_ReadAnnualReport), Scope("write:accounts")]
public IActionResult ReadAnnualReport(string year) => Json(new { });
// Registration through the API is cut (owner decision 2026-10-17): a login is made by setup or an invitation, on
// /clientapi. Mastodon answers this when its registrations are closed; its e-mail confirmation routes follow, since no
// account here waits for one
[HttpPost("/api/v1/accounts"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpPost(ApiPaths.Stubs.POST_Register), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult Register() => Error(StatusCodes.Status403Forbidden, "This action is not allowed");
[HttpPost("/api/v1/emails/confirmations"), Scope("write:accounts")]
[HttpPost(ApiPaths.Stubs.POST_ResendConfirmation), Scope("write:accounts")]
public IActionResult ResendConfirmation() =>
Error(StatusCodes.Status403Forbidden, "This method is only available while the e-mail is awaiting confirmation");
[HttpGet("/api/v1/emails/check_confirmation"), Scope("read:accounts")]
[HttpGet(ApiPaths.Stubs.GET_CheckConfirmation), Scope("read:accounts")]
public IActionResult CheckConfirmation() => Json(true);
// the peers' names are not published (/instance/peers stays empty), so a search of them finds none
[HttpGet("/api/v1/peers/search"), Microsoft.AspNetCore.Authorization.AllowAnonymous]
[HttpGet(ApiPaths.Stubs.GET_SearchPeers), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult SearchPeers() => Json(Array.Empty<string>());
// Mastodon 4.4's asynchronous refreshes are announced by a Mastodon-Async-Refresh header, which PrivaPub never sends
// (a thread's replies are read again in the background and simply show up): there is never one to ask about
[HttpGet("/api/v1_alpha/async_refreshes/{id}"), Scope("read")]
[HttpGet(ApiPaths.Stubs.GET_M_AsyncRefresh), Scope("read")]
public IActionResult AsyncRefresh(string id) => NotFoundError();
// the Mastodon admin API is cut: moderation stays on /clientapi (ModeratorController, AdminController), so every
// admin route answers as Mastodon answers an account that may not use it, whoever asks
[HttpGet("/api/v1/admin/{**rest}"), HttpPost("/api/v1/admin/{**rest}"), HttpPut("/api/v1/admin/{**rest}"), HttpPatch("/api/v1/admin/{**rest}"),
HttpDelete("/api/v1/admin/{**rest}"), HttpGet("/api/v2/admin/{**rest}"), HttpPost("/api/v2/admin/{**rest}"),
[HttpGet(ApiPaths.Stubs.GET_M_Admin), HttpPost(ApiPaths.Stubs.POST_M_Admin), HttpPut(ApiPaths.Stubs.PUT_M_Admin), HttpPatch(ApiPaths.Stubs.PATCH_M_Admin),
HttpDelete(ApiPaths.Stubs.DELETE_M_Admin), HttpGet(ApiPaths.Stubs.GET_M_AdminV2), HttpPost(ApiPaths.Stubs.POST_M_AdminV2),
ApiExplorerSettings(IgnoreApi = true), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult Admin(string rest) => Error(StatusCodes.Status403Forbidden, "This action is not allowed");
}