The API's JSON is generated at build time, and no answer is an anonymous object
Build / Build (push) Successful in 36s

Every answer of the Mastodon API and the client API now has its JSON shape generated when the server is built, instead
of worked out by reflection while it runs; the bytes sent are unchanged. The small answers that were anonymous objects
(the instance documents, notification policies, reports, lists, tags, trends, errors and the empty answers) are named
types. A type without generated metadata fails at once in development and on the pasture, and in production is logged
and still answered. Three lists that were sent as lazy sequences (moderation reports, the published domain blocks and
the languages) are now built first.

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 07:28:02 +01:00
1 parent 8a1e4e419b
commit f3fdeaf038
41 files changed
+1333 -266

No files matched your search

@@ -65,7 +65,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
if (type is null or "statuses" && MyId != default && !q.StartsWith('#') && !Handle().IsMatch(q))
results.Statuses = await Words(q, Math.Max(0, offset), Limit(), token);
if (type is null or "hashtags" && TagsController.Normalise(q) is var tag && TagsController.IsHashtag(tag))
results.Hashtags.Add(new { name = tag, url = $"{localActors.BaseAddress}/tags/{Uri.EscapeDataString(tag)}", history = await TagsController.History(dbEntities, tag, token) });
results.Hashtags.Add(new SearchTagEntity { Name = tag, Url = $"{localActors.BaseAddress}/tags/{Uri.EscapeDataString(tag)}", History = await TagsController.History(dbEntities, tag, token) });
return Json(results);
}
}
@@ -138,10 +138,10 @@ namespace PrivaPub.Api.Mastodon.Controllers
[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 }));
.Select(code => new LanguageEntity { Code = code, Name = System.Globalization.CultureInfo.GetCultureInfo(code).EnglishName }).ToList());
[HttpGet(ApiPaths.Stubs.GET_TranslationLanguages), Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult TranslationLanguages() => Json(new { });
public IActionResult TranslationLanguages() => Json(new EmptyEntity());
// 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
@@ -151,10 +151,10 @@ namespace PrivaPub.Api.Mastodon.Controllers
// 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(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>() });
public IActionResult AnnualReports(string year) => Json(new AnnualReportsEntity { AnnualReports = Array.Empty<object>(), Accounts = Array.Empty<object>(), Statuses = Array.Empty<object>() });
[HttpPost(ApiPaths.Stubs.POST_M_ReadAnnualReport), Scope("write:accounts")]
public IActionResult ReadAnnualReport(string year) => Json(new { });
public IActionResult ReadAnnualReport(string year) => Json(new EmptyEntity());
// 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