Pleroma.Web.PleromaAPI.EmojiPackController: fix dialyzer errors with replace_params: false

This commit is contained in:
Mark Felder 2024-01-30 19:12:29 -05:00
parent f1aeb80518
commit 9d16393d8b
1 changed files with 20 additions and 9 deletions

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackController do
alias Pleroma.Emoji.Pack alias Pleroma.Emoji.Pack
plug(Pleroma.Web.ApiSpec.CastAndValidate) plug(Pleroma.Web.ApiSpec.CastAndValidate, replace_params: false)
plug( plug(
Pleroma.Web.Plugs.OAuthScopesPlug, Pleroma.Web.Plugs.OAuthScopesPlug,
@ -26,7 +26,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackController do
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaEmojiPackOperation defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaEmojiPackOperation
def remote(conn, params) do def remote(%{private: %{open_api_spex: %{params: params}}} = conn, _) do
with {:ok, packs} <- with {:ok, packs} <-
Pack.list_remote(url: params.url, page_size: params.page_size, page: params.page) do Pack.list_remote(url: params.url, page_size: params.page_size, page: params.page) do
json(conn, packs) json(conn, packs)
@ -38,7 +38,7 @@ def remote(conn, params) do
end end
end end
def index(conn, params) do def index(%{private: %{open_api_spex: %{params: params}}} = conn, _) do
emoji_path = emoji_path =
[:instance, :static_dir] [:instance, :static_dir]
|> Pleroma.Config.get!() |> Pleroma.Config.get!()
@ -61,7 +61,11 @@ def index(conn, params) do
end end
end end
def show(conn, %{name: name, page: page, page_size: page_size}) do def show(
%{private: %{open_api_spex: %{params: %{name: name, page: page, page_size: page_size}}}} =
conn,
_
) do
name = String.trim(name) name = String.trim(name)
with {:ok, pack} <- Pack.show(name: name, page: page, page_size: page_size) do with {:ok, pack} <- Pack.show(name: name, page: page, page_size: page_size) do
@ -90,7 +94,7 @@ def show(conn, %{name: name, page: page, page_size: page_size}) do
end end
end end
def archive(conn, %{name: name}) do def archive(%{private: %{open_api_spex: %{params: %{name: name}}}} = conn, _) do
with {:ok, archive} <- Pack.get_archive(name) do with {:ok, archive} <- Pack.get_archive(name) do
send_download(conn, {:binary, archive}, filename: "#{name}.zip") send_download(conn, {:binary, archive}, filename: "#{name}.zip")
else else
@ -109,7 +113,10 @@ def archive(conn, %{name: name}) do
end end
end end
def download(%{body_params: %{url: url, name: name} = params} = conn, _) do def download(
%{private: %{open_api_spex: %{body_params: %{url: url, name: name} = params}}} = conn,
_
) do
with {:ok, _pack} <- Pack.download(name, url, params[:as]) do with {:ok, _pack} <- Pack.download(name, url, params[:as]) do
json(conn, "ok") json(conn, "ok")
else else
@ -130,7 +137,7 @@ def download(%{body_params: %{url: url, name: name} = params} = conn, _) do
end end
end end
def create(conn, %{name: name}) do def create(%{private: %{open_api_spex: %{params: %{name: name}}}} = conn, _) do
name = String.trim(name) name = String.trim(name)
with {:ok, _pack} <- Pack.create(name) do with {:ok, _pack} <- Pack.create(name) do
@ -159,7 +166,7 @@ def create(conn, %{name: name}) do
end end
end end
def delete(conn, %{name: name}) do def delete(%{private: %{open_api_spex: %{params: %{name: name}}}} = conn, _) do
name = String.trim(name) name = String.trim(name)
with {:ok, deleted} when deleted != [] <- Pack.delete(name) do with {:ok, deleted} when deleted != [] <- Pack.delete(name) do
@ -184,7 +191,11 @@ def delete(conn, %{name: name}) do
end end
end end
def update(%{body_params: %{metadata: metadata}} = conn, %{name: name}) do def update(
%{private: %{open_api_spex: %{body_params: %{metadata: metadata}, params: %{name: name}}}} =
conn,
_
) do
with {:ok, pack} <- Pack.update_metadata(name, metadata) do with {:ok, pack} <- Pack.update_metadata(name, metadata) do
json(conn, pack.pack) json(conn, pack.pack)
else else