From 8a79f20c21fcb3baab0a817fc000c78d348349fb Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 6 Feb 2020 18:09:57 +0100 Subject: [PATCH] EmojiReactions: Rename to EmojiReacts --- docs/API/differences_in_mastoapi_responses.md | 2 +- lib/pleroma/activity.ex | 2 +- lib/pleroma/notification.ex | 4 ++-- lib/pleroma/web/activity_pub/transmogrifier.ex | 8 ++++---- lib/pleroma/web/activity_pub/utils.ex | 4 ++-- priv/static/schemas/litepub-0.1.jsonld | 2 +- test/fixtures/emoji-reaction-no-emoji.json | 2 +- test/fixtures/emoji-reaction-too-long.json | 2 +- test/fixtures/emoji-reaction.json | 2 +- test/web/activity_pub/activity_pub_test.exs | 2 +- test/web/activity_pub/transmogrifier_test.exs | 10 +++++----- test/web/mastodon_api/views/notification_view_test.exs | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md index 82d967e4d..89245261c 100644 --- a/docs/API/differences_in_mastoapi_responses.md +++ b/docs/API/differences_in_mastoapi_responses.md @@ -101,7 +101,7 @@ The `type` value is `move`. Has an additional field: - `target`: new account -### EmojiReaction Notification +### EmojiReact Notification The `type` value is `pleroma:emoji_reaction`. Has these fields: diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 0f8fce774..72e2256ea 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -31,7 +31,7 @@ defmodule Pleroma.Activity do "Announce" => "reblog", "Like" => "favourite", "Move" => "move", - "EmojiReaction" => "pleroma:emoji_reaction" + "EmojiReact" => "pleroma:emoji_reaction" } @mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types, diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index d04a65a1e..66e91fcef 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -294,7 +294,7 @@ def create_notifications(%Activity{data: %{"to" => _, "type" => "Create"}} = act end def create_notifications(%Activity{data: %{"type" => type}} = activity) - when type in ["Like", "Announce", "Follow", "Move", "EmojiReaction"] do + when type in ["Like", "Announce", "Follow", "Move", "EmojiReact"] do notifications = activity |> get_notified_from_activity() @@ -322,7 +322,7 @@ def create_notification(%Activity{} = activity, %User{} = user) do def get_notified_from_activity(activity, local_only \\ true) def get_notified_from_activity(%Activity{data: %{"type" => type}} = activity, local_only) - when type in ["Create", "Like", "Announce", "Follow", "Move", "EmojiReaction"] do + when type in ["Create", "Like", "Announce", "Follow", "Move", "EmojiReact"] do [] |> Utils.maybe_notify_to_recipients(activity) |> Utils.maybe_notify_mentioned_recipients(activity) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 2b8bfc3bd..a72d8430f 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -580,7 +580,7 @@ def handle_incoming( "star" => "⭐" } - @doc "Rewrite misskey likes into EmojiReactions" + @doc "Rewrite misskey likes into EmojiReacts" def handle_incoming( %{ "type" => "Like", @@ -589,7 +589,7 @@ def handle_incoming( options ) do data - |> Map.put("type", "EmojiReaction") + |> Map.put("type", "EmojiReact") |> Map.put("content", @misskey_reactions[reaction] || reaction) |> handle_incoming(options) end @@ -610,7 +610,7 @@ def handle_incoming( def handle_incoming( %{ - "type" => "EmojiReaction", + "type" => "EmojiReact", "object" => object_id, "actor" => _actor, "id" => id, @@ -751,7 +751,7 @@ def handle_incoming( def handle_incoming( %{ "type" => "Undo", - "object" => %{"type" => "EmojiReaction", "id" => reaction_activity_id}, + "object" => %{"type" => "EmojiReact", "id" => reaction_activity_id}, "actor" => _actor, "id" => id } = data, diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 4f7fdaf38..4bcacc6d1 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -308,7 +308,7 @@ def make_like_data( def make_emoji_reaction_data(user, object, emoji, activity_id) do make_like_data(user, object, activity_id) - |> Map.put("type", "EmojiReaction") + |> Map.put("type", "EmojiReact") |> Map.put("content", emoji) end @@ -493,7 +493,7 @@ def fetch_latest_follow(%User{ap_id: follower_id}, %User{ap_id: followed_id}) do def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do %{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id) - "EmojiReaction" + "EmojiReact" |> Activity.Queries.by_type() |> where(actor: ^ap_id) |> where([activity], fragment("?->>'content' = ?", activity.data, ^emoji)) diff --git a/priv/static/schemas/litepub-0.1.jsonld b/priv/static/schemas/litepub-0.1.jsonld index e7ebf72be..278ad2f96 100644 --- a/priv/static/schemas/litepub-0.1.jsonld +++ b/priv/static/schemas/litepub-0.1.jsonld @@ -29,7 +29,7 @@ "@id": "litepub:oauthRegistrationEndpoint", "@type": "@id" }, - "EmojiReaction": "litepub:EmojiReaction", + "EmojiReact": "litepub:EmojiReact", "alsoKnownAs": { "@id": "as:alsoKnownAs", "@type": "@id" diff --git a/test/fixtures/emoji-reaction-no-emoji.json b/test/fixtures/emoji-reaction-no-emoji.json index fff77b29b..ef3bbe55c 100644 --- a/test/fixtures/emoji-reaction-no-emoji.json +++ b/test/fixtures/emoji-reaction-no-emoji.json @@ -1,5 +1,5 @@ { - "type": "EmojiReaction", + "type": "EmojiReact", "signature": { "type": "RsaSignature2017", "signatureValue": "fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==", diff --git a/test/fixtures/emoji-reaction-too-long.json b/test/fixtures/emoji-reaction-too-long.json index 31830d90c..e917c9a68 100644 --- a/test/fixtures/emoji-reaction-too-long.json +++ b/test/fixtures/emoji-reaction-too-long.json @@ -1,5 +1,5 @@ { - "type": "EmojiReaction", + "type": "EmojiReact", "signature": { "type": "RsaSignature2017", "signatureValue": "fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==", diff --git a/test/fixtures/emoji-reaction.json b/test/fixtures/emoji-reaction.json index 3812e43ad..fe1fecddb 100644 --- a/test/fixtures/emoji-reaction.json +++ b/test/fixtures/emoji-reaction.json @@ -1,5 +1,5 @@ { - "type": "EmojiReaction", + "type": "EmojiReact", "signature": { "type": "RsaSignature2017", "signatureValue": "fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==", diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index ff4604a52..ea6e79b44 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -877,7 +877,7 @@ test "adds an emoji reaction activity to the db" do assert reaction_activity assert reaction_activity.data["actor"] == reactor.ap_id - assert reaction_activity.data["type"] == "EmojiReaction" + assert reaction_activity.data["type"] == "EmojiReact" assert reaction_activity.data["content"] == "🔥" assert reaction_activity.data["object"] == object.data["id"] assert reaction_activity.data["to"] == [User.ap_followers(reactor), activity.data["actor"]] diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 0829a6ec2..1b12ee3a9 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -340,7 +340,7 @@ test "it works for incoming likes" do assert data["object"] == activity.data["object"] end - test "it works for incoming misskey likes, turning them into EmojiReactions" do + test "it works for incoming misskey likes, turning them into EmojiReacts" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) @@ -352,13 +352,13 @@ test "it works for incoming misskey likes, turning them into EmojiReactions" do {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) assert data["actor"] == data["actor"] - assert data["type"] == "EmojiReaction" + assert data["type"] == "EmojiReact" assert data["id"] == data["id"] assert data["object"] == activity.data["object"] assert data["content"] == "🍮" end - test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReactions" do + test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReacts" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) @@ -371,7 +371,7 @@ test "it works for incoming misskey likes that contain unicode emojis, turning t {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) assert data["actor"] == data["actor"] - assert data["type"] == "EmojiReaction" + assert data["type"] == "EmojiReact" assert data["id"] == data["id"] assert data["object"] == activity.data["object"] assert data["content"] == "⭐" @@ -389,7 +389,7 @@ test "it works for incoming emoji reactions" do {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) assert data["actor"] == "http://mastodon.example.org/users/admin" - assert data["type"] == "EmojiReaction" + assert data["type"] == "EmojiReact" assert data["id"] == "http://mastodon.example.org/users/admin#reactions/2" assert data["object"] == activity.data["object"] assert data["content"] == "👌" diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs index 1fe83cb2c..2ac75c2ff 100644 --- a/test/web/mastodon_api/views/notification_view_test.exs +++ b/test/web/mastodon_api/views/notification_view_test.exs @@ -135,7 +135,7 @@ test "Move notification" do NotificationView.render("index.json", %{notifications: [notification], for: follower}) end - test "EmojiReaction notification" do + test "EmojiReact notification" do user = insert(:user) other_user = insert(:user)