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)
end
def fix_tag(%{"tag" => %{"type" => "Hashtag", "name" => hashtag} = tag} = object) do
combined = [tag, String.slice(hashtag, 1..-1)]
Map.put(object, "tag", combined)
def fix_tag(%{"tag" => %{} = tag} = object) do
object
|> Map.put("tag", [tag])
|> fix_tag
end
def fix_tag(%{"tag" => %{} = tag} = object), do: Map.put(object, "tag", [tag])
def fix_tag(object), do: object
# content map usually only has one language so this will do for now.