projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'remotes/origin/develop' into 1505-threads-federation
[akkoma]
/
lib
/
pleroma
/
web
/
pleroma_api
/
controllers
/
emoji_api_controller.ex
diff --git
a/lib/pleroma/web/pleroma_api/controllers/emoji_api_controller.ex
b/lib/pleroma/web/pleroma_api/controllers/emoji_api_controller.ex
index 6f286032eafb510a40ce6bb0da5e04079de17505..a2f6d2287f5a4f2966f2977532f979e0c22ba9d0 100644
(file)
--- a/
lib/pleroma/web/pleroma_api/controllers/emoji_api_controller.ex
+++ b/
lib/pleroma/web/pleroma_api/controllers/emoji_api_controller.ex
@@
-7,7
+7,7
@@
defmodule Pleroma.Web.PleromaAPI.EmojiAPIController do
plug(
OAuthScopesPlug,
plug(
OAuthScopesPlug,
- %{scopes:
Pleroma.Config.oauth_admin_scopes("write")
}
+ %{scopes:
["write"], admin: true
}
when action in [
:create,
:delete,
when action in [
:create,
:delete,
@@
-52,7
+52,7
@@
defmodule Pleroma.Web.PleromaAPI.EmojiAPIController do
@doc """
Lists the packs available on the instance as JSON.
@doc """
Lists the packs available on the instance as JSON.
- The information is public and does not require authenti
fi
cation. The format is
+ The information is public and does not require authentication. The format is
a map of "pack directory name" to pack.json contents.
"""
def list_packs(conn, _params) do
a map of "pack directory name" to pack.json contents.
"""
def list_packs(conn, _params) do
@@
-573,11
+573,14
@@
keeping it in cache for #{div(cache_ms, 1000)}s")
assumed to be emojis and stored in the new `pack.json` file.
"""
def import_from_fs(conn, _params) do
assumed to be emojis and stored in the new `pack.json` file.
"""
def import_from_fs(conn, _params) do
- with {:ok, results} <- File.ls(emoji_dir_path()) do
+ emoji_path = emoji_dir_path()
+
+ with {:ok, %{access: :read_write}} <- File.stat(emoji_path),
+ {:ok, results} <- File.ls(emoji_path) do
imported_pack_names =
results
|> Enum.filter(fn file ->
imported_pack_names =
results
|> Enum.filter(fn file ->
- dir_path = Path.join(emoji_
dir_path()
, file)
+ dir_path = Path.join(emoji_
path
, file)
# Find the directories that do NOT have pack.json
File.dir?(dir_path) and not File.exists?(Path.join(dir_path, "pack.json"))
end)
# Find the directories that do NOT have pack.json
File.dir?(dir_path) and not File.exists?(Path.join(dir_path, "pack.json"))
end)
@@
-585,6
+588,11
@@
keeping it in cache for #{div(cache_ms, 1000)}s")
json(conn, imported_pack_names)
else
json(conn, imported_pack_names)
else
+ {:ok, %{access: _}} ->
+ conn
+ |> put_status(:internal_server_error)
+ |> json(%{error: "Error: emoji pack directory must be writable"})
+
{:error, _} ->
conn
|> put_status(:internal_server_error)
{:error, _} ->
conn
|> put_status(:internal_server_error)