commit: 9a27cb4f9d314fe1066f566de71357f55926116e
parent 3fd13b70ec7c8e9faca46550fe02b51ccbeaebd0
Author: Tusooa Zhu <tusooa@kazv.moe>
Date: Wed, 22 Sep 2021 19:27:04 -0400
Deal with target not found error in add_alias
Ref: emit-move
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex b/lib/pleroma/web/api_spec/operations/twitter_util_operation.ex
@@ -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
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -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