alias Pleroma.FollowingRelationship
alias Pleroma.Notification
+ alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
{:ok, [notification]} = Notification.create_notifications(activity)
assert notification.user_id == user.id
+ assert notification.type == "pleroma:emoji_reaction"
end
test "notifies someone when they are directly addressed" do
notified_ids = Enum.sort([notification.user_id, other_notification.user_id])
assert notified_ids == [other_user.id, third_user.id]
assert notification.activity_id == activity.id
+ assert notification.type == "mention"
assert other_notification.activity_id == activity.id
assert [%Pleroma.Marker{unread_count: 2}] =
assert Notification.create_notification(activity, muter)
end
- test "it disables notifications from followers" do
- follower = insert(:user)
-
- followed =
- insert(:user, notification_settings: %Pleroma.User.NotificationSetting{followers: false})
-
- User.follow(follower, followed)
- {:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
- refute Notification.create_notification(activity, followed)
- end
-
- test "it disables notifications from non-followers" do
+ test "it disables notifications from strangers" do
follower = insert(:user)
followed =
insert(:user,
- notification_settings: %Pleroma.User.NotificationSetting{non_followers: false}
+ notification_settings: %Pleroma.User.NotificationSetting{block_from_strangers: true}
)
{:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
refute Notification.create_notification(activity, followed)
end
- test "it disables notifications from people the user follows" do
- follower =
- insert(:user, notification_settings: %Pleroma.User.NotificationSetting{follows: false})
-
- followed = insert(:user)
- User.follow(follower, followed)
- follower = Repo.get(User, follower.id)
- {:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
- refute Notification.create_notification(activity, follower)
- end
-
- test "it disables notifications from people the user does not follow" do
- follower =
- insert(:user, notification_settings: %Pleroma.User.NotificationSetting{non_follows: false})
-
- followed = insert(:user)
- {:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
- refute Notification.create_notification(activity, follower)
- end
-
test "it doesn't create a notification for user if he is the activity author" do
activity = insert(:note_activity)
author = User.get_cached_by_ap_id(activity.data["actor"])
assert {:ok, []} == Notification.create_notifications(status)
end
+
+ test "it disables notifications from people who are invisible" do
+ author = insert(:user, invisible: true)
+ user = insert(:user)
+
+ {:ok, status} = CommonAPI.post(author, %{status: "hey @#{user.nickname}"})
+ refute Notification.create_notification(status, user)
+ end
end
describe "follow / follow_request notifications" do
# After request is accepted, the same notification is rendered with type "follow":
assert {:ok, _} = CommonAPI.accept_follow_request(user, followed_user)
- notification_id = notification.id
- assert [%{id: ^notification_id}] = Notification.for_user(followed_user)
- assert %{type: "follow"} = NotificationView.render("show.json", render_opts)
+ notification =
+ Repo.get(Notification, notification.id)
+ |> Repo.preload(:activity)
+
+ assert %{type: "follow"} =
+ NotificationView.render("show.json", notification: notification, for: followed_user)
end
test "it doesn't create a notification for follow-unfollow-follow chains" do