Fix unit tests
This commit is contained in:
parent
0e0c316c76
commit
9d99e76a3a
@ -697,24 +697,22 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||||||
|
|
||||||
defp build_flag_object(%Activity{} = activity) do
|
defp build_flag_object(%Activity{} = activity) do
|
||||||
object = Object.normalize(activity, fetch: false)
|
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
|
end
|
||||||
|
|
||||||
defp build_flag_object(%Object{data: data}) do
|
defp build_flag_object(%Object{} = object) do
|
||||||
actor = User.get_by_ap_id(data["actor"])
|
actor = User.get_by_ap_id(object.data["actor"])
|
||||||
id = data["id"]
|
build_flag_object_with_actor_and_id(object, actor, object.data["id"])
|
||||||
|
|
||||||
%{
|
|
||||||
"type" => "Note",
|
|
||||||
"id" => id,
|
|
||||||
"content" => data["content"],
|
|
||||||
"published" => data["published"],
|
|
||||||
"actor" =>
|
|
||||||
AccountView.render(
|
|
||||||
"show.json",
|
|
||||||
%{user: actor, skip_visibility_check: true}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp build_flag_object(act) when is_map(act) or is_binary(act) do
|
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(_), 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
|
#### Report-related helpers
|
||||||
def get_reports(params, page, page_size) do
|
def get_reports(params, page, page_size) do
|
||||||
params =
|
params =
|
||||||
|
@ -1504,6 +1504,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
reporter_ap_id = reporter.ap_id
|
reporter_ap_id = reporter.ap_id
|
||||||
target_ap_id = target_account.ap_id
|
target_ap_id = target_account.ap_id
|
||||||
activity_ap_id = activity.data["id"]
|
activity_ap_id = activity.data["id"]
|
||||||
|
object_ap_id = activity.object.data["id"]
|
||||||
|
|
||||||
activity_with_object = Activity.get_by_ap_id_with_object(activity_ap_id)
|
activity_with_object = Activity.get_by_ap_id_with_object(activity_ap_id)
|
||||||
|
|
||||||
@ -1515,6 +1516,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
reported_activity: activity,
|
reported_activity: activity,
|
||||||
content: content,
|
content: content,
|
||||||
activity_ap_id: activity_ap_id,
|
activity_ap_id: activity_ap_id,
|
||||||
|
object_ap_id: object_ap_id,
|
||||||
activity_with_object: activity_with_object,
|
activity_with_object: activity_with_object,
|
||||||
reporter_ap_id: reporter_ap_id,
|
reporter_ap_id: reporter_ap_id,
|
||||||
target_ap_id: target_ap_id
|
target_ap_id: target_ap_id
|
||||||
@ -1528,7 +1530,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
target_account: target_account,
|
target_account: target_account,
|
||||||
reported_activity: reported_activity,
|
reported_activity: reported_activity,
|
||||||
content: content,
|
content: content,
|
||||||
activity_ap_id: activity_ap_id,
|
object_ap_id: object_ap_id,
|
||||||
activity_with_object: activity_with_object,
|
activity_with_object: activity_with_object,
|
||||||
reporter_ap_id: reporter_ap_id,
|
reporter_ap_id: reporter_ap_id,
|
||||||
target_ap_id: target_ap_id
|
target_ap_id: target_ap_id
|
||||||
@ -1544,7 +1546,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
|
|
||||||
note_obj = %{
|
note_obj = %{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"id" => activity_ap_id,
|
"id" => object_ap_id,
|
||||||
"content" => content,
|
"content" => content,
|
||||||
"published" => activity_with_object.object.data["published"],
|
"published" => activity_with_object.object.data["published"],
|
||||||
"actor" =>
|
"actor" =>
|
||||||
@ -1568,6 +1570,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
context: context,
|
context: context,
|
||||||
target_account: target_account,
|
target_account: target_account,
|
||||||
reported_activity: reported_activity,
|
reported_activity: reported_activity,
|
||||||
|
object_ap_id: object_ap_id,
|
||||||
content: content
|
content: content
|
||||||
},
|
},
|
||||||
Utils,
|
Utils,
|
||||||
@ -1582,8 +1585,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
content: content
|
content: content
|
||||||
})
|
})
|
||||||
|
|
||||||
new_data =
|
new_data = put_in(activity.data, ["object"], [target_account.ap_id, object_ap_id])
|
||||||
put_in(activity.data, ["object"], [target_account.ap_id, reported_activity.data["id"]])
|
|
||||||
|
|
||||||
assert_called(Utils.maybe_federate(%{activity | data: new_data}))
|
assert_called(Utils.maybe_federate(%{activity | data: new_data}))
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||||||
|
|
||||||
note_obj = %{
|
note_obj = %{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"id" => activity.data["id"],
|
"id" => activity.object.data["id"],
|
||||||
"content" => "test post",
|
"content" => "test post",
|
||||||
"published" => object.data["published"],
|
"published" => object.data["published"],
|
||||||
"actor" => AccountView.render("show.json", %{user: user, skip_visibility_check: true})
|
"actor" => AccountView.render("show.json", %{user: user, skip_visibility_check: true})
|
||||||
|
Loading…
Reference in New Issue
Block a user