summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-04 20:40:46 +0200
committerlain <lain@soykaf.club>2020-06-04 20:40:46 +0200
commitaa2ac76510d95f2412e23f3739e8e1ae4402643f (patch)
tree4f80d938342e7db968509a182a2673b7501caa94
parentd44da91bbf50ae91e8246ebe3669cfaf1fabda1b (diff)
Notification: Don't break on figuring out the type of old EmojiReactions
-rw-r--r--lib/pleroma/notification.ex4
-rw-r--r--test/notification_test.exs17
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 455d214bf..e5b880b10 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -398,6 +398,10 @@ defmodule Pleroma.Notification do
"EmojiReact" ->
"pleroma:emoji_reaction"
+ # Compatibility with old reactions
+ "EmojiReaction" ->
+ "pleroma:emoji_reaction"
+
"Create" ->
activity
|> type_from_activity_object()
diff --git a/test/notification_test.exs b/test/notification_test.exs
index 6bc2b6904..f2115a29e 100644
--- a/test/notification_test.exs
+++ b/test/notification_test.exs
@@ -8,8 +8,10 @@ defmodule Pleroma.NotificationTest do
import Pleroma.Factory
import Mock
+ alias Pleroma.Activity
alias Pleroma.FollowingRelationship
alias Pleroma.Notification
+ alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -29,8 +31,18 @@ defmodule Pleroma.NotificationTest do
{:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo")
{:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
{:ok, like} = CommonAPI.favorite(other_user, post.id)
+ {:ok, react_2} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
- assert {4, nil} = Repo.update_all(Notification, set: [type: nil])
+ data =
+ react_2.data
+ |> Map.put("type", "EmojiReaction")
+
+ {:ok, react_2} =
+ react_2
+ |> Activity.change(%{data: data})
+ |> Repo.update()
+
+ assert {5, nil} = Repo.update_all(Notification, set: [type: nil])
Notification.fill_in_notification_types()
@@ -43,6 +55,9 @@ defmodule Pleroma.NotificationTest do
assert %{type: "pleroma:emoji_reaction"} =
Repo.get_by(Notification, user_id: user.id, activity_id: react.id)
+ assert %{type: "pleroma:emoji_reaction"} =
+ Repo.get_by(Notification, user_id: user.id, activity_id: react_2.id)
+
assert %{type: "pleroma:chat_mention"} =
Repo.get_by(Notification, user_id: other_user.id, activity_id: chat.id)
end