diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack/dnd.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/dnd.go | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/vendor/github.com/nlopes/slack/dnd.go b/vendor/github.com/nlopes/slack/dnd.go index da6e4a16..a3aa680c 100644 --- a/vendor/github.com/nlopes/slack/dnd.go +++ b/vendor/github.com/nlopes/slack/dnd.go @@ -2,7 +2,6 @@ package slack import ( "context" - "errors" "net/url" "strconv" "strings" @@ -36,16 +35,14 @@ type dndTeamInfoResponse struct { SlackResponse } -func dndRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*dndResponseFull, error) { +func (api *Client) dndRequest(ctx context.Context, path string, values url.Values) (*dndResponseFull, error) { response := &dndResponseFull{} - err := postSlackMethod(ctx, client, path, values, response, d) + err := api.postMethod(ctx, path, values, response) if err != nil { return nil, err } - if !response.Ok { - return nil, errors.New(response.Error) - } - return response, nil + + return response, response.Err() } // EndDND ends the user's scheduled Do Not Disturb session @@ -61,7 +58,7 @@ func (api *Client) EndDNDContext(ctx context.Context) error { response := &SlackResponse{} - if err := postSlackMethod(ctx, api.httpclient, "dnd.endDnd", values, response, api); err != nil { + if err := api.postMethod(ctx, "dnd.endDnd", values, response); err != nil { return err } @@ -79,7 +76,7 @@ func (api *Client) EndSnoozeContext(ctx context.Context) (*DNDStatus, error) { "token": {api.token}, } - response, err := dndRequest(ctx, api.httpclient, "dnd.endSnooze", values, api) + response, err := api.dndRequest(ctx, "dnd.endSnooze", values) if err != nil { return nil, err } @@ -100,7 +97,7 @@ func (api *Client) GetDNDInfoContext(ctx context.Context, user *string) (*DNDSta values.Set("user", *user) } - response, err := dndRequest(ctx, api.httpclient, "dnd.info", values, api) + response, err := api.dndRequest(ctx, "dnd.info", values) if err != nil { return nil, err } @@ -120,13 +117,14 @@ func (api *Client) GetDNDTeamInfoContext(ctx context.Context, users []string) (m } response := &dndTeamInfoResponse{} - if err := postSlackMethod(ctx, api.httpclient, "dnd.teamInfo", values, response, api); err != nil { + if err := api.postMethod(ctx, "dnd.teamInfo", values, response); err != nil { return nil, err } if response.Err() != nil { return nil, response.Err() } + return response.Users, nil } @@ -137,7 +135,7 @@ func (api *Client) SetSnooze(minutes int) (*DNDStatus, error) { return api.SetSnoozeContext(context.Background(), minutes) } -// SetSnooze adjusts the snooze duration for a user's Do Not Disturb settings with a custom context. +// SetSnoozeContext adjusts the snooze duration for a user's Do Not Disturb settings with a custom context. // For more information see the SetSnooze docs func (api *Client) SetSnoozeContext(ctx context.Context, minutes int) (*DNDStatus, error) { values := url.Values{ @@ -145,7 +143,7 @@ func (api *Client) SetSnoozeContext(ctx context.Context, minutes int) (*DNDStatu "num_minutes": {strconv.Itoa(minutes)}, } - response, err := dndRequest(ctx, api.httpclient, "dnd.setSnooze", values, api) + response, err := api.dndRequest(ctx, "dnd.setSnooze", values) if err != nil { return nil, err } |