From 9d16393d8b0cf2e177001874b4f6c01e9591fa83 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 30 Jan 2024 19:12:29 -0500 Subject: [PATCH] Pleroma.Web.PleromaAPI.EmojiPackController: fix dialyzer errors with replace_params: false --- .../controllers/emoji_pack_controller.ex | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex b/lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex index 420fea12c..32360d2a2 100644 --- a/lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex @@ -7,7 +7,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackController do alias Pleroma.Emoji.Pack - plug(Pleroma.Web.ApiSpec.CastAndValidate) + plug(Pleroma.Web.ApiSpec.CastAndValidate, replace_params: false) plug( Pleroma.Web.Plugs.OAuthScopesPlug, @@ -26,7 +26,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackController do 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} <- Pack.list_remote(url: params.url, page_size: params.page_size, page: params.page) do json(conn, packs) @@ -38,7 +38,7 @@ def remote(conn, params) do end end - def index(conn, params) do + def index(%{private: %{open_api_spex: %{params: params}}} = conn, _) do emoji_path = [:instance, :static_dir] |> Pleroma.Config.get!() @@ -61,7 +61,11 @@ def index(conn, params) do 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) 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 - 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 send_download(conn, {:binary, archive}, filename: "#{name}.zip") else @@ -109,7 +113,10 @@ def archive(conn, %{name: name}) do 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 json(conn, "ok") else @@ -130,7 +137,7 @@ def download(%{body_params: %{url: url, name: name} = params} = conn, _) do end end - def create(conn, %{name: name}) do + def create(%{private: %{open_api_spex: %{params: %{name: name}}}} = conn, _) do name = String.trim(name) with {:ok, _pack} <- Pack.create(name) do @@ -159,7 +166,7 @@ def create(conn, %{name: name}) do end end - def delete(conn, %{name: name}) do + def delete(%{private: %{open_api_spex: %{params: %{name: name}}}} = conn, _) do name = String.trim(name) with {:ok, deleted} when deleted != [] <- Pack.delete(name) do @@ -184,7 +191,11 @@ def delete(conn, %{name: name}) do 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 json(conn, pack.pack) else