chore: Slack file upload changes (#10903)

The Slack `files.upload` API endpoint is deprecated and will stop
functioning on March 11, 2025. In this PR, we have implemented the
changes for the [new file
upload](https://api.slack.com/messaging/files#uploading_files) method.
This commit is contained in:
Muhsin Keloth
2025-02-19 12:14:30 +05:30
committed by GitHub
parent 8a5b007bc4
commit 031199f15a
4 changed files with 21 additions and 18 deletions

View File

@@ -162,15 +162,13 @@ describe Integrations::Slack::SendOnSlackService do
attachment = message.attachments.new(account_id: message.account_id, file_type: :image)
attachment.file.attach(io: Rails.root.join('spec/assets/avatar.png').open, filename: 'avatar.png', content_type: 'image/png')
expect(slack_client).to receive(:files_upload).with(hash_including(
channels: hook.reference_id,
thread_ts: conversation.identifier,
initial_comment: 'Attached File!',
filetype: 'png',
content: anything,
filename: attachment.file.filename,
title: attachment.file.filename
)).and_return(file_attachment)
expect(slack_client).to receive(:files_upload_v2).with(
filename: attachment.file.filename,
content: anything,
channel_id: hook.reference_id,
thread_ts: conversation.identifier,
initial_comment: 'Attached File!'
).and_return(file_attachment)
message.save!