diff options
author | Unknwon <u@gogs.io> | 2016-07-24 01:08:22 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-07-24 01:08:22 +0800 |
commit | 1f2e173a745da8e4b57f96b5561a3c10054d3b76 (patch) | |
tree | 367f0f07e4fe1269ac0772e0561a4bf912b5153c /routers/api/v1 | |
parent | 46e96c008cf966428c9dad71c7871de88186e3fe (diff) | |
download | gitea-1f2e173a745da8e4b57f96b5561a3c10054d3b76.tar.gz gitea-1f2e173a745da8e4b57f96b5561a3c10054d3b76.zip |
Refactor User.Id to User.ID
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/admin/org_team.go | 6 | ||||
-rw-r--r-- | routers/api/v1/admin/user.go | 2 | ||||
-rw-r--r-- | routers/api/v1/api.go | 2 | ||||
-rw-r--r-- | routers/api/v1/convert/convert.go | 4 | ||||
-rw-r--r-- | routers/api/v1/org/org.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 8 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 22 | ||||
-rw-r--r-- | routers/api/v1/user/app.go | 4 | ||||
-rw-r--r-- | routers/api/v1/user/email.go | 4 | ||||
-rw-r--r-- | routers/api/v1/user/follower.go | 8 | ||||
-rw-r--r-- | routers/api/v1/user/key.go | 6 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 4 |
12 files changed, 36 insertions, 36 deletions
diff --git a/routers/api/v1/admin/org_team.go b/routers/api/v1/admin/org_team.go index 9b5411b12e..c0f3487e11 100644 --- a/routers/api/v1/admin/org_team.go +++ b/routers/api/v1/admin/org_team.go @@ -15,7 +15,7 @@ import ( func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { team := &models.Team{ - OrgID: ctx.Org.Organization.Id, + OrgID: ctx.Org.Organization.ID, Name: form.Name, Description: form.Description, Authorize: models.ParseAccessMode(form.Permission), @@ -37,7 +37,7 @@ func AddTeamMember(ctx *context.APIContext) { if ctx.Written() { return } - if err := ctx.Org.Team.AddMember(u.Id); err != nil { + if err := ctx.Org.Team.AddMember(u.ID); err != nil { ctx.Error(500, "AddMember", err) return } @@ -51,7 +51,7 @@ func RemoveTeamMember(ctx *context.APIContext) { return } - if err := ctx.Org.Team.RemoveMember(u.Id); err != nil { + if err := ctx.Org.Team.RemoveMember(u.ID); err != nil { ctx.Error(500, "RemoveMember", err) return } diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 4bb24998bb..b282ce3227 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -147,5 +147,5 @@ func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { if ctx.Written() { return } - user.CreateUserPublicKey(ctx, form, u.Id) + user.CreateUserPublicKey(ctx, form, u.ID) } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index a13a1e6885..a0af200749 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -49,7 +49,7 @@ func RepoAssignment() macaron.Handler { ctx.Repo.Owner = owner // Get repository. - repo, err := models.GetRepositoryByName(owner.Id, repoName) + repo, err := models.GetRepositoryByName(owner.ID, repoName) if err != nil { if models.IsErrRepoNotExist(err) { ctx.Status(404) diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 52f28e7dd5..596b450f27 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -23,7 +23,7 @@ func ToUser(u *models.User) *api.User { } return &api.User{ - ID: u.Id, + ID: u.ID, UserName: u.Name, FullName: u.FullName, Email: u.Email, @@ -194,7 +194,7 @@ func ToIssue(issue *models.Issue) *api.Issue { func ToOrganization(org *models.User) *api.Organization { return &api.Organization{ - ID: org.Id, + ID: org.ID, AvatarUrl: org.AvatarLink(), UserName: org.Name, FullName: org.FullName, diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 5b1ea007e3..7b2cfcd1dc 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -48,7 +48,7 @@ func Get(ctx *context.APIContext) { // https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization func Edit(ctx *context.APIContext, form api.EditOrgOption) { org := ctx.Org.Organization - if !org.IsOwnedBy(ctx.User.Id) { + if !org.IsOwnedBy(ctx.User.ID) { ctx.Status(403) return } diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index a3f69d3f81..b105b6816c 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -53,7 +53,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { issue := &models.Issue{ RepoID: ctx.Repo.Repository.ID, Name: form.Title, - PosterID: ctx.User.Id, + PosterID: ctx.User.ID, Poster: ctx.User, Content: form.Body, } @@ -69,7 +69,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { } return } - issue.AssigneeID = assignee.Id + issue.AssigneeID = assignee.ID } issue.MilestoneID = form.Milestone } else { @@ -109,7 +109,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { return } - if !issue.IsPoster(ctx.User.Id) && !ctx.Repo.IsWriter() { + if !issue.IsPoster(ctx.User.ID) && !ctx.Repo.IsWriter() { ctx.Status(403) return } @@ -135,7 +135,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { } return } - issue.AssigneeID = assignee.Id + issue.AssigneeID = assignee.ID } if err = models.UpdateIssueUserByAssignee(issue); err != nil { diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 222098ac66..679ebb09d4 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -27,7 +27,7 @@ func Search(ctx *context.APIContext) { // Check visibility. if ctx.IsSigned && opts.OwnerID > 0 { - if ctx.User.Id == opts.OwnerID { + if ctx.User.ID == opts.OwnerID { opts.Private = true } else { u, err := models.GetUserByID(opts.OwnerID) @@ -38,7 +38,7 @@ func Search(ctx *context.APIContext) { }) return } - if u.IsOrganization() && u.IsOwnedBy(ctx.User.Id) { + if u.IsOrganization() && u.IsOwnedBy(ctx.User.ID) { opts.Private = true } // FIXME: how about collaborators? @@ -78,7 +78,7 @@ func Search(ctx *context.APIContext) { // https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories func ListMyRepos(ctx *context.APIContext) { - ownRepos, err := models.GetRepositories(ctx.User.Id, true) + ownRepos, err := models.GetRepositories(ctx.User.ID, true) if err != nil { ctx.Error(500, "GetRepositories", err) return @@ -126,7 +126,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR ctx.Error(422, "", err) } else { if repo != nil { - if err = models.DeleteRepository(ctx.User.Id, repo.ID); err != nil { + if err = models.DeleteRepository(ctx.User.ID, repo.ID); err != nil { log.Error(4, "DeleteRepository: %v", err) } } @@ -159,7 +159,7 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { return } - if !org.IsOwnedBy(ctx.User.Id) { + if !org.IsOwnedBy(ctx.User.ID) { ctx.Error(403, "", "Given user is not owner of organization.") return } @@ -171,7 +171,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { ctxUser := ctx.User // Not equal means context user is an organization, // or is another user/organization if current user is admin. - if form.Uid != ctxUser.Id { + if form.Uid != ctxUser.ID { org, err := models.GetUserByID(form.Uid) if err != nil { if models.IsErrUserNotExist(err) { @@ -191,7 +191,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { if ctxUser.IsOrganization() && !ctx.User.IsAdmin { // Check ownership of organization. - if !ctxUser.IsOwnedBy(ctx.User.Id) { + if !ctxUser.IsOwnedBy(ctx.User.ID) { ctx.Error(403, "", "Given user is not owner of organization.") return } @@ -226,7 +226,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { }) if err != nil { if repo != nil { - if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil { + if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { log.Error(4, "DeleteRepository: %v", errDelete) } } @@ -249,7 +249,7 @@ func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repositor return nil, nil } - repo, err := models.GetRepositoryByName(owner.Id, ctx.Params(":reponame")) + repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame")) if err != nil { if models.IsErrRepoNotExist(err) { ctx.Status(404) @@ -279,12 +279,12 @@ func Delete(ctx *context.APIContext) { return } - if owner.IsOrganization() && !owner.IsOwnedBy(ctx.User.Id) { + if owner.IsOrganization() && !owner.IsOwnedBy(ctx.User.ID) { ctx.Error(403, "", "Given user is not owner of organization.") return } - if err := models.DeleteRepository(owner.Id, repo.ID); err != nil { + if err := models.DeleteRepository(owner.ID, repo.ID); err != nil { ctx.Error(500, "DeleteRepository", err) return } diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index da030e9839..165f6eb8ec 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -13,7 +13,7 @@ import ( // 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) + tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { ctx.Error(500, "ListAccessTokens", err) return @@ -29,7 +29,7 @@ func ListAccessTokens(ctx *context.APIContext) { // 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, + UID: ctx.User.ID, Name: form.Name, } if err := models.NewAccessToken(t); err != nil { diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index 6a3d525cce..1f615cdff3 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -15,7 +15,7 @@ import ( // 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) + emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { ctx.Error(500, "GetEmailAddresses", err) return @@ -37,7 +37,7 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { emails := make([]*models.EmailAddress, len(form.Emails)) for i := range form.Emails { emails[i] = &models.EmailAddress{ - UID: ctx.User.Id, + UID: ctx.User.ID, Email: form.Emails[i], IsActivated: !setting.Service.RegisterEmailConfirm, } diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index 00d1952d59..8d103c9e14 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -78,7 +78,7 @@ func CheckMyFollowing(ctx *context.APIContext) { if ctx.Written() { return } - checkUserFollowing(ctx, ctx.User, target.Id) + checkUserFollowing(ctx, ctx.User, target.ID) } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another @@ -91,7 +91,7 @@ func CheckFollowing(ctx *context.APIContext) { if ctx.Written() { return } - checkUserFollowing(ctx, u, target.Id) + checkUserFollowing(ctx, u, target.ID) } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user @@ -100,7 +100,7 @@ func Follow(ctx *context.APIContext) { if ctx.Written() { return } - if err := models.FollowUser(ctx.User.Id, target.Id); err != nil { + if err := models.FollowUser(ctx.User.ID, target.ID); err != nil { ctx.Error(500, "FollowUser", err) return } @@ -113,7 +113,7 @@ func Unfollow(ctx *context.APIContext) { if ctx.Written() { return } - if err := models.UnfollowUser(ctx.User.Id, target.Id); err != nil { + if err := models.UnfollowUser(ctx.User.ID, target.ID); err != nil { ctx.Error(500, "UnfollowUser", err) return } diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 7337112ece..3e407feff8 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -54,7 +54,7 @@ func listPublicKeys(ctx *context.APIContext, uid int64) { // 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) + listPublicKeys(ctx, ctx.User.ID) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user @@ -63,7 +63,7 @@ func ListPublicKeys(ctx *context.APIContext) { if ctx.Written() { return } - listPublicKeys(ctx, user.Id) + listPublicKeys(ctx, user.ID) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key @@ -101,7 +101,7 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid // 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) + CreateUserPublicKey(ctx, form, ctx.User.ID) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index b460d942b7..98571ae69d 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -36,7 +36,7 @@ func Search(ctx *context.APIContext) { results := make([]*api.User, len(users)) for i := range users { results[i] = &api.User{ - ID: users[i].Id, + ID: users[i].ID, UserName: users[i].Name, AvatarUrl: users[i].AvatarLink(), FullName: users[i].FullName, @@ -68,5 +68,5 @@ func GetInfo(ctx *context.APIContext) { if !ctx.IsSigned { u.Email = "" } - ctx.JSON(200, &api.User{u.Id, u.Name, u.FullName, u.Email, u.AvatarLink()}) + ctx.JSON(200, &api.User{u.ID, u.Name, u.FullName, u.Email, u.AvatarLink()}) } |