support for special chars in pack name

This commit is contained in:
Alexander Strizhakov 2020-06-27 13:43:25 +03:00
commit 9b6d89ff8c
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
7 changed files with 128 additions and 59 deletions

View file

@ -244,7 +244,8 @@ defmodule Pleroma.Emoji.Pack do
uri = url |> String.trim() |> URI.parse()
with :ok <- validate_shareable_packs_available(uri),
{:ok, remote_pack} <- uri |> URI.merge("/api/pleroma/emoji/packs/#{name}") |> http_get(),
{:ok, remote_pack} <-
uri |> URI.merge("/api/pleroma/emoji/packs/show?name=#{name}") |> http_get(),
{:ok, %{sha: sha, url: url} = pack_info} <- fetch_pack_info(remote_pack, uri, name),
{:ok, archive} <- download_archive(url, sha),
pack <- copy_as(remote_pack, as || name),
@ -572,7 +573,7 @@ defmodule Pleroma.Emoji.Pack do
{:ok,
%{
sha: sha,
url: URI.merge(uri, "/api/pleroma/emoji/packs/#{name}/archive") |> to_string()
url: URI.merge(uri, "/api/pleroma/emoji/packs/archive?name=#{name}") |> to_string()
}}
%{"fallback-src" => src, "fallback-src-sha256" => sha} when is_binary(src) ->

View file

@ -192,7 +192,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaEmojiPackOperation do
end
defp name_param do
Operation.parameter(:name, :path, :string, "Pack Name", example: "cofe", required: true)
Operation.parameter(:name, :query, :string, "Pack Name", example: "cofe", required: true)
end
defp url_param do

View file

@ -234,21 +234,21 @@ defmodule Pleroma.Web.Router do
get("/remote", EmojiPackController, :remote)
post("/download", EmojiPackController, :download)
post("/:name", EmojiPackController, :create)
patch("/:name", EmojiPackController, :update)
delete("/:name", EmojiPackController, :delete)
post("/create", EmojiPackController, :create)
patch("/update", EmojiPackController, :update)
delete("/delete", EmojiPackController, :delete)
post("/:name/files", EmojiFileController, :create)
patch("/:name/files", EmojiFileController, :update)
delete("/:name/files", EmojiFileController, :delete)
post("/files", EmojiFileController, :add_file)
patch("/files", EmojiFileController, :update_file)
delete("/files", EmojiFileController, :delete_file)
end
# Pack info / downloading
scope "/packs" do
pipe_through(:api)
get("/", EmojiPackController, :index)
get("/:name", EmojiPackController, :show)
get("/:name/archive", EmojiPackController, :archive)
get("/show", EmojiPackController, :show)
get("/archive", EmojiPackController, :archive)
end
end