Transmogrifier: Extend misskey like compatibility.
authorlain <lain@soykaf.club>
Sat, 5 Oct 2019 08:45:42 +0000 (10:45 +0200)
committerlain <lain@soykaf.club>
Sat, 5 Oct 2019 08:45:42 +0000 (10:45 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/transmogrifier_test.exs

index 54c18bc0e920e0647563d7e051c6137065afa1c7..2c6edb0b1d3388b12b45430516c104b9ea8bf71e 100644 (file)
@@ -570,7 +570,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     "angry" => "💢",
     "confused" => "😥",
     "rip" => "😇",
-    "pudding" => "🍮"
+    "pudding" => "🍮",
+    "star" => "⭐"
   }
 
   @doc "Rewrite misskey likes into EmojiReactions"
@@ -583,7 +584,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
       ) do
     data
     |> Map.put("type", "EmojiReaction")
-    |> Map.put("content", @misskey_reactions[reaction])
+    |> Map.put("content", @misskey_reactions[reaction] || reaction)
     |> handle_incoming(options)
   end
 
index 530a762fa9acbed34ea147d54ae619f8204882ab..9156b23e30029b8898de275dac4426071d3254de 100644 (file)
@@ -359,6 +359,25 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert data["content"] == "🍮"
     end
 
+    test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReactions" do
+      user = insert(:user)
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+
+      data =
+        File.read!("test/fixtures/misskey-like.json")
+        |> Poison.decode!()
+        |> Map.put("object", activity.data["object"])
+        |> Map.put("_misskey_reaction", "⭐")
+
+      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+
+      assert data["actor"] == data["actor"]
+      assert data["type"] == "EmojiReaction"
+      assert data["id"] == data["id"]
+      assert data["object"] == activity.data["object"]
+      assert data["content"] == "⭐"
+    end
+
     test "it works for incoming emoji reactions" do
       user = insert(:user)
       {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})