Files
SocialPub/PrivaPub/Api/Mastodon/Controllers/ReportsController.cs
T

35 lines
1.1 KiB
C#
Raw Normal View History

2026-10-01 12:13:57 +02:00
using Microsoft.AspNetCore.Mvc;
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
2026-10-01 12:13:57 +02:00
{
[HttpPost("/api/v1/reports"), 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);
2026-10-01 12:13:57 +02:00
if (report == default)
return NotFoundError();
return Json(new
{
id = report.ID,
action_taken = false,
action_taken_at = default(string),
category = report.Category,
comment = report.Comment ?? string.Empty,
forwarded = report.Forwarded,
created_at = MastodonJson.Time(report.CreatedAt),
status_ids = report.PostIds,
rule_ids = report.RuleIds,
target_account = await mapper.Account(report.TargetAccountId, token)
2026-10-01 12:13:57 +02:00
});
}
}
}