Permit fetching individual reports with notes preloaded
This commit is contained in:
parent
24ce324973
commit
7efc074ead
|
@ -14,6 +14,7 @@ defmodule Pleroma.Activity do
|
||||||
alias Pleroma.ReportNote
|
alias Pleroma.ReportNote
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
@ -153,6 +154,18 @@ def get_bookmark(%Activity{} = activity, %User{} = user) do
|
||||||
|
|
||||||
def get_bookmark(_, _), do: nil
|
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
|
def change(struct, params \\ %{}) do
|
||||||
struct
|
struct
|
||||||
|> cast(params, [:data, :recipients])
|
|> cast(params, [:data, :recipients])
|
||||||
|
|
|
@ -38,7 +38,7 @@ def index(conn, params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(conn, %{id: id}) do
|
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))
|
render(conn, "show.json", Report.extract_report_info(report))
|
||||||
else
|
else
|
||||||
_ -> {:error, :not_found}
|
_ -> {:error, :not_found}
|
||||||
|
|
Loading…
Reference in New Issue