diff options
author | rinpatch <rinpatch@sdf.org> | 2020-06-29 18:06:25 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-06-29 18:06:25 +0000 |
commit | 7bb36189392280fef3c3a20279671885273383d2 (patch) | |
tree | a696d00fb90e50498646a306a4d60d021de3982b | |
parent | b2b332984c42d4be8f5d4890e53faa09c44a4fb2 (diff) | |
parent | 09c5991f82e91878a940f5957ac993e1fca72545 (diff) | |
download | pleroma-7bb36189392280fef3c3a20279671885273383d2.tar.gz |
Merge branch 'fix-notification-filtering' into 'develop'
Notifications: Never return `nil` in the notification list.
See merge request pleroma/pleroma!2705
-rw-r--r-- | lib/pleroma/notification.ex | 1 | ||||
-rw-r--r-- | test/notification_test.exs | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 9ee9606be..2ef1a80c5 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -367,6 +367,7 @@ defmodule Pleroma.Notification do do_send = do_send && user in enabled_receivers create_notification(activity, user, do_send) end) + |> Enum.reject(&is_nil/1) {:ok, notifications} end diff --git a/test/notification_test.exs b/test/notification_test.exs index 526f43fab..6add3f7eb 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -22,6 +22,16 @@ defmodule Pleroma.NotificationTest do alias Pleroma.Web.Streamer describe "create_notifications" do + test "never returns nil" do + user = insert(:user) + other_user = insert(:user, %{invisible: true}) + + {:ok, activity} = CommonAPI.post(user, %{status: "yeah"}) + {:ok, activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕") + + refute {:ok, [nil]} == Notification.create_notifications(activity) + end + test "creates a notification for an emoji reaction" do user = insert(:user) other_user = insert(:user) |