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
This commit is contained in:
lambda 2018-08-27 08:25:27 +00:00
commit 440b459cd1
3 changed files with 44 additions and 7 deletions

View file

@ -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