summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tumin <iamtakingiteasy@eientei.org>2023-02-07 15:30:07 +0300
committertusooa <tusooa@kazv.moe>2023-02-20 12:27:50 -0500
commitc3a07035646b255bc5f33743d13defbaa69d9991 (patch)
tree6074da3cce476dca37d52a68e9aa786ed5e4cfa3
parent8e8a0f005cddf6b2cd1535ad634ac8cb8d0ca42e (diff)
Require related object for notifications to filter on content
-rw-r--r--lib/pleroma/notification.ex1
-rw-r--r--test/pleroma/notification_test.exs27
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 60c1a80ba..48d467c59 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -178,6 +178,7 @@ defmodule Pleroma.Notification do
from([_n, a, o] in query,
where:
fragment("not(?->>'content' ~* ?)", o.data, ^regex) or
+ fragment("?->>'content' is null", o.data) or
fragment("?->>'actor' = ?", o.data, ^user.ap_id)
)
end
diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs
index d169ab709..e55aa3a08 100644
--- a/test/pleroma/notification_test.exs
+++ b/test/pleroma/notification_test.exs
@@ -1251,5 +1251,32 @@ defmodule Pleroma.NotificationTest do
assert length(Notification.for_user(user)) == 1
end
+
+ test "it returns notifications when related object is without content and filters are defined",
+ %{user: user} do
+ followed_user = insert(:user, is_locked: true)
+
+ insert(:filter, user: followed_user, phrase: "test", hide: true)
+
+ {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
+ refute FollowingRelationship.following?(user, followed_user)
+ assert [notification] = Notification.for_user(followed_user)
+
+ assert %{type: "follow_request"} =
+ NotificationView.render("show.json", %{
+ notification: notification,
+ for: followed_user
+ })
+
+ assert {:ok, _} = CommonAPI.accept_follow_request(user, followed_user)
+
+ assert [notification] = Notification.for_user(followed_user)
+
+ assert %{type: "follow"} =
+ NotificationView.render("show.json", %{
+ notification: notification,
+ for: followed_user
+ })
+ end
end
end