subscriber_notifications = Notification.for_user(subscriber)
assert Enum.empty?(subscriber_notifications)
end
+
+ test "it sends edited notifications to those who repeated a status" do
+ user = insert(:user)
+ repeated_user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity_one} =
+ CommonAPI.post(user, %{
+ status: "hey @#{other_user.nickname}!"
+ })
+
+ {:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
+
+ {:ok, _edit_activity} =
+ CommonAPI.update(user, activity_one, %{
+ status: "hey @#{other_user.nickname}! mew mew"
+ })
+
+ assert [%{type: "reblog"}] = Notification.for_user(user)
+ assert [%{type: "update"}] = Notification.for_user(repeated_user)
+ assert [%{type: "mention"}] = Notification.for_user(other_user)
+ end
end
test "create_poll_notifications/1" do
task =
Task.async(fn ->
{:ok, _topic} = Streamer.get_topic_and_add_socket("user", user, oauth_token)
- assert_receive {:render_with_user, _, _, _}, 4_000
+ assert_receive {:render_with_user, _, _, _, "user"}, 4_000
end)
task_user_notification =
{:ok, _topic} =
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
- assert_receive {:render_with_user, _, _, _}, 4_000
+ assert_receive {:render_with_user, _, _, _, "user:notification"}, 4_000
end)
activity = insert(:note_activity)
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
assert FollowingRelationship.following?(user, followed_user)
- assert [notification] = Notification.for_user(followed_user)
+ assert [_notification] = Notification.for_user(followed_user)
CommonAPI.unfollow(user, followed_user)
{:ok, _, _, _activity_dupe} = CommonAPI.follow(user, followed_user)
- notification_id = notification.id
- assert [%{id: ^notification_id}] = Notification.for_user(followed_user)
+ assert Enum.count(Notification.for_user(followed_user)) == 1
end
test "dismisses the notification on follow request rejection" do
end
end
+ describe "destroy_multiple_from_types/2" do
+ test "clears all notifications of a certain type for a given user" do
+ report_activity = insert(:report_activity)
+ user1 = insert(:user, is_moderator: true, is_admin: true)
+ user2 = insert(:user, is_moderator: true, is_admin: true)
+ {:ok, _} = Notification.create_notifications(report_activity)
+
+ {:ok, _} =
+ CommonAPI.post(user2, %{
+ status: "hey @#{user1.nickname} !"
+ })
+
+ Notification.destroy_multiple_from_types(user1, ["pleroma:report"])
+
+ assert [%Pleroma.Notification{type: "mention"}] = Notification.for_user(user1)
+ assert [%Pleroma.Notification{type: "pleroma:report"}] = Notification.for_user(user2)
+ end
+ end
+
describe "set_read_up_to()" do
test "it sets all notifications as read up to a specified notification ID" do
user = insert(:user)
assert [other_user] == enabled_receivers
assert [] == disabled_receivers
end
+
+ test "it sends edited notifications to those who repeated a status" do
+ user = insert(:user)
+ repeated_user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity_one} =
+ CommonAPI.post(user, %{
+ status: "hey @#{other_user.nickname}!"
+ })
+
+ {:ok, _activity_two} = CommonAPI.repeat(activity_one.id, repeated_user)
+
+ {:ok, edit_activity} =
+ CommonAPI.update(user, activity_one, %{
+ status: "hey @#{other_user.nickname}! mew mew"
+ })
+
+ {enabled_receivers, _disabled_receivers} =
+ Notification.get_notified_from_activity(edit_activity)
+
+ assert repeated_user in enabled_receivers
+ assert other_user not in enabled_receivers
+ end
end
describe "notification lifecycle" do
assert Notification.for_user(user) == []
end
- test "it returns notifications for domain-blocked but followed user" do
- user = insert(:user)
- blocked = insert(:user, ap_id: "http://some-domain.com")
-
- {:ok, user} = User.block_domain(user, "some-domain.com")
- {:ok, _, _} = User.follow(user, blocked)
-
- {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
-
- assert length(Notification.for_user(user)) == 1
- end
-
test "it doesn't return notifications for muted thread", %{user: user} do
another_user = insert(:user)