Unverified Commit a9c97172 authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Add (us)subscribe to/from issues (#479)

And extend the MergeEvent struct.
parent c5f12546
...@@ -490,6 +490,24 @@ type MergeEvent struct { ...@@ -490,6 +490,24 @@ type MergeEvent struct {
Username string `json:"username"` Username string `json:"username"`
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
} `json:"assignee"` } `json:"assignee"`
Changes struct {
AssigneeID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"assignee_id"`
Description struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"description"`
Labels struct {
Previous []Label `json:"previous"`
Current []Label `json:"current"`
} `json:"labels"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
} `json:"changes"`
} }
// WikiPageEvent represents a wiki page event. // WikiPageEvent represents a wiki page event.
......
...@@ -363,6 +363,60 @@ func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...Optio ...@@ -363,6 +363,60 @@ func (s *IssuesService) DeleteIssue(pid interface{}, issue int, options ...Optio
return s.client.Do(req, nil) return s.client.Do(req, nil)
} }
// SubscribeToIssue subscribes the authenticated user to the given issue to
// receive notifications. If the user is already subscribed to the issue, the
// status code 304 is returned.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#subscribe-to-a-merge-request
func (s *IssuesService) SubscribeToIssue(pid interface{}, issue int, options ...OptionFunc) (*Issue, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/issues/%d/subscribe", url.QueryEscape(project), issue)
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, nil, err
}
i := new(Issue)
resp, err := s.client.Do(req, i)
if err != nil {
return nil, resp, err
}
return i, resp, err
}
// UnsubscribeFromIssue unsubscribes the authenticated user from the given
// issue to not receive notifications from that merge request. If the user
// is not subscribed to the issue, status code 304 is returned.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#unsubscribe-from-a-merge-request
func (s *IssuesService) UnsubscribeFromIssue(pid interface{}, issue int, options ...OptionFunc) (*Issue, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/issues/%d/unsubscribe", url.QueryEscape(project), issue)
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, nil, err
}
i := new(Issue)
resp, err := s.client.Do(req, i)
if err != nil {
return nil, resp, err
}
return i, resp, err
}
// ListMergeRequestsClosingIssueOptions represents the available // ListMergeRequestsClosingIssueOptions represents the available
// ListMergeRequestsClosingIssue() options. // ListMergeRequestsClosingIssue() options.
// //
......
...@@ -684,8 +684,8 @@ func (s *MergeRequestsService) GetSingleMergeRequestDiffVersion(pid interface{}, ...@@ -684,8 +684,8 @@ func (s *MergeRequestsService) GetSingleMergeRequestDiffVersion(pid interface{},
return v, resp, err return v, resp, err
} }
// SubscribeToMergeRequest subscribes the authenticated user to the given merge request // SubscribeToMergeRequest subscribes the authenticated user to the given merge
// to receive notifications. If the user is already subscribed to the // request to receive notifications. If the user is already subscribed to the
// merge request, the status code 304 is returned. // merge request, the status code 304 is returned.
// //
// GitLab API docs: // GitLab API docs:
...@@ -711,9 +711,10 @@ func (s *MergeRequestsService) SubscribeToMergeRequest(pid interface{}, mergeReq ...@@ -711,9 +711,10 @@ func (s *MergeRequestsService) SubscribeToMergeRequest(pid interface{}, mergeReq
return m, resp, err return m, resp, err
} }
// UnsubscribeFromMergeRequest unsubscribes the authenticated user from the given merge request // UnsubscribeFromMergeRequest unsubscribes the authenticated user from the
// to not receive notifications from that merge request. If the user is // given merge request to not receive notifications from that merge request.
// not subscribed to the merge request, status code 304 is returned. // If the user is not subscribed to the merge request, status code 304 is
// returned.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#unsubscribe-from-a-merge-request // https://docs.gitlab.com/ce/api/merge_requests.html#unsubscribe-from-a-merge-request
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment