Linting.
[akkoma] / lib / pleroma / web / activity_pub / transmogrifier.ex
index 05a03a37711d809c2063eaecd4e4dff9a0dcee74..2c1f01c18b3e3f7cff36a97cf174d26ee57e1821 100644 (file)
@@ -560,6 +560,34 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     end
   end
 
+  @misskey_reactions %{
+    "like" => "👍",
+    "love" => "❤️",
+    "laugh" => "😆",
+    "hmm" => "🤔",
+    "surprise" => "😮",
+    "congrats" => "🎉",
+    "angry" => "💢",
+    "confused" => "😥",
+    "rip" => "😇",
+    "pudding" => "🍮",
+    "star" => "⭐"
+  }
+
+  @doc "Rewrite misskey likes into EmojiReactions"
+  def handle_incoming(
+        %{
+          "type" => "Like",
+          "_misskey_reaction" => reaction
+        } = data,
+        options
+      ) do
+    data
+    |> Map.put("type", "EmojiReaction")
+    |> Map.put("content", @misskey_reactions[reaction] || reaction)
+    |> handle_incoming(options)
+  end
+
   def handle_incoming(
         %{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data,
         _options