Anonymize reporter before federating
This commit is contained in:
parent
27d271b4ef
commit
58ec4fd1ee
3 changed files with 52 additions and 2 deletions
|
|
@ -415,6 +415,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
with flag_data <- make_flag_data(params, additional),
|
||||
{:ok, activity} <- insert(flag_data, local),
|
||||
{:ok, stripped_activity} <- strip_report_status_data(activity),
|
||||
stripped_activity <- maybe_anonymize_reporter(stripped_activity),
|
||||
_ <- notify_and_stream(activity),
|
||||
:ok <-
|
||||
maybe_federate(stripped_activity) do
|
||||
|
|
|
|||
|
|
@ -875,15 +875,29 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
{:ok, %{activity | data: new_data}}
|
||||
end
|
||||
|
||||
def maybe_anonymize_reporter(activity) do
|
||||
def get_anonymized_reporter do
|
||||
with true <- Pleroma.Config.get([:activitypub, :anonymize_reporter]),
|
||||
nickname when is_binary(nickname) <-
|
||||
Pleroma.Config.get([:activitypub, :anonymize_reporter_local_nickname]),
|
||||
%User{ap_id: ap_id, local: true} <- User.get_cached_by_nickname(nickname) do
|
||||
ap_id
|
||||
else
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_anonymize_reporter(%Activity{data: data} = activity) do
|
||||
%Activity{activity | data: maybe_anonymize_reporter(data)}
|
||||
end
|
||||
|
||||
def maybe_anonymize_reporter(activity) do
|
||||
ap_id = get_anonymized_reporter()
|
||||
|
||||
if is_binary(ap_id) do
|
||||
activity
|
||||
|> Map.put("actor", ap_id)
|
||||
else
|
||||
_ -> activity
|
||||
activity
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue