diff options
| author | eugenijm <eugenijm@protonmail.com> | 2019-03-27 22:09:39 +0300 | 
|---|---|---|
| committer | eugenijm <eugenijm@protonmail.com> | 2019-03-28 07:52:07 +0300 | 
| commit | 55d086b52077a220aef60c8d9071aea990431d74 (patch) | |
| tree | 9696ce6c0ea3ba8ceaea5b1f7700b4907066dbc6 /test | |
| parent | 926bf114b7385761c3cac50e262d061f47fda4b8 (diff) | |
| download | pleroma-55d086b52077a220aef60c8d9071aea990431d74.tar.gz pleroma-55d086b52077a220aef60c8d9071aea990431d74.zip | |
Notification controls
Allow users to configure whether they want to receive notifications from people they follow / who follow them, people from remote / local instances
Diffstat (limited to 'test')
| -rw-r--r-- | test/notification_test.exs | 69 | 
1 files changed, 69 insertions, 0 deletions
| diff --git a/test/notification_test.exs b/test/notification_test.exs index 12b4292aa..89d06b3a2 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -41,6 +41,75 @@ defmodule Pleroma.NotificationTest do        assert nil == Notification.create_notification(activity, user)      end +    test "it doesn't create a notificatin for the user if the user mutes the activity author" do +      muter = insert(:user) +      muted = insert(:user) +      {:ok, _} = User.mute(muter, muted) +      muter = Repo.get(User, muter.id) +      {:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"}) + +      assert nil == Notification.create_notification(activity, muter) +    end + +    test "it doesn't create a notification for an activity from a muted thread" do +      muter = insert(:user) +      other_user = insert(:user) +      {:ok, activity} = CommonAPI.post(muter, %{"status" => "hey"}) +      CommonAPI.add_mute(muter, activity) + +      {:ok, activity} = +        CommonAPI.post(other_user, %{ +          "status" => "Hi @#{muter.nickname}", +          "in_reply_to_status_id" => activity.id +        }) + +      assert nil == Notification.create_notification(activity, muter) +    end + +    test "it disables notifications from people on remote instances" do +      user = insert(:user, info: %{notification_settings: %{"remote" => false}}) +      other_user = insert(:user) + +      create_activity = %{ +        "@context" => "https://www.w3.org/ns/activitystreams", +        "type" => "Create", +        "to" => ["https://www.w3.org/ns/activitystreams#Public"], +        "actor" => other_user.ap_id, +        "object" => %{ +          "type" => "Note", +          "content" => "Hi @#{user.nickname}", +          "attributedTo" => other_user.ap_id +        } +      } + +      {:ok, %{local: false} = activity} = Transmogrifier.handle_incoming(create_activity) +      assert nil == Notification.create_notification(activity, user) +    end + +    test "it disables notifications from people on the local instance" do +      user = insert(:user, info: %{notification_settings: %{"local" => false}}) +      other_user = insert(:user) +      {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"}) +      assert nil == Notification.create_notification(activity, user) +    end + +    test "it disables notifications from followers" do +      follower = insert(:user) +      followed = insert(:user, info: %{notification_settings: %{"followers" => false}}) +      User.follow(follower, followed) +      {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"}) +      assert nil == Notification.create_notification(activity, followed) +    end + +    test "it disables notifications from people the user follows" do +      follower = insert(:user, info: %{notification_settings: %{"follows" => false}}) +      followed = insert(:user) +      User.follow(follower, followed) +      follower = Repo.get(User, follower.id) +      {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"}) +      assert nil == 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_by_ap_id(activity.data["actor"]) | 
