Skip to content

Commit

Permalink
Merge branch 'master' into docs/inline-docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzoaiello authored Jul 15, 2024
2 parents b9f044c + cab4284 commit c6ee26b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
- '1.18'
- '1.19'
- '1.20'
- '1.21'
- '1.22'
name: test go-${{ matrix.go }}
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Conversation struct {
IsGlobalShared bool `json:"is_global_shared"`
IsPendingExtShared bool `json:"is_pending_ext_shared"`
IsPrivate bool `json:"is_private"`
IsReadOnly bool `json:"is_read_only"`
IsMpIM bool `json:"is_mpim"`
Unlinked int `json:"unlinked"`
NameNormalized string `json:"name_normalized"`
Expand Down
18 changes: 10 additions & 8 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,15 @@ func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParamet
}

// UploadFile uploads a file.
// For more details, see UploadFileContext documentation.
// 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.
// For more details, see: https://api.slack.com/methods/files.upload
// 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.
Expand Down Expand Up @@ -535,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)
}
Expand Down Expand Up @@ -576,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,
Expand Down
9 changes: 9 additions & 0 deletions files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,13 @@ func TestUploadFileV2(t *testing.T) {
if _, err := api.UploadFileV2(params); err != nil {
t.Errorf("Unexpected error: %s", err)
}

reader = bytes.NewBufferString("test no channel")
params = UploadFileV2Parameters{
Filename: "test.txt",
Reader: reader,
FileSize: 15}
if _, err := api.UploadFileV2(params); err != nil {
t.Errorf("Unexpected error: %s", err)
}
}
5 changes: 1 addition & 4 deletions reminders.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ func (api *Client) doReminders(ctx context.Context, path string, values url.Valu

// create an array of pointers to reminders
var reminders = make([]*Reminder, 0, len(response.Reminders))
for _, reminder := range response.Reminders {
reminders = append(reminders, reminder)
}

reminders = append(reminders, response.Reminders...)
return reminders, response.Err()
}

Expand Down
2 changes: 2 additions & 0 deletions webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type WebhookMessage struct {
ReplaceOriginal bool `json:"replace_original"`
DeleteOriginal bool `json:"delete_original"`
ReplyBroadcast bool `json:"reply_broadcast,omitempty"`
UnfurlLinks bool `json:"unfurl_links,omitempty"`
UnfurlMedia bool `json:"unfurl_media,omitempty"`
}

func PostWebhook(url string, msg *WebhookMessage) error {
Expand Down

0 comments on commit c6ee26b

Please sign in to comment.