Fix unit tests

This commit is contained in:
tusooa 2022-11-20 00:57:04 -05:00
commit 9d99e76a3a
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 35 additions and 21 deletions

View file

@ -697,24 +697,22 @@ defmodule Pleroma.Web.ActivityPub.Utils do
defp build_flag_object(%Activity{} = activity) do
object = Object.normalize(activity, fetch: false)
build_flag_object(object)
# Do not allow people to report Creates. Instead, report the Object that is Created.
if activity.data["type"] != "Create" do
build_flag_object_with_actor_and_id(
object,
User.get_by_ap_id(activity.data["actor"]),
activity.data["id"]
)
else
build_flag_object(object)
end
end
defp build_flag_object(%Object{data: data}) do
actor = User.get_by_ap_id(data["actor"])
id = data["id"]
%{
"type" => "Note",
"id" => id,
"content" => data["content"],
"published" => data["published"],
"actor" =>
AccountView.render(
"show.json",
%{user: actor, skip_visibility_check: true}
)
}
defp build_flag_object(%Object{} = object) do
actor = User.get_by_ap_id(object.data["actor"])
build_flag_object_with_actor_and_id(object, actor, object.data["id"])
end
defp build_flag_object(act) when is_map(act) or is_binary(act) do
@ -740,6 +738,20 @@ defmodule Pleroma.Web.ActivityPub.Utils do
defp build_flag_object(_), do: []
defp build_flag_object_with_actor_and_id(%Object{data: data}, actor, id) do
%{
"type" => "Note",
"id" => id,
"content" => data["content"],
"published" => data["published"],
"actor" =>
AccountView.render(
"show.json",
%{user: actor, skip_visibility_check: true}
)
}
end
#### Report-related helpers
def get_reports(params, page, page_size) do
params =