summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/email.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/user/email.go')
-rw-r--r--routers/api/v1/user/email.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go
index 66bddd24cf..fe11954ba7 100644
--- a/routers/api/v1/user/email.go
+++ b/routers/api/v1/user/email.go
@@ -14,10 +14,10 @@ import (
)
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
-func ListEmails(ctx *context.Context) {
+func ListEmails(ctx *context.APIContext) {
emails, err := models.GetEmailAddresses(ctx.User.Id)
if err != nil {
- ctx.Handle(500, "GetEmailAddresses", err)
+ ctx.Error(500, "GetEmailAddresses", err)
return
}
apiEmails := make([]*api.Email, len(emails))
@@ -28,7 +28,7 @@ func ListEmails(ctx *context.Context) {
}
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
-func AddEmail(ctx *context.Context, form api.CreateEmailOption) {
+func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
if len(form.Emails) == 0 {
ctx.Status(422)
return
@@ -45,9 +45,9 @@ func AddEmail(ctx *context.Context, form api.CreateEmailOption) {
if err := models.AddEmailAddresses(emails); err != nil {
if models.IsErrEmailAlreadyUsed(err) {
- ctx.APIError(422, "", "Email address has been used: "+err.(models.ErrEmailAlreadyUsed).Email)
+ ctx.Error(422, "", "Email address has been used: "+err.(models.ErrEmailAlreadyUsed).Email)
} else {
- ctx.APIError(500, "AddEmailAddresses", err)
+ ctx.Error(500, "AddEmailAddresses", err)
}
return
}
@@ -60,7 +60,7 @@ func AddEmail(ctx *context.Context, form api.CreateEmailOption) {
}
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
-func DeleteEmail(ctx *context.Context, form api.CreateEmailOption) {
+func DeleteEmail(ctx *context.APIContext, form api.CreateEmailOption) {
if len(form.Emails) == 0 {
ctx.Status(204)
return
@@ -74,7 +74,7 @@ func DeleteEmail(ctx *context.Context, form api.CreateEmailOption) {
}
if err := models.DeleteEmailAddresses(emails); err != nil {
- ctx.APIError(500, "DeleteEmailAddresses", err)
+ ctx.Error(500, "DeleteEmailAddresses", err)
return
}
ctx.Status(204)