Files
SocialPub/PrivaPub/Api/Mastodon/Controllers/ReportsController.cs
T
thepraandClaude Opus 5.5 f3fdeaf038
Build / Build (push) Successful in 36s
The API's JSON is generated at build time, and no answer is an anonymous object
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
2026-11-10 07:28:02 +01:00

37 lines
1.2 KiB
C#

using Microsoft.AspNetCore.Mvc;
using PrivaPub.Api.Mastodon.Entities;
using PrivaPub.Api.Mastodon.Infrastructure;
using PrivaPub.Api.Mastodon.Mappers;
using PrivaPub.Domain.Relationships;
namespace PrivaPub.Api.Mastodon.Controllers
{
public class ReportsController(
IReportService reportService,
MastodonMapper mapper) : MastodonController
{
[HttpPost(ApiPaths.Reports.POST_Create), Scope("write:reports")]
public async Task<IActionResult> Create(CancellationToken token)
{
var report = await reportService.File(Me, Params.Get("account_id"), Params.List("status_ids"), Params.Get("comment"), Params.Get("category"),
Params.List("rule_ids"), Params.Bool("forward") == true, token);
if (report == default)
return NotFoundError();
return Json(new ReportEntity
{
Id = report.ID,
ActionTaken = false,
ActionTakenAt = default(string),
Category = report.Category,
Comment = report.Comment ?? string.Empty,
Forwarded = report.Forwarded,
CreatedAt = MastodonJson.Time(report.CreatedAt),
StatusIds = report.PostIds,
RuleIds = report.RuleIds,
TargetAccount = await mapper.Account(report.TargetAccountId, token)
});
}
}
}