diff options
author | rinpatch <rinpatch@sdf.org> | 2020-05-08 15:00:43 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-05-08 15:00:43 +0000 |
commit | 570940a3fd8d5a2fb600656432dfc01304161221 (patch) | |
tree | 036b218fd0381f0f91655a3458c5cc4dd41fd314 /lib | |
parent | fbcc53760e6fcd393513c05a5bd7a4a6a6f3b731 (diff) | |
parent | 8ae4d64d475405f8ff98868b80fc71fbe74b45bc (diff) | |
download | pleroma-570940a3fd8d5a2fb600656432dfc01304161221.tar.gz |
Merge branch 'bugfix/fix-like-notifications' into 'develop'
Notifications: Simplify recipient calculation for some Activities.
See merge request pleroma/pleroma!2486
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index c135306ca..8aa9ed2d4 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -368,13 +368,7 @@ defmodule Pleroma.Notification do def get_notified_from_activity(%Activity{data: %{"type" => type}} = activity, local_only) when type in ["Create", "Like", "Announce", "Follow", "Move", "EmojiReact"] do - potential_receiver_ap_ids = - [] - |> Utils.maybe_notify_to_recipients(activity) - |> Utils.maybe_notify_mentioned_recipients(activity) - |> Utils.maybe_notify_subscribers(activity) - |> Utils.maybe_notify_followers(activity) - |> Enum.uniq() + potential_receiver_ap_ids = get_potential_receiver_ap_ids(activity) potential_receivers = User.get_users_from_set(potential_receiver_ap_ids, local_only) @@ -392,6 +386,27 @@ defmodule Pleroma.Notification do def get_notified_from_activity(_, _local_only), do: {[], []} + # For some activities, only notify the author of the object + def get_potential_receiver_ap_ids(%{data: %{"type" => type, "object" => object_id}}) + when type in ~w{Like Announce EmojiReact} do + case Object.get_cached_by_ap_id(object_id) do + %Object{data: %{"actor" => actor}} -> + [actor] + + _ -> + [] + end + end + + def get_potential_receiver_ap_ids(activity) do + [] + |> Utils.maybe_notify_to_recipients(activity) + |> Utils.maybe_notify_mentioned_recipients(activity) + |> Utils.maybe_notify_subscribers(activity) + |> Utils.maybe_notify_followers(activity) + |> Enum.uniq() + end + @doc "Filters out AP IDs domain-blocking and not following the activity's actor" def exclude_domain_blocker_ap_ids(ap_ids, activity, preloaded_users \\ []) |