Do not notify subscribers for messages from users which are replies to others
authorMark Felder <feld@FreeBSD.org>
Tue, 23 Jul 2019 18:14:26 +0000 (13:14 -0500)
committerMark Felder <feld@FreeBSD.org>
Tue, 23 Jul 2019 18:14:26 +0000 (13:14 -0500)
lib/pleroma/web/common_api/utils.ex
test/notification_test.exs

index fcc0009695bc4560af4c561081d9fa553f9544fe..6f0f56d96a7c1587196e27c5fafb400918f4ae34 100644 (file)
@@ -439,6 +439,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do
 
   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(
         recipients,
         %Activity{data: %{"actor" => actor, "type" => type}} = activity
index dda570b499b5841ba3ebaff7b5cd01d771cba954..06f0b6557f1a97095c09f76be58b313134dd02ce 100644 (file)
@@ -42,6 +42,24 @@ defmodule Pleroma.NotificationTest do
 
       assert notification.user_id == subscriber.id
     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
 
   describe "create_notification" do