mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
user: add optional local_only param to get_notified_from_activity()
This commit is contained in:
parent
719a8a1f82
commit
0a2c1a3419
1 changed files with 17 additions and 7 deletions
|
@ -464,15 +464,25 @@ defmodule Pleroma.User do
|
||||||
update_and_set_cache(cs)
|
update_and_set_cache(cs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_notified_from_activity_query(to) do
|
def get_notified_from_activity_query(to, false) do
|
||||||
from(
|
from(
|
||||||
u in User,
|
u in User,
|
||||||
where: u.ap_id in ^to,
|
where: u.ap_id in ^to
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_notified_from_activity_query(to, true) do
|
||||||
|
query = get_notified_from_activity_query(to, false)
|
||||||
|
|
||||||
|
from(
|
||||||
|
u in query,
|
||||||
where: u.local == true
|
where: u.local == true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_notified_from_activity(%Activity{data: %{"type" => "Announce", "to" => to} = data}) do
|
def get_notified_from_activity(activity, local_only \\ true)
|
||||||
|
|
||||||
|
def get_notified_from_activity(%Activity{data: %{"type" => "Announce", "to" => to} = data}, local_only) do
|
||||||
object = Object.normalize(data["object"])
|
object = Object.normalize(data["object"])
|
||||||
actor = User.get_cached_by_ap_id(data["actor"])
|
actor = User.get_cached_by_ap_id(data["actor"])
|
||||||
|
|
||||||
|
@ -485,18 +495,18 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|
|
||||||
query = get_notified_from_activity_query(to)
|
query = get_notified_from_activity_query(to, local_only)
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_notified_from_activity(%Activity{data: %{"to" => to}}) do
|
def get_notified_from_activity(%Activity{data: %{"to" => to}}, local_only) do
|
||||||
query = get_notified_from_activity_query(to)
|
query = get_notified_from_activity_query(to, local_only)
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_notified_from_activity(_), do: []
|
def get_notified_from_activity(_, _), do: []
|
||||||
|
|
||||||
def get_recipients_from_activity(%Activity{recipients: to}) do
|
def get_recipients_from_activity(%Activity{recipients: to}) do
|
||||||
query =
|
query =
|
||||||
|
|
Loading…
Reference in a new issue