diff options
author | Wim <wim@42.be> | 2018-08-10 00:38:19 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-08-10 00:38:19 +0200 |
commit | 68aeb93afa0dd4a5067fcefff9db0a70644d7128 (patch) | |
tree | fdd80104c029ba57cb27d54850a3aa7020fedfba /vendor/github.com/nlopes/slack/dnd.go | |
parent | 51062863a5c34d81e296cf15c61140911037cf3b (diff) | |
download | matterbridge-msglm-68aeb93afa0dd4a5067fcefff9db0a70644d7128.tar.gz matterbridge-msglm-68aeb93afa0dd4a5067fcefff9db0a70644d7128.tar.bz2 matterbridge-msglm-68aeb93afa0dd4a5067fcefff9db0a70644d7128.zip |
Update nlopes/slack vendor
Diffstat (limited to 'vendor/github.com/nlopes/slack/dnd.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/dnd.go | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/vendor/github.com/nlopes/slack/dnd.go b/vendor/github.com/nlopes/slack/dnd.go index 4f1b3228..26d36d6a 100644 --- a/vendor/github.com/nlopes/slack/dnd.go +++ b/vendor/github.com/nlopes/slack/dnd.go @@ -36,9 +36,9 @@ type dndTeamInfoResponse struct { SlackResponse } -func dndRequest(ctx context.Context, path string, values url.Values, debug bool) (*dndResponseFull, error) { +func dndRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*dndResponseFull, error) { response := &dndResponseFull{} - err := post(ctx, path, values, response, debug) + err := postSlackMethod(ctx, client, path, values, response, debug) if err != nil { return nil, err } @@ -56,17 +56,16 @@ func (api *Client) EndDND() error { // EndDNDContext ends the user's scheduled Do Not Disturb session with a custom context func (api *Client) EndDNDContext(ctx context.Context) error { values := url.Values{ - "token": {api.config.token}, + "token": {api.token}, } response := &SlackResponse{} - if err := post(ctx, "dnd.endDnd", values, response, api.debug); err != nil { + + if err := postSlackMethod(ctx, api.httpclient, "dnd.endDnd", values, response, api.debug); err != nil { return err } - if !response.Ok { - return errors.New(response.Error) - } - return nil + + return response.Err() } // EndSnooze ends the current user's snooze mode @@ -77,10 +76,10 @@ func (api *Client) EndSnooze() (*DNDStatus, error) { // EndSnoozeContext ends the current user's snooze mode with a custom context func (api *Client) EndSnoozeContext(ctx context.Context) (*DNDStatus, error) { values := url.Values{ - "token": {api.config.token}, + "token": {api.token}, } - response, err := dndRequest(ctx, "dnd.endSnooze", values, api.debug) + response, err := dndRequest(ctx, api.httpclient, "dnd.endSnooze", values, api.debug) if err != nil { return nil, err } @@ -95,12 +94,13 @@ func (api *Client) GetDNDInfo(user *string) (*DNDStatus, error) { // GetDNDInfoContext provides information about a user's current Do Not Disturb settings with a custom context. func (api *Client) GetDNDInfoContext(ctx context.Context, user *string) (*DNDStatus, error) { values := url.Values{ - "token": {api.config.token}, + "token": {api.token}, } if user != nil { values.Set("user", *user) } - response, err := dndRequest(ctx, "dnd.info", values, api.debug) + + response, err := dndRequest(ctx, api.httpclient, "dnd.info", values, api.debug) if err != nil { return nil, err } @@ -115,11 +115,12 @@ func (api *Client) GetDNDTeamInfo(users []string) (map[string]DNDStatus, error) // GetDNDTeamInfoContext provides information about a user's current Do Not Disturb settings with a custom context. func (api *Client) GetDNDTeamInfoContext(ctx context.Context, users []string) (map[string]DNDStatus, error) { values := url.Values{ - "token": {api.config.token}, + "token": {api.token}, "users": {strings.Join(users, ",")}, } response := &dndTeamInfoResponse{} - if err := post(ctx, "dnd.teamInfo", values, response, api.debug); err != nil { + + if err := postSlackMethod(ctx, api.httpclient, "dnd.teamInfo", values, response, api.debug); err != nil { return nil, err } if !response.Ok { @@ -139,10 +140,11 @@ func (api *Client) SetSnooze(minutes int) (*DNDStatus, error) { // For more information see the SetSnooze docs func (api *Client) SetSnoozeContext(ctx context.Context, minutes int) (*DNDStatus, error) { values := url.Values{ - "token": {api.config.token}, + "token": {api.token}, "num_minutes": {strconv.Itoa(minutes)}, } - response, err := dndRequest(ctx, "dnd.setSnooze", values, api.debug) + + response, err := dndRequest(ctx, api.httpclient, "dnd.setSnooze", values, api.debug) if err != nil { return nil, err } |