issue_reaction.go (gitea-1.13.1) | : | issue_reaction.go (gitea-1.13.2) | ||
---|---|---|---|---|
skipping to change at line 23 | skipping to change at line 23 | |||
// Reaction contain one reaction | // Reaction contain one reaction | |||
type Reaction struct { | type Reaction struct { | |||
User *User `json:"user"` | User *User `json:"user"` | |||
Reaction string `json:"content"` | Reaction string `json:"content"` | |||
Created time.Time `json:"created_at"` | Created time.Time `json:"created_at"` | |||
} | } | |||
// GetIssueReactions get a list reactions of an issue | // GetIssueReactions get a list reactions of an issue | |||
func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction , *Response, error) { | func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction , *Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
reactions := make([]*Reaction, 0, 10) | reactions := make([]*Reaction, 0, 10) | |||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/ %d/reactions", owner, repo, index), nil, nil, &reactions) | resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/ %d/reactions", owner, repo, index), nil, nil, &reactions) | |||
return reactions, resp, err | return reactions, resp, err | |||
} | } | |||
// GetIssueCommentReactions get a list of reactions from a comment of an issue | // GetIssueCommentReactions get a list of reactions from a comment of an issue | |||
func (c *Client) GetIssueCommentReactions(owner, repo string, commentID int64) ( []*Reaction, *Response, error) { | func (c *Client) GetIssueCommentReactions(owner, repo string, commentID int64) ( []*Reaction, *Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
reactions := make([]*Reaction, 0, 10) | reactions := make([]*Reaction, 0, 10) | |||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/ comments/%d/reactions", owner, repo, commentID), nil, nil, &reactions) | resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/ comments/%d/reactions", owner, repo, commentID), nil, nil, &reactions) | |||
return reactions, resp, err | return reactions, resp, err | |||
} | } | |||
// editReactionOption contain the reaction type | // editReactionOption contain the reaction type | |||
type editReactionOption struct { | type editReactionOption struct { | |||
Reaction string `json:"content"` | Reaction string `json:"content"` | |||
} | } | |||
// PostIssueReaction add a reaction to an issue | // PostIssueReaction add a reaction to an issue | |||
func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction str ing) (*Reaction, *Response, error) { | func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction str ing) (*Reaction, *Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
reactionResponse := new(Reaction) | reactionResponse := new(Reaction) | |||
body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | |||
if err != nil { | if err != nil { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
resp, err := c.getParsedResponse("POST", | resp, err := c.getParsedResponse("POST", | |||
fmt.Sprintf("/repos/%s/%s/issues/%d/reactions", owner, repo, inde x), | fmt.Sprintf("/repos/%s/%s/issues/%d/reactions", owner, repo, inde x), | |||
jsonHeader, bytes.NewReader(body), reactionResponse) | jsonHeader, bytes.NewReader(body), reactionResponse) | |||
return reactionResponse, resp, err | return reactionResponse, resp, err | |||
} | } | |||
// DeleteIssueReaction remove a reaction from an issue | // DeleteIssueReaction remove a reaction from an issue | |||
func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction s tring) (*Response, error) { | func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction s tring) (*Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, err | return nil, err | |||
} | } | |||
body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | |||
if err != nil { | if err != nil { | |||
return nil, err | return nil, err | |||
} | } | |||
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/ %d/reactions", owner, repo, index), jsonHeader, bytes.NewReader(body)) | _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/ %d/reactions", owner, repo, index), jsonHeader, bytes.NewReader(body)) | |||
return resp, err | return resp, err | |||
} | } | |||
// PostIssueCommentReaction add a reaction to a comment of an issue | // PostIssueCommentReaction add a reaction to a comment of an issue | |||
func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, r eaction string) (*Reaction, *Response, error) { | func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, r eaction string) (*Reaction, *Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
reactionResponse := new(Reaction) | reactionResponse := new(Reaction) | |||
body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | |||
if err != nil { | if err != nil { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
resp, err := c.getParsedResponse("POST", | resp, err := c.getParsedResponse("POST", | |||
fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, r epo, commentID), | fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, r epo, commentID), | |||
jsonHeader, bytes.NewReader(body), reactionResponse) | jsonHeader, bytes.NewReader(body), reactionResponse) | |||
return reactionResponse, resp, err | return reactionResponse, resp, err | |||
} | } | |||
// DeleteIssueCommentReaction remove a reaction from a comment of an issue | // DeleteIssueCommentReaction remove a reaction from a comment of an issue | |||
func (c *Client) DeleteIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Response, error) { | func (c *Client) DeleteIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != n il { | |||
return nil, err | return nil, err | |||
} | } | |||
body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | body, err := json.Marshal(&editReactionOption{Reaction: reaction}) | |||
if err != nil { | if err != nil { | |||
return nil, err | return nil, err | |||
} | } | |||
_, resp, err := c.getResponse("DELETE", | _, resp, err := c.getResponse("DELETE", | |||
fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, r epo, commentID), | fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, r epo, commentID), | |||
jsonHeader, bytes.NewReader(body)) | jsonHeader, bytes.NewReader(body)) | |||
return resp, err | return resp, err | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |