Do not notify subscribers for messages from users which are replies to others
This commit is contained in:
parent
a042a7ac6d
commit
fd287387a0
2 changed files with 24 additions and 0 deletions
|
@ -439,6 +439,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
|
|
||||||
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
||||||
|
|
||||||
|
def maybe_notify_subscribers(_, %Activity{
|
||||||
|
data: %{"object" => %Object{data: %{"inReplyTo" => _ap_id}}}
|
||||||
|
}) do
|
||||||
|
:nothing
|
||||||
|
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,24 @@ 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
|
||||||
|
})
|
||||||
|
|
||||||
|
refute Notification.create_notification(reply_activity, subscriber)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "create_notification" do
|
describe "create_notification" do
|
||||||
|
|
Loading…
Reference in a new issue