fix unauthenticated req to favourited/rebloggd_by

This commit is contained in:
Sadposter 2019-07-23 15:02:18 +01:00
parent a042a7ac6d
commit eacf61d823
1 changed files with 12 additions and 6 deletions

View File

@ -884,9 +884,12 @@ 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 = users = Repo.all(q)
Repo.all(q) users = if is_nil(user) do
|> Enum.filter(&(not User.blocks?(user, &1))) users
else
Enum.filter(users, &(not User.blocks?(user, &1)))
end
conn conn
|> put_view(AccountView) |> put_view(AccountView)
@ -901,9 +904,12 @@ 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 = users = Repo.all(q)
Repo.all(q) users = if is_nil(user) do
|> Enum.filter(&(not User.blocks?(user, &1))) users
else
Enum.filter(users, &(not User.blocks?(user, &1)))
end
conn conn
|> put_view(AccountView) |> put_view(AccountView)