Skip to content

Commit

Permalink
Merge branch 'master' into cli-remake-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Mar 4, 2023
2 parents b841d78 + b92c821 commit 4fd0968
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 9 additions & 4 deletions internal/edge/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ type Client struct {
token string
}

func New(teamID string, token string, cookies []*http.Cookie) *Client {
func New(teamID string, token string, cookies []*http.Cookie) (*Client, error) {
cl, err := chttp.New("https://slack.com", cookies)
if err != nil {
return nil, err
}
return &Client{
cl: chttp.Must(chttp.New("https://slack.com", cookies)),
cl: cl,
token: token,
apiPath: fmt.Sprintf("https://edgeapi.slack.com/cache/%s/", teamID)}
apiPath: fmt.Sprintf("https://edgeapi.slack.com/cache/%s/", teamID),
}, nil
}

func NewWithProvider(teamID string, prov auth.Provider) *Client {
func NewWithProvider(teamID string, prov auth.Provider) (*Client, error) {
return New(teamID, prov.SlackToken(), prov.Cookies())
}

Expand Down
12 changes: 9 additions & 3 deletions internal/edge/edge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ func TestNew(t *testing.T) {
t.Skip("test token not set")
}

au, err := auth.NewValueAuth(testToken, testCookie)
prov, err := auth.NewValueAuth(testToken, testCookie)
if err != nil {
t.Fatal(err)
}
cl, err := New(testTeam, prov.SlackToken(), prov.Cookies())
if err != nil {
t.Fatal(err)
}
cl := New(testTeam, au.SlackToken(), au.Cookies())
req := UsersListRequest{
Channels: []string{"C6NL0QQSG"},
Filter: "everyone AND NOT bots AND NOT apps",
Expand All @@ -54,7 +57,10 @@ func TestGetUsers(t *testing.T) {
if err != nil {
t.Fatal(err)
}
cl := NewWithProvider(testTeam, au)
cl, err := NewWithProvider(testTeam, au)
if err != nil {
t.Fatal(err)
}
ui, err := cl.GetUsers(context.Background(), []string{"U0LKLSNER", "U03K9GLS2", "U03KMNRQS"})
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 4fd0968

Please sign in to comment.