diff options
Diffstat (limited to 'routers/api/v1/repo/issue_comment.go')
-rw-r--r-- | routers/api/v1/repo/issue_comment.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index d62ca81314..13e7de46b1 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -68,17 +68,25 @@ func ListIssueComments(ctx *context.APIContext) { } issue.Repo = ctx.Repo.Repository - comments, err := models.FindComments(models.FindCommentsOptions{ + opts := &models.FindCommentsOptions{ IssueID: issue.ID, Since: since, Before: before, Type: models.CommentTypeComment, - }) + } + + comments, err := models.FindComments(opts) if err != nil { ctx.Error(http.StatusInternalServerError, "FindComments", err) return } + totalCount, err := models.CountComments(opts) + if err != nil { + ctx.InternalServerError(err) + return + } + if err := models.CommentList(comments).LoadPosters(); err != nil { ctx.Error(http.StatusInternalServerError, "LoadPosters", err) return @@ -89,6 +97,8 @@ func ListIssueComments(ctx *context.APIContext) { comment.Issue = issue apiComments[i] = convert.ToComment(comments[i]) } + + ctx.SetTotalCountHeader(totalCount) ctx.JSON(http.StatusOK, &apiComments) } @@ -138,18 +148,26 @@ func ListRepoIssueComments(ctx *context.APIContext) { return } - comments, err := models.FindComments(models.FindCommentsOptions{ + opts := &models.FindCommentsOptions{ ListOptions: utils.GetListOptions(ctx), RepoID: ctx.Repo.Repository.ID, Type: models.CommentTypeComment, Since: since, Before: before, - }) + } + + comments, err := models.FindComments(opts) if err != nil { ctx.Error(http.StatusInternalServerError, "FindComments", err) return } + totalCount, err := models.CountComments(opts) + if err != nil { + ctx.InternalServerError(err) + return + } + if err = models.CommentList(comments).LoadPosters(); err != nil { ctx.Error(http.StatusInternalServerError, "LoadPosters", err) return @@ -171,6 +189,8 @@ func ListRepoIssueComments(ctx *context.APIContext) { for i := range comments { apiComments[i] = convert.ToComment(comments[i]) } + + ctx.SetTotalCountHeader(totalCount) ctx.JSON(http.StatusOK, &apiComments) } |