activitypub: transmogrifier: do not attempt to expand pre-existing AS2 tag objects
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 14 Feb 2019 00:27:35 +0000 (00:27 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 14 Feb 2019 00:35:53 +0000 (00:35 +0000)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 98a2af8198dc1b25a11b315ec83d2819415c80a4..5da65fa39b7d537fe6a834704ef538de37939914 100644 (file)
@@ -765,12 +765,18 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   def add_hashtags(object) do
     tags =
       (object["tag"] || [])
-      |> Enum.map(fn tag ->
-        %{
-          "href" => Pleroma.Web.Endpoint.url() <> "/tags/#{tag}",
-          "name" => "##{tag}",
-          "type" => "Hashtag"
-        }
+      |> Enum.map(fn
+        # Expand internal representation tags into AS2 tags.
+        tag when is_binary(tag) ->
+          %{
+            "href" => Pleroma.Web.Endpoint.url() <> "/tags/#{tag}",
+            "name" => "##{tag}",
+            "type" => "Hashtag"
+          }
+
+        # Do not process tags which are already AS2 tag objects.
+        tag when is_map(tag) ->
+          tag
       end)
 
     object