瀏覽代碼

Notifications: Never return `nil` in the notification list.

merge-requests/2720/head
lain 4 年之前
父節點
當前提交
90083a754d
共有 2 個檔案被更改,包括 13 行新增0 行删除
  1. +1
    -0
      lib/pleroma/notification.ex
  2. +12
    -0
      test/notification_test.exs

+ 1
- 0
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.filter(& &1)

{:ok, notifications}
end


+ 12
- 0
test/notification_test.exs 查看文件

@@ -21,7 +21,19 @@ defmodule Pleroma.NotificationTest do
alias Pleroma.Web.Push
alias Pleroma.Web.Streamer

# TODO: Test there's no nil notifications

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)


Loading…
取消
儲存