Merge remote-tracking branch 'remotes/origin/develop' into 1427-oauth-admin-scopes
[akkoma] / lib / pleroma / web / pleroma_api / controllers / emoji_api_controller.ex
index cf5a086feece30072b962ab2b1a58ca6e679a060..6f286032eafb510a40ce6bb0da5e04079de17505 100644 (file)
@@ -1,8 +1,26 @@
 defmodule Pleroma.Web.PleromaAPI.EmojiAPIController do
   use Pleroma.Web, :controller
 
+  alias Pleroma.Plugs.OAuthScopesPlug
+
   require Logger
 
+  plug(
+    OAuthScopesPlug,
+    %{scopes: Pleroma.Config.oauth_admin_scopes("write")}
+    when action in [
+           :create,
+           :delete,
+           :download_from,
+           :list_from,
+           :import_from_fs,
+           :update_file,
+           :update_metadata
+         ]
+  )
+
+  plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
+
   def emoji_dir_path do
     Path.join(
       Pleroma.Config.get!([:instance, :static_dir]),
@@ -182,6 +200,7 @@ keeping it in cache for #{div(cache_ms, 1000)}s")
     |> Tesla.get!()
     |> Map.get(:body)
     |> Jason.decode!()
+    |> Map.get("links")
     |> List.last()
     |> Map.get("href")
     # Get the actual nodeinfo address and fetch it