diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-11-03 01:00:12 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-11-03 01:00:12 +0000 |
commit | 0d8cc0905aeebb965df0cf755a171d21b01ed978 (patch) | |
tree | 70eb61d52bc4eb52be17cd8ab2cf9591e4cf2908 /lib | |
parent | 0fd2830fe14e73c575f73eeb2ccfaf2bd5a27eba (diff) | |
parent | 53dd048590b93da67f9d4abac8cc111424c4d5c0 (diff) | |
download | pleroma-0d8cc0905aeebb965df0cf755a171d21b01ed978.tar.gz |
Merge branch 'fix/get_report_with_notes' into 'develop'
Permit fetching individual reports with notes preloaded
See merge request pleroma/pleroma!3118
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/activity.ex | 13 | ||||
-rw-r--r-- | lib/pleroma/web/admin_api/controllers/report_controller.ex | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 17af04257..553834da0 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -14,6 +14,7 @@ defmodule Pleroma.Activity do alias Pleroma.ReportNote alias Pleroma.ThreadMute alias Pleroma.User + alias Pleroma.Web.ActivityPub.ActivityPub import Ecto.Changeset import Ecto.Query @@ -153,6 +154,18 @@ defmodule Pleroma.Activity do def get_bookmark(_, _), do: nil + def get_report(activity_id) do + opts = %{ + type: "Flag", + skip_preload: true, + preload_report_notes: true + } + + ActivityPub.fetch_activities_query([], opts) + |> where(id: ^activity_id) + |> Repo.one() + end + def change(struct, params \\ %{}) do struct |> cast(params, [:data, :recipients]) diff --git a/lib/pleroma/web/admin_api/controllers/report_controller.ex b/lib/pleroma/web/admin_api/controllers/report_controller.ex index 86da93893..6a0e56f5f 100644 --- a/lib/pleroma/web/admin_api/controllers/report_controller.ex +++ b/lib/pleroma/web/admin_api/controllers/report_controller.ex @@ -38,7 +38,7 @@ defmodule Pleroma.Web.AdminAPI.ReportController do end def show(conn, %{id: id}) do - with %Activity{} = report <- Activity.get_by_id(id) do + with %Activity{} = report <- Activity.get_report(id) do render(conn, "show.json", Report.extract_report_info(report)) else _ -> {:error, :not_found} |