aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-07 12:43:30 +0200
committerlain <lain@soykaf.club>2020-05-07 12:43:30 +0200
commitf57fa2a00df2d93eba53c1ff3ab5c7d5fabb8308 (patch)
tree75851b816d4195da3094f25cb07a561903f97463 /lib
parent4c92dfb73ef1f40438adf5da009499205a677912 (diff)
downloadpleroma-f57fa2a00df2d93eba53c1ff3ab5c7d5fabb8308.tar.gz
Notifications: Simplify recipient calculation for some Activities.
Fixes the 'getting notfications for other people's posts' bug.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 98289af08..b14e7c843 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -339,13 +339,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)
@@ -363,6 +357,27 @@ defmodule Pleroma.Notification do
def get_notified_from_activity(_, _local_only), do: {[], []}
+ # For some actitivies, only notifity 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 \\ [])