The API's JSON is generated at build time, and no answer is an anonymous object
Build / Build (push) Successful in 36s
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:
1 parent
8a1e4e419b
commit
f3fdeaf038
41 files changed
+1333
-266
No files matched your search
@@ -93,6 +93,7 @@ PrivaPub/ ASP.NET Core Web API, net10.0
|
||||
Infrastructure/
|
||||
Http/ FederationHttp + SafeHttpHandlerFactory + IpRangeGuard: the only way out
|
||||
Jobs/ JobQueue (leases), JobWorker, Backoff, HostCircuitBreaker
|
||||
Json/ ServerJsonContext, PrivaPubJson (the serializer chains), UnregisteredJson, ViewBuild
|
||||
Push/ Web Push (R9): Vapid (the server's key, ES256 JWTs), WebPushCrypto (aes128gcm, aesgcm),
|
||||
WebPushJob (SendPush, through the `push` client)
|
||||
Ids/ PrivacyIds (day-only ids for personas and groups, arrival-ordered ids for remote posts)
|
||||
@@ -144,7 +145,8 @@ PrivaPub/ ASP.NET Core Web API, net10.0
|
||||
Participations: a persona's Join and Leave of a remote event, and the organiser's answer
|
||||
Api/Mastodon/
|
||||
Auth/ OpenIddict setup (keys in Mongo), MastodonScopes, TokenController, OAuthPruner
|
||||
Infrastructure/ MastodonController (avatar context, scopes, errors, Link), MastodonParams, MastodonJson, Page
|
||||
Infrastructure/ MastodonController (avatar context, scopes, errors, Link), MastodonParams, MastodonJson,
|
||||
MastodonJsonContext, Page
|
||||
Entities/ Mappers/ Mastodon entities; MastodonMapper (Account, Status), AccountSearch
|
||||
Controllers/ apps, instance, accounts, statuses, timelines, notifications, search, lists, filters,
|
||||
media, polls, reactions, reports, scheduled statuses, streaming, tags, trends, cdns,
|
||||
@@ -1106,7 +1108,23 @@ same rules. Applied to PrivaPub:
|
||||
- **Routes** are constants in `PrivaPub/ApiPaths.cs` (HR0305): one nested class per controller, `GET_`/`POST_`/…,
|
||||
`_M_` when the template has parameters, `Prefix` for a controller's own `[Route]`. The values are the frozen routes
|
||||
above, never changed by a rename. decePubClient keeps its own `APIs` class (owner, 2026-11-10: kept separate).
|
||||
- **Still open:** source-generated JSON contexts (HR0306).
|
||||
- **JSON (HR0306):** everything that crosses HTTP has source-generated metadata, and no response is an anonymous object.
|
||||
- `PrivaPub.ClientModels/ClientModelsJsonContext` holds every `/clientapi` DTO, shared with decePubClient.
|
||||
`Infrastructure/Json/ServerJsonContext` holds the server-only ones: problem details, `/build.json` and the Web Push
|
||||
and VAPID dictionaries. Both are chained into MVC's and the minimal APIs' options, `PrivaPubJson.Web` and
|
||||
`PrivaPubJson.Plain` (`PrivaPubJson.Chain`).
|
||||
- `Api/Mastodon/Infrastructure/MastodonJsonContext` holds every Mastodon entity (`Entities/Entities.cs` and
|
||||
`Entities/Documents.cs`, the named shapes of instance, policy, report and the other small answers), with `List<T>` of
|
||||
each and the boxed values the `object` members carry. It is chained into `MastodonJson.Options`, which the API,
|
||||
streaming and error bodies use.
|
||||
- An answer is a list or an array, never a lazy `Select`: an iterator's type has no metadata.
|
||||
- The last resolver of each chain is `UnregisteredJson`. In Development and the pasture an unregistered type throws.
|
||||
In Production it is logged as an error once and still serialized, so a gap never takes the server down.
|
||||
`PrivaPubJson.Check` fails startup outside Production when a class in `PrivaPub.ClientModels` or
|
||||
`Api/Mastodon/Entities` has no metadata.
|
||||
- The documented exceptions: ActivityPub documents are built and read as `JsonNode` (`ActivityPubRenderer`,
|
||||
`ActivityJson`). Job payloads, backup manifests, restore markers and archive exports are stored, not sent, and keep
|
||||
the default options. OpenIddict writes its own token responses.
|
||||
|
||||
## Verifying
|
||||
|
||||
|
||||
Reference in new issue
Block a user