fix unauthenticated req to favourited/rebloggd_by
authorSadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 23 Jul 2019 14:02:18 +0000 (15:02 +0100)
committerSadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 23 Jul 2019 14:08:33 +0000 (15:08 +0100)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

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