maybe_notify_subscribers: Don't create notifications from ingested messages
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 11 Aug 2021 17:45:49 +0000 (19:45 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 11 Aug 2021 18:49:38 +0000 (20:49 +0200)
CHANGELOG.md
lib/pleroma/web/common_api/utils.ex

index 4e3e408646f1aad4403ca427ee2d67914bf62472..c07e596b591712fc2a298e316d9ac02b27e6a4dc 100644 (file)
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 ### Added
 
 ### Fixed
+- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
 
 ### Removed
 
index 33639e6954fb54f51473fb9926c02c2f56b56239..10eb48250e9fb63a4d5f17536fe54cf74743adfa 100644 (file)
@@ -412,19 +412,14 @@ defmodule Pleroma.Web.CommonAPI.Utils do
 
   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(
         recipients,
-        %Activity{data: %{"actor" => actor, "type" => type}} = activity
-      )
-      when type == "Create" do
-    with %User{} = user <- User.get_cached_by_ap_id(actor) do
+        %Activity{data: %{"actor" => actor, "type" => "Create"}} = activity
+      ) do
+    # Do not notify subscribers if author is making a reply
+    with %Object{data: object} <- Object.normalize(activity, fetch: false),
+         nil <- object["inReplyTo"],
+         %User{} = user <- User.get_cached_by_ap_id(actor) do
       subscriber_ids =
         user
         |> User.subscriber_users()