aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/email.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-17 02:28:47 -0500
committerUnknwon <u@gogs.io>2015-12-17 02:28:47 -0500
commit9cd16c5b12d093dd694e146d6c845ee4c405c774 (patch)
treed9f1a037ba8ecbc3e5fe2f15f0baec6dec6242b4 /routers/api/v1/user/email.go
parent6673dcb0380aa99da25b4d1d68cf129635fe30d9 (diff)
downloadgitea-9cd16c5b12d093dd694e146d6c845ee4c405c774.tar.gz
gitea-9cd16c5b12d093dd694e146d6c845ee4c405c774.zip
#1692 add organization APIs
Diffstat (limited to 'routers/api/v1/user/email.go')
-rw-r--r--routers/api/v1/user/email.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go
index 449560e782..fd9193bd74 100644
--- a/routers/api/v1/user/email.go
+++ b/routers/api/v1/user/email.go
@@ -10,9 +10,10 @@ import (
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
- to "github.com/gogits/gogs/routers/api/v1/utils"
+ "github.com/gogits/gogs/routers/api/v1/convert"
)
+// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
func ListEmails(ctx *middleware.Context) {
emails, err := models.GetEmailAddresses(ctx.User.Id)
if err != nil {
@@ -21,11 +22,12 @@ func ListEmails(ctx *middleware.Context) {
}
apiEmails := make([]*api.Email, len(emails))
for i := range emails {
- apiEmails[i] = to.ApiEmail(emails[i])
+ apiEmails[i] = convert.ToApiEmail(emails[i])
}
ctx.JSON(200, &apiEmails)
}
+// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) {
if len(form.Emails) == 0 {
ctx.Status(422)
@@ -52,11 +54,12 @@ func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) {
apiEmails := make([]*api.Email, len(emails))
for i := range emails {
- apiEmails[i] = to.ApiEmail(emails[i])
+ apiEmails[i] = convert.ToApiEmail(emails[i])
}
ctx.JSON(201, &apiEmails)
}
+// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
func DeleteEmail(ctx *middleware.Context, form api.CreateEmailOption) {
if len(form.Emails) == 0 {
ctx.Status(204)