From a3afbca7dc709a9dd2d5496c2d966fc1b1ef4efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 9 Nov 2016 16:57:33 +0100 Subject: [PATCH] More data and methods for issue-comments --- gitea/issue_comment.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/gitea/issue_comment.go b/gitea/issue_comment.go index 59f064a..ccd13b6 100644 --- a/gitea/issue_comment.go +++ b/gitea/issue_comment.go @@ -13,11 +13,14 @@ import ( // Comment represents a comment in commit and issue page. type Comment struct { - ID int64 `json:"id"` - Poster *User `json:"user"` - Body string `json:"body"` - Created time.Time `json:"created_at"` - Updated time.Time `json:"updated_at"` + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + PRURL string `json:"pull_request_url"` + IssueURL string `json:"issue_url"` + Poster *User `json:"user"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` } // ListIssueComments list comments on an issue. @@ -26,6 +29,12 @@ func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments) } +// ListRepoIssueComments list comments for a given repo. +func (c *Client) ListRepoIssuecomments(owner, repo string) ([]*Comment, error) { + comments := make([]*Comment, 0, 10) + return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) +} + // CreateIssueCommentOption is option when creating an issue comment. type CreateIssueCommentOption struct { Body string `json:"body" binding:"Required"` @@ -55,3 +64,9 @@ func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, op comment := new(Comment) return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) } + +// DeleteIssueComment deletes an issue comment. +func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil) + return err +}