@@ -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. | - 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. | - 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. | - 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 | - Added `:reject_deletes` group to SimplePolicy | ||||
<details> | <details> | ||||
<summary>API Changes</summary> | <summary>API Changes</summary> | ||||
@@ -562,8 +562,6 @@ config :pleroma, :email_notifications, | |||||
inactivity_threshold: 7 | inactivity_threshold: 7 | ||||
} | } | ||||
config :pleroma, :notifications, enable_follow_request_notifications: false | |||||
config :pleroma, :oauth2, | config :pleroma, :oauth2, | ||||
token_expires_in: 600, | token_expires_in: 600, | ||||
issue_new_refresh_token: true, | issue_new_refresh_token: true, | ||||
@@ -2275,20 +2275,6 @@ config :pleroma, :config_description, [ | |||||
}, | }, | ||||
%{ | %{ | ||||
group: :pleroma, | 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, | key: Pleroma.Emails.UserEmail, | ||||
type: :group, | type: :group, | ||||
description: "Email template settings", | description: "Email template settings", | ||||
@@ -293,17 +293,8 @@ defmodule Pleroma.Notification do | |||||
end | end | ||||
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) | 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) | do_create_notifications(activity) | ||||
end | end | ||||
@@ -312,9 +312,7 @@ defmodule Pleroma.NotificationTest do | |||||
}) | }) | ||||
end | 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) | user = insert(:user) | ||||
followed_user = insert(:user, locked: true) | followed_user = insert(:user, locked: true) | ||||
@@ -333,21 +331,6 @@ defmodule Pleroma.NotificationTest do | |||||
assert %{type: "follow"} = NotificationView.render("show.json", render_opts) | assert %{type: "follow"} = NotificationView.render("show.json", render_opts) | ||||
end | 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 | test "it doesn't create a notification for follow-unfollow-follow chains" do | ||||
user = insert(:user) | user = insert(:user) | ||||
followed_user = insert(:user, locked: false) | followed_user = insert(:user, locked: false) | ||||
@@ -364,7 +347,6 @@ defmodule Pleroma.NotificationTest do | |||||
end | end | ||||
test "dismisses the notification on follow request rejection" do | test "dismisses the notification on follow request rejection" do | ||||
clear_config([:notifications, :enable_follow_request_notifications], true) | |||||
user = insert(:user, locked: true) | user = insert(:user, locked: true) | ||||
follower = insert(:user) | follower = insert(:user) | ||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user) | {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user) | ||||