Ensure actor in Activity is also anonymized
This commit is contained in:
parent
58ec4fd1ee
commit
1121f099e9
3 changed files with 19 additions and 2 deletions
|
|
@ -887,7 +887,8 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_anonymize_reporter(%Activity{data: data} = activity) do
|
def maybe_anonymize_reporter(%Activity{data: data} = activity) do
|
||||||
%Activity{activity | data: maybe_anonymize_reporter(data)}
|
new_data = maybe_anonymize_reporter(data)
|
||||||
|
%Activity{activity | actor: new_data["actor"], data: new_data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_anonymize_reporter(activity) do
|
def maybe_anonymize_reporter(activity) do
|
||||||
|
|
|
||||||
|
|
@ -1738,7 +1738,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
|> put_in(["object"], [target_account.ap_id, object_ap_id])
|
|> put_in(["object"], [target_account.ap_id, object_ap_id])
|
||||||
|> Map.put("actor", placeholder.ap_id)
|
|> Map.put("actor", placeholder.ap_id)
|
||||||
|
|
||||||
assert_called(Utils.maybe_federate(%{activity | data: new_data}))
|
assert_called(
|
||||||
|
Utils.maybe_federate(%{activity | actor: placeholder.ap_id, data: new_data})
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -693,6 +693,20 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
||||||
assert %{"actor" => placeholder.ap_id} == Utils.maybe_anonymize_reporter(report)
|
assert %{"actor" => placeholder.ap_id} == Utils.maybe_anonymize_reporter(report)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "anonymize Activity", %{
|
||||||
|
placeholder: placeholder,
|
||||||
|
reporter: reporter,
|
||||||
|
report: report
|
||||||
|
} do
|
||||||
|
clear_config([:activitypub, :anonymize_reporter], true)
|
||||||
|
clear_config([:activitypub, :anonymize_reporter_local_nickname], placeholder.nickname)
|
||||||
|
report_activity = %Activity{actor: reporter, data: report}
|
||||||
|
anon_id = placeholder.ap_id
|
||||||
|
|
||||||
|
assert %Activity{actor: ^anon_id, data: %{"actor" => ^anon_id}} =
|
||||||
|
Utils.maybe_anonymize_reporter(report_activity)
|
||||||
|
end
|
||||||
|
|
||||||
test "do not anonymize when disabled", %{
|
test "do not anonymize when disabled", %{
|
||||||
placeholder: placeholder,
|
placeholder: placeholder,
|
||||||
reporter: reporter,
|
reporter: reporter,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue