aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/user.ex
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-08-27 08:25:27 +0000
committerlambda <pleromagit@rogerbraun.net>2018-08-27 08:25:27 +0000
commit440b459cd14778e155cd6a3550847b1277fbd1f1 (patch)
tree6f8930579bf7c310dc57d1e2e82d571615888a65 /lib/pleroma/user.ex
parent63094cfd3ec0a9ca6e17a3ba6fa8271050cfb9b0 (diff)
parent7e0f62acee35a9e2738caab97deffdaae6a822c4 (diff)
downloadpleroma-440b459cd14778e155cd6a3550847b1277fbd1f1.tar.gz
Merge branch 'bugfix/announce-timeline-flooding' into 'develop'
activitypub: filter destination list for announce activities differently than normal (closes #164) Closes #164 See merge request pleroma/pleroma!227
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r--lib/pleroma/user.ex28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index fa0ea171d..7d7f3b23e 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -457,13 +457,29 @@ defmodule Pleroma.User do
update_and_set_cache(cs)
end
+ def get_notified_from_activity_query(to) do
+ from(
+ u in User,
+ where: u.ap_id in ^to,
+ where: u.local == true
+ )
+ end
+
+ def get_notified_from_activity(%Activity{recipients: to, data: %{"type" => "Announce"} = data}) do
+ object = Object.normalize(data["object"])
+
+ # ensure that the actor who published the announced object appears only once
+ to =
+ (to ++ [object.data["actor"]])
+ |> Enum.uniq()
+
+ query = get_notified_from_activity_query(to)
+
+ Repo.all(query)
+ end
+
def get_notified_from_activity(%Activity{recipients: to}) do
- query =
- from(
- u in User,
- where: u.ap_id in ^to,
- where: u.local == true
- )
+ query = get_notified_from_activity_query(to)
Repo.all(query)
end