aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-11-28 00:09:00 +0900
committerMaxim Filippov <colixer@gmail.com>2019-11-28 00:09:00 +0900
commitfcabcab4430b0aa075243bf98630d67c79f3ef9b (patch)
tree0439551be52670b09922b31e753f119f6f46d83e
parent5135656f579954cf786011b539934c7150e0d0bc (diff)
downloadpleroma-fcabcab4430b0aa075243bf98630d67c79f3ef9b.tar.gz
Fetch account from report, not from status (it might be deleted)
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex9
-rw-r--r--lib/pleroma/web/admin_api/admin_api_controller.ex4
-rw-r--r--test/web/admin_api/admin_api_controller_test.exs19
3 files changed, 29 insertions, 3 deletions
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index d91abf7b3..2ca805c09 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -798,11 +798,18 @@ 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)
+ [%{data: %{"object" => [account_id | _]}} | _] = reports
+
+ account =
+ AccountView.render("show.json", %{
+ user: User.get_by_ap_id(account_id)
+ })
+
status = get_status_data(activity)
%{
date: max_date.data["published"],
- account: activity["actor"],
+ account: account,
status: status,
actors: Enum.uniq(actors),
reports: reports
diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex
index 24fdc3c82..b003d1f35 100644
--- a/lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/admin_api_controller.ex
@@ -647,11 +647,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
end
def list_grouped_reports(conn, _params) do
- reports = Utils.get_reported_activities()
+ statuses = Utils.get_reported_activities()
conn
|> 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
def report_show(conn, %{"id" => id}) do
diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs
index a69fadcdc..108baad91 100644
--- a/test/web/admin_api/admin_api_controller_test.exs
+++ b/test/web/admin_api/admin_api_controller_test.exs
@@ -1755,6 +1755,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
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
describe "POST /api/pleroma/admin/reports/:id/respond" do