alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
- def cast_recipients(message, field, field_fallback \\ []) do
+ def cast_and_filter_recipients(message, field, follower_collection, field_fallback \\ []) do
{:ok, data} = ObjectValidators.Recipients.cast(message[field] || field_fallback)
+ data =
+ Enum.reject(data, fn x ->
+ String.ends_with?(x, "/followers") and x != follower_collection
+ end)
+
Map.put(message, field, data)
end
data
|> Map.put("context", context)
|> Map.put("context_id", context_id)
- |> cast_recipients("to")
- |> cast_recipients("cc")
- |> cast_recipients("bto")
- |> cast_recipients("bcc")
- |> Transmogrifier.fix_explicit_addressing(follower_collection)
+ |> cast_and_filter_recipients("to", follower_collection)
+ |> cast_and_filter_recipients("cc", follower_collection)
+ |> cast_and_filter_recipients("bto", follower_collection)
+ |> cast_and_filter_recipients("bcc", follower_collection)
|> Transmogrifier.fix_implicit_addressing(follower_collection)
end
%User{follower_address: follower_collection} = User.get_cached_by_ap_id(activity["actor"])
activity
- |> cast_recipients("to")
- |> cast_recipients("cc")
- |> cast_recipients("bto")
- |> cast_recipients("bcc")
- |> Transmogrifier.fix_explicit_addressing(follower_collection)
+ |> cast_and_filter_recipients("to", follower_collection)
+ |> cast_and_filter_recipients("cc", follower_collection)
+ |> cast_and_filter_recipients("bto", follower_collection)
+ |> cast_and_filter_recipients("bcc", follower_collection)
|> Transmogrifier.fix_implicit_addressing(follower_collection)
end