Commit d26cd6c1 authored by kaniini's avatar kaniini

user: factor out user set fetching from User.get_notified_from_activity()

parent 81d6ca17
Pipeline #4346 passed with stages
in 9 minutes and 16 seconds
......@@ -464,15 +464,15 @@ def update_follower_count(%User{} = user) do
update_and_set_cache(cs)
end
def get_notified_from_activity_query(to, false) do
def get_users_from_set_query(ap_ids, false) do
from(
u in User,
where: u.ap_id in ^to
where: u.ap_id in ^ap_ids
)
end
def get_notified_from_activity_query(to, true) do
query = get_notified_from_activity_query(to, false)
def get_users_from_set_query(ap_ids, true) do
query = get_users_from_set_query(ap_ids, false)
from(
u in query,
......@@ -480,6 +480,11 @@ def get_notified_from_activity_query(to, true) do
)
end
def get_users_from_set(ap_ids, local_only \\ true) do
get_users_from_set_query(ap_ids, local_only)
|> Repo.all()
end
def get_notified_from_activity(activity, local_only \\ true)
def get_notified_from_activity(%Activity{data: %{"to" => to} = data}, local_only) do
......@@ -513,9 +518,7 @@ def get_notified_from_activity(%Activity{data: %{"to" => to} = data}, local_only
(to ++ tagged_mentions)
|> Enum.uniq()
query = get_notified_from_activity_query(to, local_only)
Repo.all(query)
get_users_from_set(to, local_only)
end
def get_notified_from_activity(_, _), do: []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment