[#3213] Made Object.object_data_hashtags/1 handle both AS2 and plain text hashtags.

This commit is contained in:
Ivan Tashkinov 2020-12-30 15:22:49 +03:00
parent e0b5edb6d5
commit 8d1a0c1afd
1 changed files with 3 additions and 1 deletions

View File

@ -405,16 +405,18 @@ defp embedded_hashtags(%Object{data: data}) do
defp embedded_hashtags(_), do: []
defp object_data_hashtags(%{"tag" => tags}) when is_list(tags) do
# Note: Old format with copy of hashtags as strings is ignored, using AS2
tags
|> Enum.filter(fn
%{"type" => "Hashtag"} = data -> Map.has_key?(data, "name")
plain_text when is_bitstring(plain_text) -> true
_ -> false
end)
|> Enum.map(fn
%{"name" => "#" <> hashtag} -> String.downcase(hashtag)
%{"name" => hashtag} -> String.downcase(hashtag)
hashtag when is_bitstring(hashtag) -> String.downcase(hashtag)
end)
|> Enum.uniq()
end
defp object_data_hashtags(_), do: []