mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Merge branch 'tusooa/notif-setting' into 'develop'
Fix block_from_stranger setting See merge request pleroma/pleroma!3833
This commit is contained in:
commit
4d3c2fb21b
2 changed files with 27 additions and 1 deletions
|
@ -679,7 +679,7 @@ defmodule Pleroma.Notification do
|
||||||
cond do
|
cond do
|
||||||
opts[:type] == "poll" -> false
|
opts[:type] == "poll" -> false
|
||||||
user.ap_id == actor -> false
|
user.ap_id == actor -> false
|
||||||
!User.following?(follower, user) -> true
|
!User.following?(user, follower) -> true
|
||||||
true -> false
|
true -> false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -334,6 +334,32 @@ defmodule Pleroma.NotificationTest do
|
||||||
refute Notification.create_notification(activity, followed)
|
refute Notification.create_notification(activity, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it disables notifications from non-followees" do
|
||||||
|
follower = insert(:user)
|
||||||
|
|
||||||
|
followed =
|
||||||
|
insert(:user,
|
||||||
|
notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
CommonAPI.follow(follower, followed)
|
||||||
|
{:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
|
||||||
|
refute Notification.create_notification(activity, followed)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it allows notifications from followees" do
|
||||||
|
poster = insert(:user)
|
||||||
|
|
||||||
|
receiver =
|
||||||
|
insert(:user,
|
||||||
|
notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
CommonAPI.follow(receiver, poster)
|
||||||
|
{:ok, activity} = CommonAPI.post(poster, %{status: "hey @#{receiver.nickname}"})
|
||||||
|
assert Notification.create_notification(activity, receiver)
|
||||||
|
end
|
||||||
|
|
||||||
test "it doesn't create a notification for user if he is the activity author" do
|
test "it doesn't create a notification for user if he is the activity author" do
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
author = User.get_cached_by_ap_id(activity.data["actor"])
|
author = User.get_cached_by_ap_id(activity.data["actor"])
|
||||||
|
|
Loading…
Reference in a new issue