diff options
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/admin/orgs.go | 2 | ||||
-rw-r--r-- | routers/api/v1/admin/users.go | 4 | ||||
-rw-r--r-- | routers/api/v1/api.go | 24 | ||||
-rw-r--r-- | routers/api/v1/convert/convert.go | 113 | ||||
-rw-r--r-- | routers/api/v1/org/org.go | 6 | ||||
-rw-r--r-- | routers/api/v1/repo/branch.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/hooks.go | 7 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 165 | ||||
-rw-r--r-- | routers/api/v1/repo/keys.go | 6 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 12 | ||||
-rw-r--r-- | routers/api/v1/user/email.go | 4 | ||||
-rw-r--r-- | routers/api/v1/user/followers.go | 2 | ||||
-rw-r--r-- | routers/api/v1/user/keys.go | 6 |
13 files changed, 292 insertions, 63 deletions
diff --git a/routers/api/v1/admin/orgs.go b/routers/api/v1/admin/orgs.go index 1e7ad15657..fcce3b9314 100644 --- a/routers/api/v1/admin/orgs.go +++ b/routers/api/v1/admin/orgs.go @@ -40,5 +40,5 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { return } - ctx.JSON(201, convert.ToApiOrganization(org)) + ctx.JSON(201, convert.ToOrganization(org)) } diff --git a/routers/api/v1/admin/users.go b/routers/api/v1/admin/users.go index 50409cff94..ce13804ffb 100644 --- a/routers/api/v1/admin/users.go +++ b/routers/api/v1/admin/users.go @@ -69,7 +69,7 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { mailer.SendRegisterNotifyMail(ctx.Context.Context, u) } - ctx.JSON(201, convert.ToApiUser(u)) + ctx.JSON(201, convert.ToUser(u)) } // https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user @@ -118,7 +118,7 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) { } log.Trace("Account profile updated by admin (%s): %s", ctx.User.Name, u.Name) - ctx.JSON(200, convert.ToApiUser(u)) + ctx.JSON(200, convert.ToUser(u)) } // https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index a75910b8a2..59625efdf1 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -62,16 +62,18 @@ func RepoAssignment() macaron.Handler { return } - mode, err := models.AccessLevel(ctx.User, repo) - if err != nil { - ctx.Error(500, "AccessLevel", err) - return + if ctx.IsSigned && ctx.User.IsAdmin { + ctx.Repo.AccessMode = models.ACCESS_MODE_OWNER + } else { + mode, err := models.AccessLevel(ctx.User, repo) + if err != nil { + ctx.Error(500, "AccessLevel", err) + return + } + ctx.Repo.AccessMode = mode } - ctx.Repo.AccessMode = mode - - // Check access. - if ctx.Repo.AccessMode == models.ACCESS_MODE_NONE { + if !ctx.Repo.HasAccess() { ctx.Status(404) return } @@ -193,9 +195,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Combo("/:id").Get(repo.GetDeployKey). Delete(repo.DeleteDeploykey) }) - m.Group("/issue", func() { - m.Combo("").Get().Post() - m.Combo("/:index").Get().Patch() + m.Group("/issues", func() { + m.Combo("").Get(repo.ListIssues).Post(bind(api.CreateIssueOption{}), repo.CreateIssue) + m.Combo("/:index").Get(repo.GetIssue).Patch(bind(api.EditIssueOption{}), repo.EditIssue) }) }, RepoAssignment()) }, ReqToken()) diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 57b3d44e2c..7e3e380bd8 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -9,15 +9,19 @@ import ( "github.com/Unknwon/com" - api "github.com/gogits/go-gogs-client" "github.com/gogits/git-module" + api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/setting" ) -// ToApiUser converts user to its API format. -func ToApiUser(u *models.User) *api.User { +func ToUser(u *models.User) *api.User { + if u == nil { + return nil + } + return &api.User{ ID: u.Id, UserName: u.Name, @@ -27,7 +31,7 @@ func ToApiUser(u *models.User) *api.User { } } -func ToApiEmail(email *models.EmailAddress) *api.Email { +func ToEmail(email *models.EmailAddress) *api.Email { return &api.Email{ Email: email.Email, Verified: email.IsActivated, @@ -35,12 +39,11 @@ func ToApiEmail(email *models.EmailAddress) *api.Email { } } -// ToApiRepository converts repository to API format. -func ToApiRepository(owner *models.User, repo *models.Repository, permission api.Permission) *api.Repository { +func ToRepository(owner *models.User, repo *models.Repository, permission api.Permission) *api.Repository { cl := repo.CloneLink() return &api.Repository{ - Id: repo.ID, - Owner: *ToApiUser(owner), + ID: repo.ID, + Owner: ToUser(owner), FullName: owner.Name + "/" + repo.Name, Private: repo.IsPrivate, Fork: repo.IsFork, @@ -51,30 +54,27 @@ func ToApiRepository(owner *models.User, repo *models.Repository, permission api } } -// ToApiBranch converts user to its API format. -func ToApiBranch(b *models.Branch,c *git.Commit) *api.Branch { +func ToBranch(b *models.Branch, c *git.Commit) *api.Branch { return &api.Branch{ - Name: b.Name, - Commit: ToApiCommit(c), - } + Name: b.Name, + Commit: ToCommit(c), + } } -// ToApiCommit converts user to its API format. -func ToApiCommit(c *git.Commit) *api.PayloadCommit { +func ToCommit(c *git.Commit) *api.PayloadCommit { return &api.PayloadCommit{ - ID: c.ID.String(), + ID: c.ID.String(), Message: c.Message(), - URL: "Not implemented", + URL: "Not implemented", Author: &api.PayloadAuthor{ - Name: c.Committer.Name, + Name: c.Committer.Name, Email: c.Committer.Email, /* UserName: c.Committer.UserName, */ }, } } -// ToApiPublicKey converts public key to its API format. -func ToApiPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey { +func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey { return &api.PublicKey{ ID: key.ID, Key: key.Content, @@ -84,8 +84,7 @@ func ToApiPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey { } } -// ToApiHook converts webhook to its API format. -func ToApiHook(repoLink string, w *models.Webhook) *api.Hook { +func ToHook(repoLink string, w *models.Webhook) *api.Hook { config := map[string]string{ "url": w.URL, "content_type": w.ContentType.Name(), @@ -110,8 +109,7 @@ func ToApiHook(repoLink string, w *models.Webhook) *api.Hook { } } -// ToApiDeployKey converts deploy key to its API format. -func ToApiDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey { +func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey { return &api.DeployKey{ ID: key.ID, Key: key.Content, @@ -122,7 +120,72 @@ func ToApiDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey { } } -func ToApiOrganization(org *models.User) *api.Organization { +func ToLabel(label *models.Label) *api.Label { + return &api.Label{ + Name: label.Name, + Color: label.Color, + } +} + +func ToMilestone(milestone *models.Milestone) *api.Milestone { + if milestone == nil { + return nil + } + + apiMilestone := &api.Milestone{ + ID: milestone.ID, + State: milestone.State(), + Title: milestone.Name, + Description: milestone.Content, + OpenIssues: milestone.NumOpenIssues, + ClosedIssues: milestone.NumClosedIssues, + } + if milestone.IsClosed { + apiMilestone.Closed = &milestone.ClosedDate + } + if milestone.Deadline.Year() < 9999 { + apiMilestone.Deadline = &milestone.Deadline + } + return apiMilestone +} + +func ToIssue(issue *models.Issue) *api.Issue { + apiLabels := make([]*api.Label, len(issue.Labels)) + for i := range issue.Labels { + apiLabels[i] = ToLabel(issue.Labels[i]) + } + + apiIssue := &api.Issue{ + ID: issue.ID, + Index: issue.Index, + State: issue.State(), + Title: issue.Name, + Body: issue.Content, + User: ToUser(issue.Poster), + Labels: apiLabels, + Assignee: ToUser(issue.Assignee), + Milestone: ToMilestone(issue.Milestone), + Comments: issue.NumComments, + Created: issue.Created, + Updated: issue.Updated, + } + if issue.IsPull { + if err := issue.GetPullRequest(); err != nil { + log.Error(4, "GetPullRequest", err) + } else { + apiIssue.PullRequest = &api.PullRequestMeta{ + HasMerged: issue.PullRequest.HasMerged, + } + if issue.PullRequest.HasMerged { + apiIssue.PullRequest.Merged = &issue.PullRequest.Merged + } + } + } + + return apiIssue +} + +func ToOrganization(org *models.User) *api.Organization { return &api.Organization{ ID: org.Id, AvatarUrl: org.AvatarLink(), diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 4fdc5e96a3..b4e52d4862 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -21,7 +21,7 @@ func listUserOrgs(ctx *context.APIContext, u *models.User, all bool) { apiOrgs := make([]*api.Organization, len(u.Orgs)) for i := range u.Orgs { - apiOrgs[i] = convert.ToApiOrganization(u.Orgs[i]) + apiOrgs[i] = convert.ToOrganization(u.Orgs[i]) } ctx.JSON(200, &apiOrgs) } @@ -46,7 +46,7 @@ func Get(ctx *context.APIContext) { if ctx.Written() { return } - ctx.JSON(200, convert.ToApiOrganization(org)) + ctx.JSON(200, convert.ToOrganization(org)) } // https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization @@ -70,5 +70,5 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) { return } - ctx.JSON(200, convert.ToApiOrganization(org)) + ctx.JSON(200, convert.ToOrganization(org)) } diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index eedef8015e..a141921eac 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -25,7 +25,7 @@ func GetBranch(ctx *context.APIContext) { return } - ctx.JSON(200, convert.ToApiBranch(branch, c)) + ctx.JSON(200, convert.ToBranch(branch, c)) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches @@ -43,7 +43,7 @@ func ListBranches(ctx *context.APIContext) { ctx.Error(500, "GetCommit", err) return } - apiBranches[i] = convert.ToApiBranch(branches[i], c) + apiBranches[i] = convert.ToBranch(branches[i], c) } ctx.JSON(200, &apiBranches) diff --git a/routers/api/v1/repo/hooks.go b/routers/api/v1/repo/hooks.go index 840f258cf9..0cbe6762a8 100644 --- a/routers/api/v1/repo/hooks.go +++ b/routers/api/v1/repo/hooks.go @@ -26,9 +26,8 @@ func ListHooks(ctx *context.APIContext) { apiHooks := make([]*api.Hook, len(hooks)) for i := range hooks { - apiHooks[i] = convert.ToApiHook(ctx.Repo.RepoLink, hooks[i]) + apiHooks[i] = convert.ToHook(ctx.Repo.RepoLink, hooks[i]) } - ctx.JSON(200, &apiHooks) } @@ -94,7 +93,7 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { return } - ctx.JSON(201, convert.ToApiHook(ctx.Repo.RepoLink, w)) + ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w)) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook @@ -161,5 +160,5 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { return } - ctx.JSON(200, convert.ToApiHook(ctx.Repo.RepoLink, w)) + ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w)) } diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go new file mode 100644 index 0000000000..bdef1297d1 --- /dev/null +++ b/routers/api/v1/repo/issue.go @@ -0,0 +1,165 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "fmt" + "strings" + + api "github.com/gogits/go-gogs-client" + + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/context" + "github.com/gogits/gogs/modules/setting" + "github.com/gogits/gogs/routers/api/v1/convert" + "github.com/gogits/gogs/routers/repo" +) + +func ListIssues(ctx *context.APIContext) { + issues, err := models.Issues(&models.IssuesOptions{ + RepoID: ctx.Repo.Repository.ID, + Page: ctx.QueryInt("page"), + }) + if err != nil { + ctx.Error(500, "Issues", err) + return + } + + apiIssues := make([]*api.Issue, len(issues)) + for i := range issues { + apiIssues[i] = convert.ToIssue(issues[i]) + } + + ctx.SetLinkHeader(ctx.Repo.Repository.NumIssues, setting.IssuePagingNum) + ctx.JSON(200, &apiIssues) +} + +func GetIssue(ctx *context.APIContext) { + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + if err != nil { + if models.IsErrIssueNotExist(err) { + ctx.Status(404) + } else { + ctx.Error(500, "GetIssueByIndex", err) + } + return + } + + ctx.JSON(200, convert.ToIssue(issue)) +} + +func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { + issue := &models.Issue{ + RepoID: ctx.Repo.Repository.ID, + Name: form.Title, + PosterID: ctx.User.Id, + Poster: ctx.User, + Content: form.Body, + } + + if ctx.Repo.IsWriter() { + if len(form.Assignee) > 0 { + assignee, err := models.GetUserByName(form.Assignee) + if err != nil { + if models.IsErrUserNotExist(err) { + ctx.Error(422, "", fmt.Sprintf("Assignee does not exist: [name: %s]", form.Assignee)) + } else { + ctx.Error(500, "GetUserByName", err) + } + return + } + issue.AssigneeID = assignee.Id + } + issue.MilestoneID = form.Milestone + } else { + form.Labels = nil + } + + if err := models.NewIssue(ctx.Repo.Repository, issue, form.Labels, nil); err != nil { + ctx.Error(500, "NewIssue", err) + return + } else if err := repo.MailWatchersAndMentions(ctx.Context, issue); err != nil { + ctx.Error(500, "MailWatchersAndMentions", err) + return + } + + // Refetch from database to assign some automatic values + var err error + issue, err = models.GetIssueByID(issue.ID) + if err != nil { + ctx.Error(500, "GetIssueByID", err) + return + } + ctx.JSON(201, convert.ToIssue(issue)) +} + +func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + if err != nil { + if models.IsErrIssueNotExist(err) { + ctx.Status(404) + } else { + ctx.Error(500, "GetIssueByIndex", err) + } + return + } + + if !issue.IsPoster(ctx.User.Id) && !ctx.Repo.IsWriter() { + ctx.Status(403) + return + } + + if len(form.Title) > 0 { + issue.Name = form.Title + } + if form.Body != nil { + issue.Content = *form.Body + } + + if ctx.Repo.IsWriter() && form.Assignee != nil && + (issue.Assignee == nil || issue.Assignee.LowerName != strings.ToLower(*form.Assignee)) { + if len(*form.Assignee) == 0 { + issue.AssigneeID = 0 + } else { + assignee, err := models.GetUserByName(*form.Assignee) + if err != nil { + if models.IsErrUserNotExist(err) { + ctx.Error(422, "", fmt.Sprintf("Assignee does not exist: [name: %s]", *form.Assignee)) + } else { + ctx.Error(500, "GetUserByName", err) + } + return + } + issue.AssigneeID = assignee.Id + } + + if err = models.UpdateIssueUserByAssignee(issue); err != nil { + ctx.Error(500, "UpdateIssueUserByAssignee", err) + return + } + } + if ctx.Repo.IsWriter() && form.Milestone != nil && + issue.MilestoneID != *form.Milestone { + oldMid := issue.MilestoneID + issue.MilestoneID = *form.Milestone + if err = models.ChangeMilestoneAssign(oldMid, issue); err != nil { + ctx.Error(500, "ChangeMilestoneAssign", err) + return + } + } + + if err = models.UpdateIssue(issue); err != nil { + ctx.Error(500, "UpdateIssue", err) + return + } + + // Refetch from database to assign some automatic values + issue, err = models.GetIssueByID(issue.ID) + if err != nil { + ctx.Error(500, "GetIssueByID", err) + return + } + ctx.JSON(201, convert.ToIssue(issue)) +} diff --git a/routers/api/v1/repo/keys.go b/routers/api/v1/repo/keys.go index d8ae137c79..563dac2615 100644 --- a/routers/api/v1/repo/keys.go +++ b/routers/api/v1/repo/keys.go @@ -34,7 +34,7 @@ func ListDeployKeys(ctx *context.APIContext) { ctx.Error(500, "GetContent", err) return } - apiKeys[i] = convert.ToApiDeployKey(apiLink, keys[i]) + apiKeys[i] = convert.ToDeployKey(apiLink, keys[i]) } ctx.JSON(200, &apiKeys) @@ -58,7 +58,7 @@ func GetDeployKey(ctx *context.APIContext) { } apiLink := composeDeployKeysAPILink(ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name) - ctx.JSON(200, convert.ToApiDeployKey(apiLink, key)) + ctx.JSON(200, convert.ToDeployKey(apiLink, key)) } func HandleCheckKeyStringError(ctx *context.APIContext, err error) { @@ -96,7 +96,7 @@ func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) { key.Content = content apiLink := composeDeployKeysAPILink(ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name) - ctx.JSON(201, convert.ToApiDeployKey(apiLink, key)) + ctx.JSON(201, convert.ToDeployKey(apiLink, key)) } // https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 8c79c32e2c..90a323c257 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -69,7 +69,7 @@ func Search(ctx *context.APIContext) { return } results[i] = &api.Repository{ - Id: repos[i].ID, + ID: repos[i].ID, FullName: path.Join(repos[i].Owner.Name, repos[i].Name), } } @@ -97,12 +97,12 @@ func ListMyRepos(ctx *context.APIContext) { repos := make([]*api.Repository, numOwnRepos+len(accessibleRepos)) for i := range ownRepos { - repos[i] = convert.ToApiRepository(ctx.User, ownRepos[i], api.Permission{true, true, true}) + repos[i] = convert.ToRepository(ctx.User, ownRepos[i], api.Permission{true, true, true}) } i := numOwnRepos for repo, access := range accessibleRepos { - repos[i] = convert.ToApiRepository(repo.Owner, repo, api.Permission{ + repos[i] = convert.ToRepository(repo.Owner, repo, api.Permission{ Admin: access >= models.ACCESS_MODE_ADMIN, Push: access >= models.ACCESS_MODE_WRITE, Pull: true, @@ -139,7 +139,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR return } - ctx.JSON(201, convert.ToApiRepository(owner, repo, api.Permission{true, true, true})) + ctx.JSON(201, convert.ToRepository(owner, repo, api.Permission{true, true, true})) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#create @@ -239,7 +239,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { } log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) - ctx.JSON(201, convert.ToApiRepository(ctxUser, repo, api.Permission{true, true, true})) + ctx.JSON(201, convert.ToRepository(ctxUser, repo, api.Permission{true, true, true})) } func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repository) { @@ -273,7 +273,7 @@ func Get(ctx *context.APIContext) { return } - ctx.JSON(200, convert.ToApiRepository(owner, repo, api.Permission{true, true, true})) + ctx.JSON(200, convert.ToRepository(owner, repo, api.Permission{true, true, true})) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#delete diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index fe11954ba7..6a3d525cce 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -22,7 +22,7 @@ func ListEmails(ctx *context.APIContext) { } apiEmails := make([]*api.Email, len(emails)) for i := range emails { - apiEmails[i] = convert.ToApiEmail(emails[i]) + apiEmails[i] = convert.ToEmail(emails[i]) } ctx.JSON(200, &apiEmails) } @@ -54,7 +54,7 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { apiEmails := make([]*api.Email, len(emails)) for i := range emails { - apiEmails[i] = convert.ToApiEmail(emails[i]) + apiEmails[i] = convert.ToEmail(emails[i]) } ctx.JSON(201, &apiEmails) } diff --git a/routers/api/v1/user/followers.go b/routers/api/v1/user/followers.go index 7e00cb3f18..00d1952d59 100644 --- a/routers/api/v1/user/followers.go +++ b/routers/api/v1/user/followers.go @@ -15,7 +15,7 @@ import ( func responseApiUsers(ctx *context.APIContext, users []*models.User) { apiUsers := make([]*api.User, len(users)) for i := range users { - apiUsers[i] = convert.ToApiUser(users[i]) + apiUsers[i] = convert.ToUser(users[i]) } ctx.JSON(200, &apiUsers) } diff --git a/routers/api/v1/user/keys.go b/routers/api/v1/user/keys.go index 3e1ed666e2..7337112ece 100644 --- a/routers/api/v1/user/keys.go +++ b/routers/api/v1/user/keys.go @@ -46,7 +46,7 @@ func listPublicKeys(ctx *context.APIContext, uid int64) { apiLink := composePublicKeysAPILink() apiKeys := make([]*api.PublicKey, len(keys)) for i := range keys { - apiKeys[i] = convert.ToApiPublicKey(apiLink, keys[i]) + apiKeys[i] = convert.ToPublicKey(apiLink, keys[i]) } ctx.JSON(200, &apiKeys) @@ -79,7 +79,7 @@ func GetPublicKey(ctx *context.APIContext) { } apiLink := composePublicKeysAPILink() - ctx.JSON(200, convert.ToApiPublicKey(apiLink, key)) + ctx.JSON(200, convert.ToPublicKey(apiLink, key)) } // CreateUserPublicKey creates new public key to given user by ID. @@ -96,7 +96,7 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid return } apiLink := composePublicKeysAPILink() - ctx.JSON(201, convert.ToApiPublicKey(apiLink, key)) + ctx.JSON(201, convert.ToPublicKey(apiLink, key)) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key |