mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-01-09 08:45:26 +00:00
move unauth'd user blocks?/2 check
This commit is contained in:
parent
c400565427
commit
54a161cb7a
2 changed files with 6 additions and 14 deletions
|
@ -882,6 +882,8 @@ defmodule Pleroma.User do
|
|||
Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, host)
|
||||
end
|
||||
|
||||
def blocks?(nil, _), do: false
|
||||
|
||||
def subscribed_to?(user, %{ap_id: ap_id}) do
|
||||
with %User{} = target <- get_cached_by_ap_id(ap_id) do
|
||||
Enum.member?(target.info.subscribers, user.ap_id)
|
||||
|
|
|
@ -884,14 +884,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
%Object{data: %{"likes" => likes}} <- Object.normalize(object) do
|
||||
q = from(u in User, where: u.ap_id in ^likes)
|
||||
|
||||
users = Repo.all(q)
|
||||
|
||||
users =
|
||||
if is_nil(user) do
|
||||
users
|
||||
else
|
||||
Enum.filter(users, &(not User.blocks?(user, &1)))
|
||||
end
|
||||
Repo.all(q)
|
||||
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||
|
||||
conn
|
||||
|> put_view(AccountView)
|
||||
|
@ -906,14 +901,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
%Object{data: %{"announcements" => announces}} <- Object.normalize(object) do
|
||||
q = from(u in User, where: u.ap_id in ^announces)
|
||||
|
||||
users = Repo.all(q)
|
||||
|
||||
users =
|
||||
if is_nil(user) do
|
||||
users
|
||||
else
|
||||
Enum.filter(users, &(not User.blocks?(user, &1)))
|
||||
end
|
||||
Repo.all(q)
|
||||
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||
|
||||
conn
|
||||
|> put_view(AccountView)
|
||||
|
|
Loading…
Reference in a new issue