Deal with target not found error in add_alias

Ref: emit-move
This commit is contained in:
Tusooa Zhu 2021-09-22 19:27:04 -04:00 committed by Sol Fisher Romanoff
parent 5d2da84305
commit 467c45ffa6
Signed by: nbsp
GPG Key ID: 9D3F2B64F2341B62
2 changed files with 7 additions and 1 deletions

View File

@ -293,7 +293,8 @@ defmodule Pleroma.Web.ApiSpec.TwitterUtilOperation do
}
}),
400 => Operation.response("Error", "application/json", ApiError),
403 => Operation.response("Error", "application/json", ApiError)
403 => Operation.response("Error", "application/json", ApiError),
404 => Operation.response("Error", "application/json", ApiError)
}
}
end

View File

@ -196,6 +196,11 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
{:ok, _user} <- user |> User.add_alias(alias_user) do
json(conn, %{status: "success"})
else
{:not_found, _} ->
conn
|> put_status(404)
|> json(%{error: "Target account does not exist."})
{:error, error} ->
json(conn, %{error: error})
end