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

36 lines
1.2 KiB
C#
Raw Normal View History

2026-10-01 12:13:57 +02:00
using Microsoft.AspNetCore.Mvc;
using PrivaPub.Api.Mastodon.Entities;
2026-10-01 12:13:57 +02:00
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
{
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)
{
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 ReportEntity
2026-10-01 12:13:57 +02:00
{
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)
2026-10-01 12:13:57 +02:00
});
}
}
}