Transmogrifier: Handle misskey likes with reactions like EmojiReactions.
This commit is contained in:
parent
8e83c8423f
commit
43a211bcb1
|
@ -560,6 +560,33 @@ def handle_incoming(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@misskey_reactions %{
|
||||||
|
"like" => "๐",
|
||||||
|
"love" => "โค๏ธ",
|
||||||
|
"laugh" => "๐",
|
||||||
|
"hmm" => "๐ค",
|
||||||
|
"surprise" => "๐ฎ",
|
||||||
|
"congrats" => "๐",
|
||||||
|
"angry" => "๐ข",
|
||||||
|
"confused" => "๐ฅ",
|
||||||
|
"rip" => "๐",
|
||||||
|
"pudding" => "๐ฎ"
|
||||||
|
}
|
||||||
|
|
||||||
|
@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])
|
||||||
|
|> handle_incoming(options)
|
||||||
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data,
|
%{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data,
|
||||||
_options
|
_options
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"@context" : [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://w3id.org/security/v1",
|
||||||
|
{"Hashtag" : "as:Hashtag"}
|
||||||
|
],
|
||||||
|
"_misskey_reaction" : "pudding",
|
||||||
|
"actor": "http://mastodon.example.org/users/admin",
|
||||||
|
"cc" : ["https://testing.pleroma.lol/users/lain"],
|
||||||
|
"id" : "https://misskey.xyz/75149198-2f45-46e4-930a-8b0538297075",
|
||||||
|
"nickname" : "lain",
|
||||||
|
"object" : "https://testing.pleroma.lol/objects/c331bbf7-2eb9-4801-a709-2a6103492a5a",
|
||||||
|
"type" : "Like"
|
||||||
|
}
|
|
@ -341,6 +341,24 @@ test "it works for incoming likes" do
|
||||||
assert data["object"] == activity.data["object"]
|
assert data["object"] == activity.data["object"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it works for incoming misskey likes, 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"])
|
||||||
|
|
||||||
|
{: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
|
test "it works for incoming emoji reactions" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||||
|
|
Loadingโฆ
Reference in New Issue