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 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) }); } } }