Made follow request notifications non-optional (removed config switch).
authorIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 1 May 2020 06:51:41 +0000 (09:51 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Fri, 1 May 2020 06:51:41 +0000 (09:51 +0300)
CHANGELOG.md
config/config.exs
config/description.exs
lib/pleroma/notification.ex
test/notification_test.exs

index 65dd1b9c2727d628f08418feb60bcb00c502d8c8..97704917d8030ed5df48ffa5f62b225235b5a126 100644 (file)
@@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Configuration: `:restrict_unauthenticated` setting, restrict access for unauthenticated users to timelines (public and federate), user profiles and statuses.
 - New HTTP adapter [gun](https://github.com/ninenines/gun). Gun adapter requires minimum OTP version of 22.2 otherwise Pleroma won’t start. For hackney OTP update is not required.
 - Mix task to create trusted OAuth App.
-- Notifications: Added `follow_request` notification type (configurable, see `[:notifications, :enable_follow_request_notifications]` setting).
+- Notifications: Added `follow_request` notification type.
 - Added `:reject_deletes` group to SimplePolicy
 <details>
   <summary>API Changes</summary>
index 2e538c4be7dfa9ad622b15735e7a70db788fd5b3..a6c6d6f99e7c593caffe00062d61671eea94d121 100644 (file)
@@ -562,8 +562,6 @@ config :pleroma, :email_notifications,
     inactivity_threshold: 7
   }
 
-config :pleroma, :notifications, enable_follow_request_notifications: false
-
 config :pleroma, :oauth2,
   token_expires_in: 600,
   issue_new_refresh_token: true,
index 7fac1e5611a2c6766371e4ef73baf6e8fecd3fd5..9d8e3b93cd53409909c309d41a8dc74277bcb836 100644 (file)
@@ -2273,20 +2273,6 @@ config :pleroma, :config_description, [
       }
     ]
   },
-  %{
-    group: :pleroma,
-    key: :notifications,
-    type: :group,
-    description: "Notification settings",
-    children: [
-      %{
-        key: :enable_follow_request_notifications,
-        type: :boolean,
-        description:
-          "Enables notifications on new follow requests (causes issues with older PleromaFE versions)."
-      }
-    ]
-  },
   %{
     group: :pleroma,
     key: Pleroma.Emails.UserEmail,
index 9a109dfabf66f6ebe55d56e6cb7731aa37daff70..98289af08016e218008e2b27eb5dbd2f3c2dca18 100644 (file)
@@ -293,17 +293,8 @@ defmodule Pleroma.Notification do
     end
   end
 
-  def create_notifications(%Activity{data: %{"type" => "Follow"}} = activity) do
-    if Pleroma.Config.get([:notifications, :enable_follow_request_notifications]) ||
-         Activity.follow_accepted?(activity) do
-      do_create_notifications(activity)
-    else
-      {:ok, []}
-    end
-  end
-
   def create_notifications(%Activity{data: %{"type" => type}} = activity)
-      when type in ["Like", "Announce", "Move", "EmojiReact"] do
+      when type in ["Follow", "Like", "Announce", "Move", "EmojiReact"] do
     do_create_notifications(activity)
   end
 
index 0e9ffcb1824435d251d21416ae27ad3f29ec289c..601a6c0ca1f4b3d70b16b13b8d8d7b242491b661 100644 (file)
@@ -312,9 +312,7 @@ defmodule Pleroma.NotificationTest do
                })
     end
 
-    test "if `follow_request` notifications are enabled, " <>
-           "it creates `follow_request` notification for pending Follow activity" do
-      clear_config([:notifications, :enable_follow_request_notifications], true)
+    test "it creates `follow_request` notification for pending Follow activity" do
       user = insert(:user)
       followed_user = insert(:user, locked: true)
 
@@ -333,21 +331,6 @@ defmodule Pleroma.NotificationTest do
       assert %{type: "follow"} = NotificationView.render("show.json", render_opts)
     end
 
-    test "if `follow_request` notifications are disabled, " <>
-           "it does NOT create `follow*` notification for pending Follow activity" do
-      clear_config([:notifications, :enable_follow_request_notifications], false)
-      user = insert(:user)
-      followed_user = insert(:user, locked: true)
-
-      {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
-      refute FollowingRelationship.following?(user, followed_user)
-      assert [] = Notification.for_user(followed_user)
-
-      # After request is accepted, no new notifications are generated:
-      assert {:ok, _} = CommonAPI.accept_follow_request(user, followed_user)
-      assert [] = Notification.for_user(followed_user)
-    end
-
     test "it doesn't create a notification for follow-unfollow-follow chains" do
       user = insert(:user)
       followed_user = insert(:user, locked: false)
@@ -364,7 +347,6 @@ defmodule Pleroma.NotificationTest do
     end
 
     test "dismisses the notification on follow request rejection" do
-      clear_config([:notifications, :enable_follow_request_notifications], true)
       user = insert(:user, locked: true)
       follower = insert(:user)
       {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)