diff options
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r-- | routers/api/v1/user/app.go | 6 | ||||
-rw-r--r-- | routers/api/v1/user/email.go | 9 | ||||
-rw-r--r-- | routers/api/v1/user/follower.go | 26 | ||||
-rw-r--r-- | routers/api/v1/user/key.go | 16 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 3 |
5 files changed, 41 insertions, 19 deletions
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index e678aaff53..2955f78a77 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -11,7 +11,8 @@ import ( "code.gitea.io/gitea/modules/context" ) -// https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user +// ListAccessTokens list all the access tokens +// see https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user func ListAccessTokens(ctx *context.APIContext) { tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { @@ -26,7 +27,8 @@ func ListAccessTokens(ctx *context.APIContext) { ctx.JSON(200, &apiTokens) } -// https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token +// CreateAccessToken create access tokens +// see https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) { t := &models.AccessToken{ UID: ctx.User.ID, diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index 2503d01a44..f42fc11cf6 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -13,7 +13,8 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user +// ListEmails list all the emails of mine +// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user func ListEmails(ctx *context.APIContext) { emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { @@ -27,7 +28,8 @@ func ListEmails(ctx *context.APIContext) { ctx.JSON(200, &apiEmails) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses +// AddEmail add email for me +// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { if len(form.Emails) == 0 { ctx.Status(422) @@ -59,7 +61,8 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { ctx.JSON(201, &apiEmails) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses +// DeleteEmail delete email +// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses func DeleteEmail(ctx *context.APIContext, form api.CreateEmailOption) { if len(form.Emails) == 0 { ctx.Status(204) diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index 594c365177..ff043c9de9 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" ) -func responseApiUsers(ctx *context.APIContext, users []*models.User) { +func responseAPIUsers(ctx *context.APIContext, users []*models.User) { apiUsers := make([]*api.User, len(users)) for i := range users { apiUsers[i] = users[i].APIFormat() @@ -25,14 +25,16 @@ func listUserFollowers(ctx *context.APIContext, u *models.User) { ctx.Error(500, "GetUserFollowers", err) return } - responseApiUsers(ctx, users) + responseAPIUsers(ctx, users) } +// ListMyFollowers list all my followers func ListMyFollowers(ctx *context.APIContext) { listUserFollowers(ctx, ctx.User) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user +// ListFollowers list user's followers +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user func ListFollowers(ctx *context.APIContext) { u := GetUserByParams(ctx) if ctx.Written() { @@ -47,14 +49,16 @@ func listUserFollowing(ctx *context.APIContext, u *models.User) { ctx.Error(500, "GetFollowing", err) return } - responseApiUsers(ctx, users) + responseAPIUsers(ctx, users) } +// ListMyFollowing list all my followings func ListMyFollowing(ctx *context.APIContext) { listUserFollowing(ctx, ctx.User) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user +// ListFollowing list user's followings +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user func ListFollowing(ctx *context.APIContext) { u := GetUserByParams(ctx) if ctx.Written() { @@ -71,7 +75,8 @@ func checkUserFollowing(ctx *context.APIContext, u *models.User, followID int64) } } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user +// CheckMyFollowing check if the repo is followed by me +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user func CheckMyFollowing(ctx *context.APIContext) { target := GetUserByParams(ctx) if ctx.Written() { @@ -80,7 +85,8 @@ func CheckMyFollowing(ctx *context.APIContext) { checkUserFollowing(ctx, ctx.User, target.ID) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another +// CheckFollowing check if the repo is followed by user +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another func CheckFollowing(ctx *context.APIContext) { u := GetUserByParams(ctx) if ctx.Written() { @@ -93,7 +99,8 @@ func CheckFollowing(ctx *context.APIContext) { checkUserFollowing(ctx, u, target.ID) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user +// Follow follow one repository +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user func Follow(ctx *context.APIContext) { target := GetUserByParams(ctx) if ctx.Written() { @@ -106,7 +113,8 @@ func Follow(ctx *context.APIContext) { ctx.Status(204) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user +// Unfollow unfollow one repository +// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user func Unfollow(ctx *context.APIContext) { target := GetUserByParams(ctx) if ctx.Written() { diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 6df405a16c..c743b5deab 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/routers/api/v1/repo" ) +// GetUserByParamsName get user by name func GetUserByParamsName(ctx *context.APIContext, name string) *models.User { user, err := models.GetUserByName(ctx.Params(name)) if err != nil { @@ -52,12 +53,14 @@ func listPublicKeys(ctx *context.APIContext, uid int64) { ctx.JSON(200, &apiKeys) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys +// ListMyPublicKeys list all my public keys +// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys func ListMyPublicKeys(ctx *context.APIContext) { listPublicKeys(ctx, ctx.User.ID) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user +// ListPublicKeys list all user's public keys +// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user func ListPublicKeys(ctx *context.APIContext) { user := GetUserByParams(ctx) if ctx.Written() { @@ -66,7 +69,8 @@ func ListPublicKeys(ctx *context.APIContext) { listPublicKeys(ctx, user.ID) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key +// GetPublicKey get one public key +// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key func GetPublicKey(ctx *context.APIContext) { key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id")) if err != nil { @@ -99,12 +103,14 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid ctx.JSON(201, convert.ToPublicKey(apiLink, key)) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key +// CreatePublicKey create one public key for me +// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { CreateUserPublicKey(ctx, form, ctx.User.ID) } -// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key +// DeletePublicKey delete one public key of mine +// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key func DeletePublicKey(ctx *context.APIContext) { if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrKeyAccessDenied(err) { diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index c6a454cc4a..ef0a5b212e 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// Search search users func Search(ctx *context.APIContext) { opts := &models.SearchUserOptions{ Keyword: ctx.Query("q"), @@ -51,6 +52,7 @@ func Search(ctx *context.APIContext) { }) } +// GetInfo get user's information func GetInfo(ctx *context.APIContext) { u, err := models.GetUserByName(ctx.Params(":username")) if err != nil { @@ -69,6 +71,7 @@ func GetInfo(ctx *context.APIContext) { ctx.JSON(200, u.APIFormat()) } +// GetAuthenticatedUser get curent user's information func GetAuthenticatedUser(ctx *context.APIContext) { ctx.JSON(200, ctx.User.APIFormat()) } |