diff options
Diffstat (limited to 'routers/api/v1/repo/issue_comment.go')
-rw-r--r-- | routers/api/v1/repo/issue_comment.go | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index 3085c2e51f..8c97936204 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -7,11 +7,11 @@ package repo import ( "errors" "net/http" - "time" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/routers/api/v1/utils" comment_service "code.gitea.io/gitea/services/comments" ) @@ -43,16 +43,21 @@ func ListIssueComments(ctx *context.APIContext) { // in: query // description: if provided, only comments updated since the specified time are returned. // type: string + // format: date-time + // - name: before + // in: query + // description: if provided, only comments updated before the provided time are returned. + // type: string + // format: date-time // responses: // "200": // "$ref": "#/responses/CommentList" - var since time.Time - if len(ctx.Query("since")) > 0 { - since, _ = time.Parse(time.RFC3339, ctx.Query("since")) + before, since, err := utils.GetQueryBeforeSince(ctx) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetQueryBeforeSince", err) + return } - - // comments,err:=models.GetCommentsByIssueIDSince(, since) issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { ctx.Error(http.StatusInternalServerError, "GetRawIssueByIndex", err) @@ -62,7 +67,8 @@ func ListIssueComments(ctx *context.APIContext) { comments, err := models.FindComments(models.FindCommentsOptions{ IssueID: issue.ID, - Since: since.Unix(), + Since: since, + Before: before, Type: models.CommentTypeComment, }) if err != nil { @@ -105,18 +111,26 @@ func ListRepoIssueComments(ctx *context.APIContext) { // in: query // description: if provided, only comments updated since the provided time are returned. // type: string + // format: date-time + // - name: before + // in: query + // description: if provided, only comments updated before the provided time are returned. + // type: string + // format: date-time // responses: // "200": // "$ref": "#/responses/CommentList" - var since time.Time - if len(ctx.Query("since")) > 0 { - since, _ = time.Parse(time.RFC3339, ctx.Query("since")) + before, since, err := utils.GetQueryBeforeSince(ctx) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetQueryBeforeSince", err) + return } comments, err := models.FindComments(models.FindCommentsOptions{ RepoID: ctx.Repo.Repository.ID, - Since: since.Unix(), + Since: since, + Before: before, Type: models.CommentTypeComment, }) if err != nil { |