[#3213] Fixed Object.object_data_hashtags/1 to process only AS2 elements of data.tag (basing on #2984).

This commit is contained in:
Ivan Tashkinov 2020-12-30 14:42:35 +03:00
parent a25c1e8ec0
commit e0b5edb6d5

View file

@ -405,8 +405,16 @@ defp embedded_hashtags(%Object{data: data}) do
defp embedded_hashtags(_), do: []
defp object_data_hashtags(%{"tag" => tags}) when is_list(tags) do
# Note: AS2 map-type elements are ignored
Enum.filter(tags, &is_bitstring(&1))
# 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")
_ -> false
end)
|> Enum.map(fn
%{"name" => "#" <> hashtag} -> String.downcase(hashtag)
%{"name" => hashtag} -> String.downcase(hashtag)
end)
end
defp object_data_hashtags(_), do: []