Merge branch 'fix/subscriber-notifications' into 'develop'
Do not notify subscribers for messages from users which are replies to others See merge request pleroma/pleroma!1477
This commit is contained in:
commit
03d89e182e
@ -439,6 +439,13 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||||||
|
|
||||||
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
||||||
|
|
||||||
|
# Do not notify subscribers if author is making a reply
|
||||||
|
def maybe_notify_subscribers(recipients, %Activity{
|
||||||
|
object: %Object{data: %{"inReplyTo" => _ap_id}}
|
||||||
|
}) do
|
||||||
|
recipients
|
||||||
|
end
|
||||||
|
|
||||||
def maybe_notify_subscribers(
|
def maybe_notify_subscribers(
|
||||||
recipients,
|
recipients,
|
||||||
%Activity{data: %{"actor" => actor, "type" => type}} = activity
|
%Activity{data: %{"actor" => actor, "type" => type}} = activity
|
||||||
|
@ -42,6 +42,28 @@ defmodule Pleroma.NotificationTest do
|
|||||||
|
|
||||||
assert notification.user_id == subscriber.id
|
assert notification.user_id == subscriber.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "does not create a notification for subscribed users if status is a reply" do
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user)
|
||||||
|
subscriber = insert(:user)
|
||||||
|
|
||||||
|
User.subscribe(subscriber, other_user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
|
||||||
|
|
||||||
|
{:ok, _reply_activity} =
|
||||||
|
CommonAPI.post(other_user, %{
|
||||||
|
"status" => "test reply",
|
||||||
|
"in_reply_to_status_id" => activity.id
|
||||||
|
})
|
||||||
|
|
||||||
|
user_notifications = Notification.for_user(user)
|
||||||
|
assert length(user_notifications) == 1
|
||||||
|
|
||||||
|
subscriber_notifications = Notification.for_user(subscriber)
|
||||||
|
assert Enum.empty?(subscriber_notifications)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "create_notification" do
|
describe "create_notification" do
|
||||||
|
Loading…
Reference in New Issue
Block a user