1
0
mirror of https://git.pleroma.social/sjw/pleroma.git synced 2024-12-26 22:55:12 +01:00

Notification: Don't break on figuring out the type of old EmojiReactions

This commit is contained in:
lain 2020-06-04 20:40:46 +02:00
parent d44da91bbf
commit aa2ac76510
2 changed files with 20 additions and 1 deletions

View File

@ -398,6 +398,10 @@ defmodule Pleroma.Notification do
"EmojiReact" -> "EmojiReact" ->
"pleroma:emoji_reaction" "pleroma:emoji_reaction"
# Compatibility with old reactions
"EmojiReaction" ->
"pleroma:emoji_reaction"
"Create" -> "Create" ->
activity activity
|> type_from_activity_object() |> type_from_activity_object()

View File

@ -8,8 +8,10 @@ defmodule Pleroma.NotificationTest do
import Pleroma.Factory import Pleroma.Factory
import Mock import Mock
alias Pleroma.Activity
alias Pleroma.FollowingRelationship alias Pleroma.FollowingRelationship
alias Pleroma.Notification alias Pleroma.Notification
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers alias Pleroma.Tests.ObanHelpers
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
@ -29,8 +31,18 @@ defmodule Pleroma.NotificationTest do
{:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo") {:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo")
{:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "") {:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "")
{:ok, like} = CommonAPI.favorite(other_user, post.id) {: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() Notification.fill_in_notification_types()
@ -43,6 +55,9 @@ defmodule Pleroma.NotificationTest do
assert %{type: "pleroma:emoji_reaction"} = assert %{type: "pleroma:emoji_reaction"} =
Repo.get_by(Notification, user_id: user.id, activity_id: react.id) 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"} = assert %{type: "pleroma:chat_mention"} =
Repo.get_by(Notification, user_id: other_user.id, activity_id: chat.id) Repo.get_by(Notification, user_id: other_user.id, activity_id: chat.id)
end end