transmogrifier: don't apply heuristics against messages which have `directMessage` set true

This commit is contained in:
William Pitcock 2018-12-23 15:35:49 +00:00
parent ddae43eb43
commit 420651157b
1 changed files with 13 additions and 7 deletions

View File

@ -113,14 +113,10 @@ def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mention
def fix_explicit_addressing(object, _explicit_mentions), do: object def fix_explicit_addressing(object, _explicit_mentions), do: object
def fix_addressing(object) do # if directMessage flag is set to true, leave the addressing alone
object = def fix_explicit_addressing(%{"directMessage" => true} = object), do: object
object
|> fix_addressing_list("to")
|> fix_addressing_list("cc")
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc")
def fix_explicit_addressing(object) do
explicit_mentions = explicit_mentions =
object object
|> Utils.determine_explicit_mentions() |> Utils.determine_explicit_mentions()
@ -131,6 +127,14 @@ def fix_addressing(object) do
|> fix_explicit_addressing(explicit_mentions) |> fix_explicit_addressing(explicit_mentions)
end end
def fix_addressing(object) do
object
|> fix_addressing_list("to")
|> fix_addressing_list("cc")
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc")
end
def fix_actor(%{"attributedTo" => actor} = object) do def fix_actor(%{"attributedTo" => actor} = object) do
object object
|> Map.put("actor", get_actor(%{"actor" => actor})) |> Map.put("actor", get_actor(%{"actor" => actor}))
@ -363,6 +367,7 @@ def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = obj
data = data =
Map.put(data, "actor", actor) Map.put(data, "actor", actor)
|> fix_addressing |> fix_addressing
|> fix_explicit_addressing
with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]), with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]),
%User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do
@ -378,6 +383,7 @@ def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = obj
additional: additional:
Map.take(data, [ Map.take(data, [
"cc", "cc",
"directMessage",
"id" "id"
]) ])
} }