activitypub: transmogrifier: fix up to/cc addressing brain damage caused by mastodon-style explicit DMs

This commit is contained in:
William Pitcock 2018-11-17 16:05:41 +00:00
parent 8d06be35e0
commit 681f40ee5c

View file

@ -93,12 +93,42 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end end
end end
def fix_addressing(map) do def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mentions) do
map explicit_to =
|> fix_addressing_list("to") to
|> fix_addressing_list("cc") |> Enum.filter(fn x -> x in explicit_mentions end)
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc") explicit_cc =
to
|> Enum.filter(fn x -> x not in explicit_mentions end)
final_cc =
(cc ++ explicit_cc)
|> Enum.uniq()
object
|> Map.put("to", explicit_to)
|> Map.put("cc", final_cc)
end
def fix_explicit_addressing(object, _explicit_mentions), do: object
def fix_addressing(object) do
object =
object
|> fix_addressing_list("to")
|> fix_addressing_list("cc")
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc")
explicit_mentions =
object
|> Utils.determine_explicit_mentions()
explicit_mentions = explicit_mentions ++ ["https://www.w3.org/ns/activitystreams#Public"]
object
|> fix_explicit_addressing(explicit_mentions)
end end
def fix_actor(%{"attributedTo" => actor} = object) do def fix_actor(%{"attributedTo" => actor} = object) do