Fetch account from report, not from status (it might be deleted)
This commit is contained in:
parent
5135656f57
commit
fcabcab443
|
@ -798,11 +798,18 @@ def parse_report_group(activity) do
|
||||||
reports = get_reports_by_status_id(activity["id"])
|
reports = get_reports_by_status_id(activity["id"])
|
||||||
max_date = Enum.max_by(reports, &NaiveDateTime.from_iso8601!(&1.data["published"]))
|
max_date = Enum.max_by(reports, &NaiveDateTime.from_iso8601!(&1.data["published"]))
|
||||||
actors = Enum.map(reports, & &1.user_actor)
|
actors = Enum.map(reports, & &1.user_actor)
|
||||||
|
[%{data: %{"object" => [account_id | _]}} | _] = reports
|
||||||
|
|
||||||
|
account =
|
||||||
|
AccountView.render("show.json", %{
|
||||||
|
user: User.get_by_ap_id(account_id)
|
||||||
|
})
|
||||||
|
|
||||||
status = get_status_data(activity)
|
status = get_status_data(activity)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
date: max_date.data["published"],
|
date: max_date.data["published"],
|
||||||
account: activity["actor"],
|
account: account,
|
||||||
status: status,
|
status: status,
|
||||||
actors: Enum.uniq(actors),
|
actors: Enum.uniq(actors),
|
||||||
reports: reports
|
reports: reports
|
||||||
|
|
|
@ -647,11 +647,11 @@ def list_reports(conn, params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_grouped_reports(conn, _params) do
|
def list_grouped_reports(conn, _params) do
|
||||||
reports = Utils.get_reported_activities()
|
statuses = Utils.get_reported_activities()
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(ReportView)
|
|> put_view(ReportView)
|
||||||
|> render("index_grouped.json", Utils.get_reports_grouped_by_status(reports))
|
|> render("index_grouped.json", Utils.get_reports_grouped_by_status(statuses))
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_show(conn, %{"id" => id}) do
|
def report_show(conn, %{"id" => id}) do
|
||||||
|
|
|
@ -1755,6 +1755,25 @@ test "reopened report does not render status data if status has been deleted", %
|
||||||
|
|
||||||
assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
|
assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "account not empty if status was deleted", %{
|
||||||
|
conn: conn,
|
||||||
|
first_report: first_report,
|
||||||
|
first_status: first_status,
|
||||||
|
target_user: target_user
|
||||||
|
} do
|
||||||
|
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||||
|
{:ok, _} = CommonAPI.delete(first_status.id, target_user)
|
||||||
|
|
||||||
|
refute Activity.get_by_ap_id(first_status.id)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/pleroma/admin/grouped_reports")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["account"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /api/pleroma/admin/reports/:id/respond" do
|
describe "POST /api/pleroma/admin/reports/:id/respond" do
|
||||||
|
|
Loading…
Reference in New Issue