Skip to content
Snippets Groups Projects
Commit 681f40ee authored by kaniini's avatar kaniini
Browse files

activitypub: transmogrifier: fix up to/cc addressing brain damage caused by...

activitypub: transmogrifier: fix up to/cc addressing brain damage caused by mastodon-style explicit DMs
parent 8d06be35
No related branches found
No related tags found
No related merge requests found
......@@ -93,12 +93,42 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
end
def fix_addressing(map) do
map
|> fix_addressing_list("to")
|> fix_addressing_list("cc")
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc")
def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mentions) do
explicit_to =
to
|> Enum.filter(fn x -> x in explicit_mentions end)
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
def fix_actor(%{"attributedTo" => actor} = object) do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment