Transmogrifier: Refactor and unify incoming tag handling

This commit is contained in:
lain 2020-10-19 15:46:24 +02:00
parent 39fd4d7639
commit e97b254c6b
1 changed files with 4 additions and 6 deletions

View File

@ -323,14 +323,12 @@ def fix_tag(%{"tag" => tag} = object) when is_list(tag) do
Map.put(object, "tag", tag ++ tags) Map.put(object, "tag", tag ++ tags)
end end
def fix_tag(%{"tag" => %{"type" => "Hashtag", "name" => hashtag} = tag} = object) do def fix_tag(%{"tag" => %{} = tag} = object) do
combined = [tag, String.slice(hashtag, 1..-1)] object
|> Map.put("tag", [tag])
Map.put(object, "tag", combined) |> fix_tag
end end
def fix_tag(%{"tag" => %{} = tag} = object), do: Map.put(object, "tag", [tag])
def fix_tag(object), do: object def fix_tag(object), do: object
# content map usually only has one language so this will do for now. # content map usually only has one language so this will do for now.