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
|
|
|
|
|
{
|
2026-11-10 01:24:43 +01:00
|
|
|
public class ReportsController(
|
|
|
|
|
IReportService reportService,
|
|
|
|
|
MastodonMapper mapper) : MastodonController
|
2026-10-01 12:13:57 +02:00
|
|
|
{
|
2026-11-10 01:59:20 +01:00
|
|
|
[HttpPost(ApiPaths.Reports.POST_Create), Scope("write:reports")]
|
2026-10-01 12:13:57 +02:00
|
|
|
public async Task<IActionResult> Create(CancellationToken token)
|
|
|
|
|
{
|
2026-11-10 01:24:43 +01:00
|
|
|
var report = await reportService.File(Me, Params.Get("account_id"), Params.List("status_ids"), Params.Get("comment"), Params.Get("category"),
|
2026-10-17 04:02:47 +02:00
|
|
|
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,
|
2026-10-17 04:02:47 +02:00
|
|
|
rule_ids = report.RuleIds,
|
2026-11-10 01:24:43 +01:00
|
|
|
target_account = await mapper.Account(report.TargetAccountId, token)
|
2026-10-01 12:13:57 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|