diff options
| author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-12 21:53:03 +0300 | 
|---|---|---|
| committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-12 21:53:03 +0300 | 
| commit | c556efb761a3e7fc2beb4540d6f58dbfe8e4abfe (patch) | |
| tree | 9d6e727360e4d4d66db75362f0f29a43c97425d3 /test | |
| parent | 88b16fdfb7b40877aecae5d45f6f3a1c54362f13 (diff) | |
| download | pleroma-c556efb761a3e7fc2beb4540d6f58dbfe8e4abfe.tar.gz pleroma-c556efb761a3e7fc2beb4540d6f58dbfe8e4abfe.zip | |
[#1364] Enabled notifications on followed domain-blocked users' activities.
Diffstat (limited to 'test')
| -rw-r--r-- | test/notification_test.exs | 35 | 
1 files changed, 32 insertions, 3 deletions
| diff --git a/test/notification_test.exs b/test/notification_test.exs index caa941934..4e5559bb1 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -610,7 +610,7 @@ defmodule Pleroma.NotificationTest do        refute other_user in enabled_receivers      end -    test "it returns domain-blocking recipient in disabled recipients list" do +    test "it returns non-following domain-blocking recipient in disabled recipients list" do        blocked_domain = "blocked.domain"        user = insert(:user, %{ap_id: "https://#{blocked_domain}/@actor"})        other_user = insert(:user) @@ -624,6 +624,22 @@ defmodule Pleroma.NotificationTest do        assert [] == enabled_receivers        assert [other_user] == disabled_receivers      end + +    test "it returns following domain-blocking recipient in enabled recipients list" do +      blocked_domain = "blocked.domain" +      user = insert(:user, %{ap_id: "https://#{blocked_domain}/@actor"}) +      other_user = insert(:user) + +      {:ok, other_user} = User.block_domain(other_user, blocked_domain) +      {:ok, other_user} = User.follow(other_user, user) + +      {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"}) + +      {enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity) + +      assert [other_user] == enabled_receivers +      assert [] == disabled_receivers +    end    end    describe "notification lifecycle" do @@ -886,7 +902,7 @@ defmodule Pleroma.NotificationTest do        assert Notification.for_user(user) == []      end -    test "it doesn't return notifications for blocked domain" do +    test "it doesn't return notifications for domain-blocked non-followed user" do        user = insert(:user)        blocked = insert(:user, ap_id: "http://some-domain.com")        {:ok, user} = User.block_domain(user, "some-domain.com") @@ -896,6 +912,18 @@ defmodule Pleroma.NotificationTest 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" do        user = insert(:user)        another_user = insert(:user) @@ -926,7 +954,8 @@ defmodule Pleroma.NotificationTest do        assert Enum.empty?(Notification.for_user(user, %{with_muted: true}))      end -    test "it doesn't return notifications from a domain-blocked user when with_muted is set" do +    test "when with_muted is set, " <> +           "it doesn't return notifications from a domain-blocked non-followed user" do        user = insert(:user)        blocked = insert(:user, ap_id: "http://some-domain.com")        {:ok, user} = User.block_domain(user, "some-domain.com") | 
