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
@@ -399,10 +399,10 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
.ExecuteAsync(token);
|
||||
var followers = await dbEntities.Followers.Match(f => f.LocalActorId == MyId && f.IsAccepted).ExecuteAsync(token);
|
||||
var handles = await Hidden.HandleDomains(followings.Select(f => f.TargetActorURI).Concat(followers.Select(f => f.ActorURI)).ToList(), token);
|
||||
return Json(new
|
||||
return Json(new DomainBlockPreviewEntity
|
||||
{
|
||||
following_count = followings.Count(f => Hidden.Blocks(domain, f.TargetActorURI, handles.GetValueOrDefault(f.TargetActorURI))),
|
||||
followers_count = followers.Count(f => Hidden.Blocks(domain, f.ActorURI, handles.GetValueOrDefault(f.ActorURI)))
|
||||
FollowingCount = followings.Count(f => Hidden.Blocks(domain, f.TargetActorURI, handles.GetValueOrDefault(f.TargetActorURI))),
|
||||
FollowersCount = followers.Count(f => Hidden.Blocks(domain, f.ActorURI, handles.GetValueOrDefault(f.ActorURI)))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -410,14 +410,14 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
public async Task<IActionResult> BlockDomain(CancellationToken token)
|
||||
{
|
||||
await relationshipService.BlockDomain(Me, Params.Get("domain"), token);
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
|
||||
[HttpDelete(ApiPaths.Accounts.DELETE_UnblockDomain), Scope("write:blocks")]
|
||||
public async Task<IActionResult> UnblockDomain(CancellationToken token)
|
||||
{
|
||||
await relationshipService.UnblockDomain(Me, Params.Get("domain"), token);
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
|
||||
[HttpGet(ApiPaths.Accounts.GET_FollowRequests), Scope("read:follows")]
|
||||
@@ -440,7 +440,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
// tell who follows whom among the personas here (and their followers lists are never shown, hide_collections), so
|
||||
// every account answers none
|
||||
[HttpGet(ApiPaths.Accounts.GET_FamiliarFollowers), Scope("read:follows")]
|
||||
public IActionResult FamiliarFollowers() => Json(Params.List("id").Select(id => new { id, accounts = Array.Empty<Account>() }).ToList());
|
||||
public IActionResult FamiliarFollowers() => Json(Params.List("id").Select(id => new FamiliarFollowersEntity { Id = id, Accounts = Array.Empty<Account>() }).ToList());
|
||||
|
||||
// Endorsements (R8): Mastodon's account pins under their old names (pin, unpin) and 4.4's (endorse, unendorse). Only an
|
||||
// account the persona follows may be endorsed, as Mastodon requires; they are the persona's alone, never federated as
|
||||
|
||||
Reference in new issue
Block a user