Transmogrifier: Refactor and unify incoming tag handling
authorlain <lain@soykaf.club>
Mon, 19 Oct 2020 13:46:24 +0000 (15:46 +0200)
committerlain <lain@soykaf.club>
Mon, 19 Oct 2020 13:46:24 +0000 (15:46 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 2f51f9e396ef1dc7ea52f8c76cf83be6197160ab..39c8f7e396ac064afc69d185613aaa28f59b53e5 100644 (file)
@@ -323,14 +323,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier 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.