forked from forgejo/forgejo
rsponse 404 when delete not exist email (#15383)
fix #15357 Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
9a0858cecf
commit
e375cbfd46
5 changed files with 130 additions and 5 deletions
|
@ -111,6 +111,8 @@ func DeleteEmail(ctx *context.APIContext) {
|
|||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
form := web.GetForm(ctx).(*api.DeleteEmailOption)
|
||||
if len(form.Emails) == 0 {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
|
@ -126,6 +128,10 @@ func DeleteEmail(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
if err := models.DeleteEmailAddresses(emails); err != nil {
|
||||
if models.IsErrEmailAddressNotExist(err) {
|
||||
ctx.Error(http.StatusNotFound, "DeleteEmailAddresses", err)
|
||||
return
|
||||
}
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteEmailAddresses", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue