Skip to content

Commit

Permalink
Fallback to old user search
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed May 23, 2023
1 parent 0828171 commit d67cc63
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/confluence/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

type User struct {
AccountID string `json:"accountId"`
UserKey string `json:"userKey"`
}

type API struct {
Expand Down Expand Up @@ -575,6 +576,7 @@ func (api *API) GetUserByName(name string) (*User, error) {
}
}

// Try the new path first
_, err := api.rest.
Res("search").
Res("user", &response).
Expand All @@ -585,7 +587,20 @@ func (api *API) GetUserByName(name string) (*User, error) {
return nil, err
}

// Try old path
if len(response.Results) == 0 {
_, err := api.rest.
Res("search", &response).
Get(map[string]string{
"cql": fmt.Sprintf("user.fullname~%q", name),
})
if err != nil {
return nil, err
}
}

if len(response.Results) == 0 {

return nil, karma.
Describe("name", name).
Reason(
Expand Down

0 comments on commit d67cc63

Please sign in to comment.