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
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using MongoDB.Entities;
|
||||
|
||||
using PrivaPub.Api.Mastodon.Entities;
|
||||
using PrivaPub.Api.Mastodon.Infrastructure;
|
||||
using PrivaPub.Api.Mastodon.Mappers;
|
||||
using PrivaPub.Domain.Privacy;
|
||||
@@ -20,7 +21,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
const int MaxMembers = 500;
|
||||
|
||||
|
||||
static object View(PersonaList list) => new { id = list.ID, title = list.Title, replies_policy = list.RepliesPolicy, exclusive = list.Exclusive };
|
||||
static object View(PersonaList list) => new ListEntity { Id = list.ID, Title = list.Title, RepliesPolicy = list.RepliesPolicy, Exclusive = list.Exclusive };
|
||||
|
||||
Task<PersonaList> Mine(string id, CancellationToken token) =>
|
||||
DB.Default.Find<PersonaList>().Match(l => l.ID == id && l.AvatarId == MyId).ExecuteFirstAsync(token);
|
||||
@@ -97,7 +98,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
return NotFoundError();
|
||||
await DB.Default.DeleteAsync<PersonaListMember>(m => m.ListId == list.ID);
|
||||
await DB.Default.DeleteAsync<PersonaList>(list.ID);
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
|
||||
[HttpGet(ApiPaths.Lists.GET_M_Accounts), Scope("read:lists")]
|
||||
@@ -131,7 +132,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
return Error(StatusCodes.Status422UnprocessableEntity, "Validation failed: Too many accounts in the list");
|
||||
foreach (var account in ids.Where(a => !present.Contains(a)))
|
||||
await DB.Default.SaveAsync(new PersonaListMember { ListId = list.ID, AvatarId = MyId, AccountId = account }, token);
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
|
||||
[HttpDelete(ApiPaths.Lists.DELETE_M_Remove), Scope("write:lists")]
|
||||
@@ -141,7 +142,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
return NotFoundError();
|
||||
var ids = Params.List("account_ids");
|
||||
await DB.Default.DeleteAsync<PersonaListMember>(m => m.ListId == list.ID && ids.Contains(m.AccountId));
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
|
||||
[HttpGet(ApiPaths.Lists.GET_M_Containing), Scope("read:lists")]
|
||||
|
||||
Reference in new issue
Block a user