move unauth'd user blocks?/2 check
This commit is contained in:
parent
c400565427
commit
54a161cb7a
|
@ -882,6 +882,8 @@ def blocks?(%User{info: info} = _user, %{ap_id: ap_id}) do
|
||||||
Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, host)
|
Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blocks?(nil, _), do: false
|
||||||
|
|
||||||
def subscribed_to?(user, %{ap_id: ap_id}) do
|
def subscribed_to?(user, %{ap_id: ap_id}) do
|
||||||
with %User{} = target <- get_cached_by_ap_id(ap_id) do
|
with %User{} = target <- get_cached_by_ap_id(ap_id) do
|
||||||
Enum.member?(target.info.subscribers, user.ap_id)
|
Enum.member?(target.info.subscribers, user.ap_id)
|
||||||
|
|
|
@ -884,14 +884,9 @@ def favourited_by(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
%Object{data: %{"likes" => likes}} <- Object.normalize(object) do
|
%Object{data: %{"likes" => likes}} <- Object.normalize(object) do
|
||||||
q = from(u in User, where: u.ap_id in ^likes)
|
q = from(u in User, where: u.ap_id in ^likes)
|
||||||
|
|
||||||
users = Repo.all(q)
|
|
||||||
|
|
||||||
users =
|
users =
|
||||||
if is_nil(user) do
|
Repo.all(q)
|
||||||
users
|
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||||
else
|
|
||||||
Enum.filter(users, &(not User.blocks?(user, &1)))
|
|
||||||
end
|
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
|
@ -906,14 +901,9 @@ def reblogged_by(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||||
%Object{data: %{"announcements" => announces}} <- Object.normalize(object) do
|
%Object{data: %{"announcements" => announces}} <- Object.normalize(object) do
|
||||||
q = from(u in User, where: u.ap_id in ^announces)
|
q = from(u in User, where: u.ap_id in ^announces)
|
||||||
|
|
||||||
users = Repo.all(q)
|
|
||||||
|
|
||||||
users =
|
users =
|
||||||
if is_nil(user) do
|
Repo.all(q)
|
||||||
users
|
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||||
else
|
|
||||||
Enum.filter(users, &(not User.blocks?(user, &1)))
|
|
||||||
end
|
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
|
|
Loading…
Reference in a new issue