1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-11-29 22:28:34 +02:00

fix(IssueService.GetWatchers): UserService.GetByAccountID support accountId params

This commit is contained in:
clement
2020-03-10 17:03:59 +01:00
committed by Wes McNamee
parent a90dd878dc
commit 436469b62d
4 changed files with 98 additions and 3 deletions

View File

@@ -249,6 +249,7 @@ type Watches struct {
type Watcher struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
AccountID string `json:"accountId,omitempty" structs:"accountId,omitempty"`
DisplayName string `json:"displayName,omitempty" structs:"displayName,omitempty"`
Active bool `json:"active,omitempty" structs:"active,omitempty"`
}
@@ -1236,9 +1237,17 @@ func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
result := []User{}
user := new(User)
for _, watcher := range watches.Watchers {
user, resp, err = s.client.User.Get(watcher.Name)
if err != nil {
return nil, resp, NewJiraError(resp, err)
if watcher.AccountID != "" {
user, resp, err = s.client.User.GetByAccountID(watcher.AccountID)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
} else {
// try fallback deprecated method
user, resp, err = s.client.User.Get(watcher.Name)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
}
result = append(result, *user)
}