logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 1121f099e98c62bd6ee7a5a7e4124ae36a45fba1
parent 58ec4fd1eec3d7ac59025ab7dfca2ae9475d1b10
Author: tusooa <tusooa@kazv.moe>
Date:   Thu, 15 Dec 2022 20:20:11 -0500

Ensure actor in Activity is also anonymized

Diffstat:

Mlib/pleroma/web/activity_pub/utils.ex3++-
Mtest/pleroma/web/activity_pub/activity_pub_test.exs4+++-
Mtest/pleroma/web/activity_pub/utils_test.exs14++++++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex @@ -887,7 +887,8 @@ defmodule Pleroma.Web.ActivityPub.Utils do end 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 def maybe_anonymize_reporter(activity) do diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -1738,7 +1738,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do |> put_in(["object"], [target_account.ap_id, object_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 diff --git a/test/pleroma/web/activity_pub/utils_test.exs b/test/pleroma/web/activity_pub/utils_test.exs @@ -693,6 +693,20 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do assert %{"actor" => placeholder.ap_id} == Utils.maybe_anonymize_reporter(report) 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", %{ placeholder: placeholder, reporter: reporter,