Merge branch 'fix/pleroma-api-emoji-packs' into 'develop'
authorlain <lain@soykaf.club>
Wed, 22 Jul 2020 15:09:32 +0000 (15:09 +0000)
committerlain <lain@soykaf.club>
Wed, 22 Jul 2020 15:09:32 +0000 (15:09 +0000)
Fix /api/pleroma/emoji/packs index endpoint.

See merge request pleroma/pleroma!2777

CHANGELOG.md
lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex
test/web/pleroma_api/controllers/emoji_pack_controller_test.exs

index 08027007339d1cb6e6fd0cf76949e3d3018964f9..67e51d8acdc3f9bac854509f5c0cfba6d886c2cc 100644 (file)
@@ -93,6 +93,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Admin API: fix `GET /api/pleroma/admin/users/:nickname/credentials` returning 404 when getting the credentials of a remote user while `:instance, :limit_to_local_content` is set to `:unauthenticated`
 - Fix CSP policy generation to include remote Captcha services
 - Fix edge case where MediaProxy truncates media, usually caused when Caddy is serving content for the other Federated instance.
+- Emoji Packs could not be listed when instance was set to `public: false`
 
 ## [Unreleased (patch)]
 
index 33ecd1f70979ce27af7e335f58e8f8c0fe5ff647..657f4632451a192a0bf34dccb1bfe928d5e3c5d6 100644 (file)
@@ -21,8 +21,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackController do
          ]
   )
 
-  @skip_plugs [Pleroma.Plugs.OAuthScopesPlug, Pleroma.Plugs.ExpectPublicOrAuthenticatedCheckPlug]
-  plug(:skip_plug, @skip_plugs when action in [:archive, :show, :list])
+  @skip_plugs [Pleroma.Plugs.OAuthScopesPlug, Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug]
+  plug(:skip_plug, @skip_plugs when action in [:index, :show, :archive])
 
   defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaEmojiPackOperation
 
index df58a5eb63a92ee796c95b12cf38e13649619bfc..e113bb15fb679697f89093d45a01866e84f39532 100644 (file)
@@ -14,6 +14,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
               )
   setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
 
+  setup do: clear_config([:instance, :public], true)
+
   setup do
     admin = insert(:user, is_admin: true)
     token = insert(:oauth_admin_token, user: admin)
@@ -27,6 +29,11 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
     {:ok, %{admin_conn: admin_conn}}
   end
 
+  test "GET /api/pleroma/emoji/packs when :public: false", %{conn: conn} do
+    Config.put([:instance, :public], false)
+    conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
+  end
+
   test "GET /api/pleroma/emoji/packs", %{conn: conn} do
     resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)