Pleroma.Web.TwitterAPI.UtilController: fix dialyzer errors with replace_params: false
This commit is contained in:
parent
b8db67dafa
commit
225afe05b3
|
@ -18,7 +18,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
||||||
alias Pleroma.Web.WebFinger
|
alias Pleroma.Web.WebFinger
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
Pleroma.Web.ApiSpec.CastAndValidate
|
Pleroma.Web.ApiSpec.CastAndValidate,
|
||||||
|
[replace_params: false]
|
||||||
when action != :remote_subscribe and action != :show_subscribe_form
|
when action != :remote_subscribe and action != :show_subscribe_form
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -150,7 +151,10 @@ def remote_subscribe(conn, %{"status" => %{"status_id" => id, "profile" => profi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_interaction(%{body_params: %{ap_id: ap_id, profile: profile}} = conn, _params) do
|
def remote_interaction(
|
||||||
|
%{private: %{open_api_spex: %{body_params: %{ap_id: ap_id, profile: profile}}}} = conn,
|
||||||
|
_params
|
||||||
|
) do
|
||||||
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile) do
|
with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile) do
|
||||||
conn
|
conn
|
||||||
|> json(%{url: String.replace(template, "{uri}", ap_id)})
|
|> json(%{url: String.replace(template, "{uri}", ap_id)})
|
||||||
|
@ -187,7 +191,10 @@ def update_notification_settings(%{assigns: %{user: user}} = conn, params) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_password(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
|
def change_password(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
||||||
{:ok, user} ->
|
{:ok, user} ->
|
||||||
with {:ok, _user} <-
|
with {:ok, _user} <-
|
||||||
|
@ -210,7 +217,10 @@ def change_password(%{assigns: %{user: user}, body_params: body_params} = conn,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_email(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
|
def change_email(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
||||||
{:ok, user} ->
|
{:ok, user} ->
|
||||||
with {:ok, _user} <- User.change_email(user, body_params.email) do
|
with {:ok, _user} <- User.change_email(user, body_params.email) do
|
||||||
|
@ -229,7 +239,13 @@ def change_email(%{assigns: %{user: user}, body_params: body_params} = conn, %{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_account(%{assigns: %{user: user}, body_params: body_params} = conn, params) do
|
def delete_account(
|
||||||
|
%{
|
||||||
|
assigns: %{user: user},
|
||||||
|
private: %{open_api_spex: %{body_params: body_params, params: params}}
|
||||||
|
} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
# This endpoint can accept a query param or JSON body for backwards-compatibility.
|
# This endpoint can accept a query param or JSON body for backwards-compatibility.
|
||||||
# Submitting a JSON body is recommended, so passwords don't end up in server logs.
|
# Submitting a JSON body is recommended, so passwords don't end up in server logs.
|
||||||
password = body_params[:password] || params[:password] || ""
|
password = body_params[:password] || params[:password] || ""
|
||||||
|
@ -244,7 +260,10 @@ def delete_account(%{assigns: %{user: user}, body_params: body_params} = conn, p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_account(%{assigns: %{user: user}} = conn, params) do
|
def disable_account(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{params: params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
case CommonAPI.Utils.confirm_current_password(user, params[:password]) do
|
case CommonAPI.Utils.confirm_current_password(user, params[:password]) do
|
||||||
{:ok, user} ->
|
{:ok, user} ->
|
||||||
User.set_activation_async(user, false)
|
User.set_activation_async(user, false)
|
||||||
|
@ -255,7 +274,10 @@ def disable_account(%{assigns: %{user: user}} = conn, params) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_account(%{assigns: %{user: user}, body_params: body_params} = conn, %{}) do
|
def move_account(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
case CommonAPI.Utils.confirm_current_password(user, body_params.password) do
|
||||||
{:ok, user} ->
|
{:ok, user} ->
|
||||||
with {:ok, target_user} <- find_or_fetch_user_by_nickname(body_params.target_account),
|
with {:ok, target_user} <- find_or_fetch_user_by_nickname(body_params.target_account),
|
||||||
|
@ -276,7 +298,10 @@ def move_account(%{assigns: %{user: user}, body_params: body_params} = conn, %{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _) do
|
def add_alias(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
|
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
|
||||||
{:ok, _user} <- user |> User.add_alias(alias_user) do
|
{:ok, _user} <- user |> User.add_alias(alias_user) do
|
||||||
json(conn, %{status: "success"})
|
json(conn, %{status: "success"})
|
||||||
|
@ -291,7 +316,10 @@ def add_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _) do
|
def delete_alias(
|
||||||
|
%{assigns: %{user: user}, private: %{open_api_spex: %{body_params: body_params}}} = conn,
|
||||||
|
_
|
||||||
|
) do
|
||||||
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
|
with {:ok, alias_user} <- find_user_by_nickname(body_params.alias),
|
||||||
{:ok, _user} <- user |> User.delete_alias(alias_user) do
|
{:ok, _user} <- user |> User.delete_alias(alias_user) do
|
||||||
json(conn, %{status: "success"})
|
json(conn, %{status: "success"})
|
||||||
|
@ -306,7 +334,7 @@ def delete_alias(%{assigns: %{user: user}, body_params: body_params} = conn, _)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_aliases(%{assigns: %{user: user}} = conn, %{}) do
|
def list_aliases(%{assigns: %{user: user}} = conn, _) do
|
||||||
alias_nicks =
|
alias_nicks =
|
||||||
user
|
user
|
||||||
|> User.alias_users()
|
|> User.alias_users()
|
||||||
|
|
Loading…
Reference in New Issue