maybe_notify_subscribers: Don't create notifications from ingested replies

Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3505
This commit is contained in:
Haelwenn (lanodan) Monnier 2021-08-11 19:45:49 +02:00
parent 0e2aebd036
commit bb2d5879cc
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 7 additions and 11 deletions

View file

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- MastodonAPI: Stream out Create activities - MastodonAPI: Stream out Create activities
- MRF ObjectAgePolicy: Fix pattern matching on "published" - MRF ObjectAgePolicy: Fix pattern matching on "published"
- TwitterAPI: Make `change_password` and `change_email` require params on body instead of query - TwitterAPI: Make `change_password` and `change_email` require params on body instead of query
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
## 2.4.0 - 2021-08-08 ## 2.4.0 - 2021-08-08

View file

@ -412,19 +412,14 @@ def maybe_notify_mentioned_recipients(
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" => "Create"}} = activity
) ) do
when type == "Create" do # Do not notify subscribers if author is making a reply
with %User{} = user <- User.get_cached_by_ap_id(actor) do with %Object{data: object} <- Object.normalize(activity, fetch: false),
nil <- object["inReplyTo"],
%User{} = user <- User.get_cached_by_ap_id(actor) do
subscriber_ids = subscriber_ids =
user user
|> User.subscriber_users() |> User.subscriber_users()