[#3213] Made Object.object_data_hashtags/1 handle both AS2 and plain text hashtags.
authorIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 30 Dec 2020 12:22:49 +0000 (15:22 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 30 Dec 2020 12:22:49 +0000 (15:22 +0300)
lib/pleroma/object.ex

index dad572f2bea8caa077abd68caf6f6ddd659e8d8c..7e79e15ee03338992037944b8664445bc4d37946 100644 (file)
@@ -405,16 +405,18 @@ defmodule Pleroma.Object 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: []