forked from lug/matterbridge
Update dependencies (#2180)
* Update dependencies * Fix whatsmeow API changes
This commit is contained in:
84
vendor/github.com/slack-go/slack/files.go
generated
vendored
84
vendor/github.com/slack-go/slack/files.go
generated
vendored
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// Add here the defaults in the siten
|
||||
// Add here the defaults in the site
|
||||
DEFAULT_FILES_USER = ""
|
||||
DEFAULT_FILES_CHANNEL = ""
|
||||
DEFAULT_FILES_TS_FROM = 0
|
||||
@@ -234,12 +234,14 @@ func (api *Client) fileRequest(ctx context.Context, path string, values url.Valu
|
||||
return response, response.Err()
|
||||
}
|
||||
|
||||
// GetFileInfo retrieves a file and related comments
|
||||
// GetFileInfo retrieves a file and related comments.
|
||||
// For more details, see GetFileInfoContext documentation.
|
||||
func (api *Client) GetFileInfo(fileID string, count, page int) (*File, []Comment, *Paging, error) {
|
||||
return api.GetFileInfoContext(context.Background(), fileID, count, page)
|
||||
}
|
||||
|
||||
// GetFileInfoContext retrieves a file and related comments with a custom context
|
||||
// GetFileInfoContext retrieves a file and related comments with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.info
|
||||
func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count, page int) (*File, []Comment, *Paging, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -255,24 +257,25 @@ func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count,
|
||||
return &response.File, response.Comments, &response.Paging, nil
|
||||
}
|
||||
|
||||
// GetFile retrieves a given file from its private download URL
|
||||
// GetFile retrieves a given file from its private download URL.
|
||||
func (api *Client) GetFile(downloadURL string, writer io.Writer) error {
|
||||
return api.GetFileContext(context.Background(), downloadURL, writer)
|
||||
}
|
||||
|
||||
// GetFileContext retrieves a given file from its private download URL with a custom context
|
||||
//
|
||||
// GetFileContext retrieves a given file from its private download URL with a custom context.
|
||||
// For more details, see GetFile documentation.
|
||||
func (api *Client) GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error {
|
||||
return downloadFile(ctx, api.httpclient, api.token, downloadURL, writer, api)
|
||||
}
|
||||
|
||||
// GetFiles retrieves all files according to the parameters given
|
||||
// GetFiles retrieves all files according to the parameters given.
|
||||
// For more details, see GetFilesContext documentation.
|
||||
func (api *Client) GetFiles(params GetFilesParameters) ([]File, *Paging, error) {
|
||||
return api.GetFilesContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// GetFilesContext retrieves all files according to the parameters given with a custom context
|
||||
// GetFilesContext retrieves all files according to the parameters given with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.list
|
||||
func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameters) ([]File, *Paging, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -313,13 +316,13 @@ func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameter
|
||||
}
|
||||
|
||||
// ListFiles retrieves all files according to the parameters given. Uses cursor based pagination.
|
||||
// For more details, see ListFilesContext documentation.
|
||||
func (api *Client) ListFiles(params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
return api.ListFilesContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// ListFilesContext retrieves all files according to the parameters given with a custom context.
|
||||
//
|
||||
// For more details, see ListFiles documentation.
|
||||
// Slack API docs: https://api.slack.com/methods/files.list
|
||||
func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -351,12 +354,16 @@ func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParamet
|
||||
return response.Files, ¶ms, nil
|
||||
}
|
||||
|
||||
// UploadFile uploads a file
|
||||
// UploadFile uploads a file.
|
||||
// DEPRECATED: Use UploadFileV2 instead. This will stop functioning on March 11, 2025.
|
||||
// For more details, see: https://api.slack.com/methods/files.upload#markdown
|
||||
func (api *Client) UploadFile(params FileUploadParameters) (file *File, err error) {
|
||||
return api.UploadFileContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// UploadFileContext uploads a file and setting a custom context
|
||||
// UploadFileContext uploads a file and setting a custom context.
|
||||
// DEPRECATED: Use UploadFileV2Context instead. This will stop functioning on March 11, 2025.
|
||||
// For more details, see: https://api.slack.com/methods/files.upload#markdown
|
||||
func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParameters) (file *File, err error) {
|
||||
// Test if user token is valid. This helps because client.Do doesn't like this for some reason. XXX: More
|
||||
// investigation needed, but for now this will do.
|
||||
@@ -404,12 +411,14 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam
|
||||
return &response.File, response.Err()
|
||||
}
|
||||
|
||||
// DeleteFileComment deletes a file's comment
|
||||
// DeleteFileComment deletes a file's comment.
|
||||
// For more details, see DeleteFileCommentContext documentation.
|
||||
func (api *Client) DeleteFileComment(commentID, fileID string) error {
|
||||
return api.DeleteFileCommentContext(context.Background(), fileID, commentID)
|
||||
}
|
||||
|
||||
// DeleteFileCommentContext deletes a file's comment with a custom context
|
||||
// DeleteFileCommentContext deletes a file's comment with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.comments.delete
|
||||
func (api *Client) DeleteFileCommentContext(ctx context.Context, fileID, commentID string) (err error) {
|
||||
if fileID == "" || commentID == "" {
|
||||
return ErrParametersMissing
|
||||
@@ -424,12 +433,14 @@ func (api *Client) DeleteFileCommentContext(ctx context.Context, fileID, comment
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteFile deletes a file
|
||||
// DeleteFile deletes a file.
|
||||
// For more details, see DeleteFileContext documentation.
|
||||
func (api *Client) DeleteFile(fileID string) error {
|
||||
return api.DeleteFileContext(context.Background(), fileID)
|
||||
}
|
||||
|
||||
// DeleteFileContext deletes a file with a custom context
|
||||
// DeleteFileContext deletes a file with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.delete
|
||||
func (api *Client) DeleteFileContext(ctx context.Context, fileID string) (err error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -440,12 +451,14 @@ func (api *Client) DeleteFileContext(ctx context.Context, fileID string) (err er
|
||||
return err
|
||||
}
|
||||
|
||||
// RevokeFilePublicURL disables public/external sharing for a file
|
||||
// RevokeFilePublicURL disables public/external sharing for a file.
|
||||
// For more details, see RevokeFilePublicURLContext documentation.
|
||||
func (api *Client) RevokeFilePublicURL(fileID string) (*File, error) {
|
||||
return api.RevokeFilePublicURLContext(context.Background(), fileID)
|
||||
}
|
||||
|
||||
// RevokeFilePublicURLContext disables public/external sharing for a file with a custom context
|
||||
// RevokeFilePublicURLContext disables public/external sharing for a file with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.revokePublicURL
|
||||
func (api *Client) RevokeFilePublicURLContext(ctx context.Context, fileID string) (*File, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -459,12 +472,14 @@ func (api *Client) RevokeFilePublicURLContext(ctx context.Context, fileID string
|
||||
return &response.File, nil
|
||||
}
|
||||
|
||||
// ShareFilePublicURL enabled public/external sharing for a file
|
||||
// ShareFilePublicURL enabled public/external sharing for a file.
|
||||
// For more details, see ShareFilePublicURLContext documentation.
|
||||
func (api *Client) ShareFilePublicURL(fileID string) (*File, []Comment, *Paging, error) {
|
||||
return api.ShareFilePublicURLContext(context.Background(), fileID)
|
||||
}
|
||||
|
||||
// ShareFilePublicURLContext enabled public/external sharing for a file with a custom context
|
||||
// ShareFilePublicURLContext enabled public/external sharing for a file with a custom context.
|
||||
// Slack API docs: https://api.slack.com/methods/files.sharedPublicURL
|
||||
func (api *Client) ShareFilePublicURLContext(ctx context.Context, fileID string) (*File, []Comment, *Paging, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -478,7 +493,7 @@ func (api *Client) ShareFilePublicURLContext(ctx context.Context, fileID string)
|
||||
return &response.File, response.Comments, &response.Paging, nil
|
||||
}
|
||||
|
||||
// getUploadURLExternal gets a URL and fileID from slack which can later be used to upload a file
|
||||
// getUploadURLExternal gets a URL and fileID from slack which can later be used to upload a file.
|
||||
func (api *Client) getUploadURLExternal(ctx context.Context, params getUploadURLExternalParameters) (*getUploadURLExternalResponse, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
@@ -504,9 +519,8 @@ func (api *Client) getUploadURLExternal(ctx context.Context, params getUploadURL
|
||||
func (api *Client) uploadToURL(ctx context.Context, params uploadToURLParameters) (err error) {
|
||||
values := url.Values{}
|
||||
if params.Content != "" {
|
||||
values.Add("content", params.Content)
|
||||
values.Add("token", api.token)
|
||||
err = postForm(ctx, api.httpclient, params.UploadURL, values, nil, api)
|
||||
contentReader := strings.NewReader(params.Content)
|
||||
err = postWithMultipartResponse(ctx, api.httpclient, params.UploadURL, params.Filename, "file", api.token, values, contentReader, nil, api)
|
||||
} else if params.File != "" {
|
||||
err = postLocalWithMultipartResponse(ctx, api.httpclient, params.UploadURL, params.File, "file", api.token, values, nil, api)
|
||||
} else if params.Reader != nil {
|
||||
@@ -523,11 +537,13 @@ func (api *Client) completeUploadExternal(ctx context.Context, fileID string, pa
|
||||
return nil, err
|
||||
}
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
"files": {string(requestBytes)},
|
||||
"channel_id": {params.channel},
|
||||
"token": {api.token},
|
||||
"files": {string(requestBytes)},
|
||||
}
|
||||
|
||||
if params.channel != "" {
|
||||
values.Add("channel_id", params.channel)
|
||||
}
|
||||
if params.initialComment != "" {
|
||||
values.Add("initial_comment", params.initialComment)
|
||||
}
|
||||
@@ -545,18 +561,18 @@ func (api *Client) completeUploadExternal(ctx context.Context, fileID string, pa
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// UploadFileV2 uploads file to a given slack channel using 3 steps -
|
||||
// 1. Get an upload URL using files.getUploadURLExternal API
|
||||
// 2. Send the file as a post to the URL provided by slack
|
||||
// 3. Complete the upload and share it to the specified channel using files.completeUploadExternal
|
||||
// UploadFileV2 uploads file to a given slack channel using 3 steps.
|
||||
// For more details, see UploadFileV2Context documentation.
|
||||
func (api *Client) UploadFileV2(params UploadFileV2Parameters) (*FileSummary, error) {
|
||||
return api.UploadFileV2Context(context.Background(), params)
|
||||
}
|
||||
|
||||
// UploadFileV2 uploads file to a given slack channel using 3 steps with a custom context -
|
||||
// UploadFileV2Context uploads file to a given slack channel using 3 steps -
|
||||
// 1. Get an upload URL using files.getUploadURLExternal API
|
||||
// 2. Send the file as a post to the URL provided by slack
|
||||
// 3. Complete the upload and share it to the specified channel using files.completeUploadExternal
|
||||
//
|
||||
// Slack Docs: https://api.slack.com/messaging/files#uploading_files
|
||||
func (api *Client) UploadFileV2Context(ctx context.Context, params UploadFileV2Parameters) (file *FileSummary, err error) {
|
||||
if params.Filename == "" {
|
||||
return nil, fmt.Errorf("file.upload.v2: filename cannot be empty")
|
||||
@@ -564,9 +580,7 @@ func (api *Client) UploadFileV2Context(ctx context.Context, params UploadFileV2P
|
||||
if params.FileSize == 0 {
|
||||
return nil, fmt.Errorf("file.upload.v2: file size cannot be 0")
|
||||
}
|
||||
if params.Channel == "" {
|
||||
return nil, fmt.Errorf("file.upload.v2: channel cannot be empty")
|
||||
}
|
||||
|
||||
u, err := api.getUploadURLExternal(ctx, getUploadURLExternalParameters{
|
||||
altText: params.AltTxt,
|
||||
fileName: params.Filename,
|
||||
|
||||
Reference in New Issue
Block a user