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,10 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using MongoDB.Entities;
|
||||
|
||||
using EmptyEntity = PrivaPub.Api.Mastodon.Entities.EmptyEntity;
|
||||
using ScheduledStatusEntity = PrivaPub.Api.Mastodon.Entities.ScheduledStatusEntity;
|
||||
using ScheduledStatusParamsEntity = PrivaPub.Api.Mastodon.Entities.ScheduledStatusParamsEntity;
|
||||
using ScheduledStatusParamsPollEntity = PrivaPub.Api.Mastodon.Entities.ScheduledStatusParamsPollEntity;
|
||||
using PrivaPub.Api.Mastodon.Infrastructure;
|
||||
using PrivaPub.Domain.Media;
|
||||
using PrivaPub.Domain.Statuses;
|
||||
@@ -24,27 +28,27 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
var attachments = ids.Count == 0
|
||||
? new List<MediaAttachment>()
|
||||
: await DB.Default.Find<MediaAttachment>().Match(m => ids.Contains(m.ID)).ExecuteAsync(token);
|
||||
return new
|
||||
return new ScheduledStatusEntity
|
||||
{
|
||||
id = scheduled.ID,
|
||||
scheduled_at = MastodonJson.Time(scheduled.ScheduledAt),
|
||||
@params = new
|
||||
Id = scheduled.ID,
|
||||
ScheduledAt = MastodonJson.Time(scheduled.ScheduledAt),
|
||||
Params = new ScheduledStatusParamsEntity
|
||||
{
|
||||
text = p.Text,
|
||||
poll = p.Poll == default ? default : new { options = p.Poll.Options, expires_in = p.Poll.ExpiresIn, multiple = p.Poll.Multiple, hide_totals = p.Poll.HideTotals },
|
||||
media_ids = ids.Count == 0 ? default : ids,
|
||||
sensitive = p.Sensitive,
|
||||
spoiler_text = p.SpoilerText,
|
||||
visibility = p.Visibility,
|
||||
in_reply_to_id = p.InReplyToId,
|
||||
language = p.Language,
|
||||
application_id = default(string),
|
||||
scheduled_at = default(string),
|
||||
idempotency = p.Idempotency,
|
||||
with_rate_limit = false,
|
||||
quoted_status_id = p.QuotedStatusId
|
||||
Text = p.Text,
|
||||
Poll = p.Poll == default ? default : new ScheduledStatusParamsPollEntity { Options = p.Poll.Options, ExpiresIn = p.Poll.ExpiresIn, Multiple = p.Poll.Multiple, HideTotals = p.Poll.HideTotals },
|
||||
MediaIds = ids.Count == 0 ? default : ids,
|
||||
Sensitive = p.Sensitive,
|
||||
SpoilerText = p.SpoilerText,
|
||||
Visibility = p.Visibility,
|
||||
InReplyToId = p.InReplyToId,
|
||||
Language = p.Language,
|
||||
ApplicationId = default(string),
|
||||
ScheduledAt = default(string),
|
||||
Idempotency = p.Idempotency,
|
||||
WithRateLimit = false,
|
||||
QuotedStatusId = p.QuotedStatusId
|
||||
},
|
||||
media_attachments = ids.Select(id => attachments.FirstOrDefault(m => m.ID == id)).Where(m => m != default)
|
||||
MediaAttachments = ids.Select(id => attachments.FirstOrDefault(m => m.ID == id)).Where(m => m != default)
|
||||
.Select(m => MediaController.View(media, m)).ToList()
|
||||
};
|
||||
}
|
||||
@@ -91,7 +95,7 @@ namespace PrivaPub.Api.Mastodon.Controllers
|
||||
await DB.Default.DeleteAsync<ScheduledStatus>(scheduled.ID);
|
||||
// its media were the scheduled post's alone, never posted
|
||||
await mediaService.Trash(m => m.ScheduledStatusId == scheduled.ID, "scheduled post dropped", token);
|
||||
return Json(new { });
|
||||
return Json(new EmptyEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user