X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuser.ex;h=fca490cb1843c6227d6e8013c1d5962a02929370;hb=e838969495d2ca95406920ceef98d08f01d71192;hp=5e46208c3dadd13f2532b35cf63a93c5eb1bb1ca;hpb=ecfd4b21066f7df7450d5aace403ac97c0d7778a;p=akkoma diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 5e46208c3..fca490cb1 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -398,6 +398,7 @@ defmodule Pleroma.User do Enum.map(reqs, fn req -> req.actor end) |> Enum.uniq() |> Enum.map(fn ap_id -> get_by_ap_id(ap_id) end) + |> Enum.filter(fn u -> !following?(u, user) end) {:ok, users} end @@ -456,13 +457,34 @@ 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"]) + actor = User.get_cached_by_ap_id(data["actor"]) + + # ensure that the actor who published the announced object appears only once + to = + if actor.nickname != nil do + to ++ [object.data["actor"]] + else + to + end + |> 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 @@ -499,7 +521,8 @@ defmodule Pleroma.User do u.nickname, u.name ) - } + }, + where: not is_nil(u.nickname) ) q =