X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuser.ex;h=856f27e1013a160701c0ef7a3991c4cd5e5b66fc;hb=6f384d35ddc4682e3b845b0224ca620fbdd93785;hp=b27397e13956fc5ae16e638ff3e2ef69c1e21d2b;hpb=a6e0c31518ff60bd5e147941446779d719afaeb2;p=akkoma diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b27397e13..856f27e10 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -449,13 +449,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.get_by_ap_id(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