correctly honor include_current_user config option
This commit is contained in:
parent
bfdb1f0946
commit
7afde6a9eb
|
@ -22,6 +22,7 @@ type Refresher interface {
|
|||
|
||||
type GitlabClientParam struct {
|
||||
PullMethod string
|
||||
IncludeCurrentUser bool
|
||||
}
|
||||
|
||||
type gitlabClient struct {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package gitlab
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
|
@ -50,12 +51,16 @@ func (c *gitlabClient) FetchUser(uid int) (*User, error) {
|
|||
}
|
||||
|
||||
func (c *gitlabClient) FetchCurrentUser() (*User, error) {
|
||||
if c.IncludeCurrentUser {
|
||||
gitlabUser, _, err := c.client.Users.CurrentUser()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch current user: %v", err)
|
||||
}
|
||||
user := NewUserFromGitlabUser(gitlabUser)
|
||||
return &user, nil
|
||||
}
|
||||
// no current user to fetch, return nil
|
||||
return nil, errors.New("current user fetch is disabled")
|
||||
}
|
||||
|
||||
func (c *gitlabClient) FetchUserContent(user *User) (*UserContent, error) {
|
||||
|
|
Loading…
Reference in New Issue