Add a way to create emoji packs via an endpoint
This commit is contained in:
parent
6b4a144e4d
commit
f5131540dc
3 changed files with 56 additions and 0 deletions
|
|
@ -211,6 +211,27 @@ keeping it in cache for #{div(cache_ms, 1000)}s")
|
|||
end
|
||||
end
|
||||
|
||||
def create(conn, %{"name" => name}) do
|
||||
pack_dir = Path.join(@emoji_dir_path, name)
|
||||
|
||||
unless File.exists?(pack_dir) do
|
||||
File.mkdir_p!(pack_dir)
|
||||
|
||||
pack_file_p = Path.join(pack_dir, "pack.json")
|
||||
|
||||
File.write!(
|
||||
pack_file_p,
|
||||
Jason.encode!(%{pack: %{}, files: %{}})
|
||||
)
|
||||
|
||||
conn |> text("ok")
|
||||
else
|
||||
conn
|
||||
|> put_status(:conflict)
|
||||
|> text("A pack named \"#{name}\" already exists")
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"name" => name}) do
|
||||
pack_dir = Path.join(@emoji_dir_path, name)
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ defmodule Pleroma.Web.Router do
|
|||
|
||||
post("/update_file/:pack_name", EmojiAPIController, :update_file)
|
||||
post("/update_metadata/:pack_name", EmojiAPIController, :update_metadata)
|
||||
post("/create/:name", EmojiAPIController, :create)
|
||||
delete("/delete/:name", EmojiAPIController, :delete)
|
||||
post("/download_from", EmojiAPIController, :download_from)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue