42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
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 : MastodonController
|
||
|
|
{
|
||
|
|
readonly IReportService _reports;
|
||
|
|
readonly MastodonMapper _mapper;
|
||
|
|
|
||
|
|
public ReportsController(IReportService reports, MastodonMapper mapper)
|
||
|
|
{
|
||
|
|
_reports = reports;
|
||
|
|
_mapper = mapper;
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPost("/api/v1/reports"), Scope("write:reports")]
|
||
|
|
public async Task<IActionResult> Create(CancellationToken token)
|
||
|
|
{
|
||
|
|
var report = await _reports.File(Me, Params.Get("account_id"), Params.List("status_ids"), Params.Get("comment"), Params.Get("category"),
|
||
|
|
Params.Bool("forward") == true, token);
|
||
|
|
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 = Array.Empty<string>(),
|
||
|
|
target_account = await _mapper.Account(report.TargetAccountId, token)
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|