mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Merge branch 'strip-fix' into 'develop'
Strip fix See merge request pleroma/pleroma!3981
This commit is contained in:
commit
2b839197a9
3 changed files with 42 additions and 3 deletions
1
changelog.d/anonymous-exception-else.fix
Normal file
1
changelog.d/anonymous-exception-else.fix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix #strip_report_status_data
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
alias Ecto.UUID
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
|
||||
alias Pleroma.Maps
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Object
|
||||
|
@ -852,9 +853,11 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
[actor | reported_activities] = activity.data["object"]
|
||||
|
||||
stripped_activities =
|
||||
Enum.map(reported_activities, fn
|
||||
act when is_map(act) -> act["id"]
|
||||
act when is_binary(act) -> act
|
||||
Enum.reduce(reported_activities, [], fn act, acc ->
|
||||
case ObjectID.cast(act) do
|
||||
{:ok, act} -> [act | acc]
|
||||
_ -> acc
|
||||
end
|
||||
end)
|
||||
|
||||
new_data = put_in(activity.data, ["object"], [actor | stripped_activities])
|
||||
|
|
|
@ -16,6 +16,41 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
require Pleroma.Constants
|
||||
|
||||
describe "strip_report_status_data/1" do
|
||||
test "does not break on issues with the reported activites" do
|
||||
reporter = insert(:user)
|
||||
target_account = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(target_account, %{status: "foobar"})
|
||||
context = Utils.generate_context_id()
|
||||
content = "foobar"
|
||||
post_id = activity.data["id"]
|
||||
|
||||
res =
|
||||
Utils.make_flag_data(
|
||||
%{
|
||||
actor: reporter,
|
||||
context: context,
|
||||
account: target_account,
|
||||
statuses: [%{"id" => post_id}],
|
||||
content: content
|
||||
},
|
||||
%{}
|
||||
)
|
||||
|
||||
res =
|
||||
res
|
||||
|> Map.put("object", res["object"] ++ [nil, 1, 5, "123"])
|
||||
|
||||
{:ok, activity} = Pleroma.Web.ActivityPub.ActivityPub.insert(res)
|
||||
|
||||
[user_id, object | _] = activity.data["object"]
|
||||
|
||||
{:ok, stripped} = Utils.strip_report_status_data(activity)
|
||||
|
||||
assert stripped.data["object"] == [user_id, object["id"]]
|
||||
end
|
||||
end
|
||||
|
||||
describe "fetch the latest Follow" do
|
||||
test "fetches the latest Follow activity" do
|
||||
%Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity)
|
||||
|
|
Loading…
Reference in a new issue