Admin API: Render whole status in grouped reports
This commit is contained in:
parent
937d6c6b32
commit
2b341627da
4 changed files with 31 additions and 17 deletions
|
|
@ -822,20 +822,33 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
reports = get_reports_by_status_id(activity["id"])
|
||||
max_date = Enum.max_by(reports, &NaiveDateTime.from_iso8601!(&1.data["published"]))
|
||||
actors = Enum.map(reports, & &1.user_actor)
|
||||
{deleted, status} = get_status_data(activity)
|
||||
|
||||
%{
|
||||
date: max_date.data["published"],
|
||||
account: activity["actor"],
|
||||
status: %{
|
||||
id: activity["id"],
|
||||
content: activity["content"],
|
||||
published: activity["published"]
|
||||
},
|
||||
status: status,
|
||||
status_deleted: deleted,
|
||||
actors: Enum.uniq(actors),
|
||||
reports: reports
|
||||
}
|
||||
end
|
||||
|
||||
defp get_status_data(activity) do
|
||||
case Activity.get_by_ap_id(activity["id"]) do
|
||||
%Activity{} = act ->
|
||||
{false, act}
|
||||
|
||||
_ ->
|
||||
{true,
|
||||
%{
|
||||
id: activity["id"],
|
||||
content: activity["content"],
|
||||
published: activity["published"]
|
||||
}}
|
||||
end
|
||||
end
|
||||
|
||||
def get_reports_by_status_id(ap_id) do
|
||||
from(a in Activity,
|
||||
where: fragment("(?)->>'type' = 'Flag'", a.data),
|
||||
|
|
|
|||
|
|
@ -45,10 +45,16 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
|||
def render("index_grouped.json", %{groups: groups}) do
|
||||
reports =
|
||||
Enum.map(groups, fn group ->
|
||||
status =
|
||||
if group[:status_deleted],
|
||||
do: group[:status],
|
||||
else: StatusView.render("show.json", %{activity: group[:status]})
|
||||
|
||||
%{
|
||||
date: group[:date],
|
||||
account: group[:account],
|
||||
status: group[:status],
|
||||
status: status,
|
||||
status_deleted: status_deleted,
|
||||
actors: Enum.map(group[:actors], &merge_account_views/1),
|
||||
reports:
|
||||
group[:reports]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue