diff options
author | Patrick Connolly <patrick.c.connolly@gmail.com> | 2018-12-02 02:55:35 +0800 |
---|---|---|
committer | Wim <wim@42.be> | 2018-12-01 19:55:35 +0100 |
commit | e538a4d30459e9da1a021400b5de85894b4efabc (patch) | |
tree | ead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/files.go | |
parent | f94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff) | |
download | matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.gz matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.bz2 matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.zip |
Update nlopes/slack to 4.1-dev (#595)
Diffstat (limited to 'vendor/github.com/nlopes/slack/files.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/files.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/vendor/github.com/nlopes/slack/files.go b/vendor/github.com/nlopes/slack/files.go index 0550c9fb..13158582 100644 --- a/vendor/github.com/nlopes/slack/files.go +++ b/vendor/github.com/nlopes/slack/files.go @@ -137,16 +137,14 @@ func NewGetFilesParameters() GetFilesParameters { } } -func fileRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*fileResponseFull, error) { +func fileRequest(ctx context.Context, client httpClient, path string, values url.Values, d debug) (*fileResponseFull, error) { response := &fileResponseFull{} - err := postForm(ctx, client, SLACK_API+path, values, response, debug) + err := postForm(ctx, client, APIURL+path, values, response, d) if err != nil { return nil, err } - if !response.Ok { - return nil, errors.New(response.Error) - } - return response, nil + + return response, response.Err() } // GetFileInfo retrieves a file and related comments @@ -163,7 +161,7 @@ func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count, "page": {strconv.Itoa(page)}, } - response, err := fileRequest(ctx, api.httpclient, "files.info", values, api.debug) + response, err := fileRequest(ctx, api.httpclient, "files.info", values, api) if err != nil { return nil, nil, nil, err } @@ -202,7 +200,7 @@ func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameter values.Add("page", strconv.Itoa(params.Page)) } - response, err := fileRequest(ctx, api.httpclient, "files.list", values, api.debug) + response, err := fileRequest(ctx, api.httpclient, "files.list", values, api) if err != nil { return nil, nil, err } @@ -246,19 +244,17 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam } if params.Content != "" { values.Add("content", params.Content) - err = postForm(ctx, api.httpclient, SLACK_API+"files.upload", values, response, api.debug) + err = postForm(ctx, api.httpclient, APIURL+"files.upload", values, response, api) } else if params.File != "" { - err = postLocalWithMultipartResponse(ctx, api.httpclient, "files.upload", params.File, "file", values, response, api.debug) + err = postLocalWithMultipartResponse(ctx, api.httpclient, "files.upload", params.File, "file", values, response, api) } else if params.Reader != nil { - err = postWithMultipartResponse(ctx, api.httpclient, "files.upload", params.Filename, "file", values, params.Reader, response, api.debug) + err = postWithMultipartResponse(ctx, api.httpclient, "files.upload", params.Filename, "file", values, params.Reader, response, api) } if err != nil { return nil, err } - if !response.Ok { - return nil, errors.New(response.Error) - } - return &response.File, nil + + return &response.File, response.Err() } // DeleteFileComment deletes a file's comment @@ -277,7 +273,7 @@ func (api *Client) DeleteFileCommentContext(ctx context.Context, fileID, comment "file": {fileID}, "id": {commentID}, } - _, err = fileRequest(ctx, api.httpclient, "files.comments.delete", values, api.debug) + _, err = fileRequest(ctx, api.httpclient, "files.comments.delete", values, api) return err } @@ -293,7 +289,7 @@ func (api *Client) DeleteFileContext(ctx context.Context, fileID string) (err er "file": {fileID}, } - _, err = fileRequest(ctx, api.httpclient, "files.delete", values, api.debug) + _, err = fileRequest(ctx, api.httpclient, "files.delete", values, api) return err } @@ -309,7 +305,7 @@ func (api *Client) RevokeFilePublicURLContext(ctx context.Context, fileID string "file": {fileID}, } - response, err := fileRequest(ctx, api.httpclient, "files.revokePublicURL", values, api.debug) + response, err := fileRequest(ctx, api.httpclient, "files.revokePublicURL", values, api) if err != nil { return nil, err } @@ -328,7 +324,7 @@ func (api *Client) ShareFilePublicURLContext(ctx context.Context, fileID string) "file": {fileID}, } - response, err := fileRequest(ctx, api.httpclient, "files.sharedPublicURL", values, api.debug) + response, err := fileRequest(ctx, api.httpclient, "files.sharedPublicURL", values, api) if err != nil { return nil, nil, nil, err } |