mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
Fallback to old user search
This commit is contained in:
parent
08281712cc
commit
d67cc63871
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
AccountID string `json:"accountId"`
|
AccountID string `json:"accountId"`
|
||||||
|
UserKey string `json:"userKey"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
@ -575,6 +576,7 @@ func (api *API) GetUserByName(name string) (*User, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try the new path first
|
||||||
_, err := api.rest.
|
_, err := api.rest.
|
||||||
Res("search").
|
Res("search").
|
||||||
Res("user", &response).
|
Res("user", &response).
|
||||||
@ -585,7 +587,20 @@ func (api *API) GetUserByName(name string) (*User, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try old path
|
||||||
if len(response.Results) == 0 {
|
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.
|
return nil, karma.
|
||||||
Describe("name", name).
|
Describe("name", name).
|
||||||
Reason(
|
Reason(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user