mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 18:22:53 +00:00
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:
2
Gemfile
2
Gemfile
@@ -94,7 +94,7 @@ gem 'twitty', '~> 0.1.5'
|
||||
# facebook client
|
||||
gem 'koala'
|
||||
# slack client
|
||||
gem 'slack-ruby-client', '~> 2.2.0'
|
||||
gem 'slack-ruby-client', '~> 2.5.1'
|
||||
# for dialogflow integrations
|
||||
gem 'google-cloud-dialogflow-v2', '>= 0.24.0'
|
||||
gem 'grpc'
|
||||
|
||||
@@ -272,7 +272,8 @@ GEM
|
||||
googleauth (~> 1.0)
|
||||
grpc (~> 1.36)
|
||||
geocoder (1.8.1)
|
||||
gli (2.21.1)
|
||||
gli (2.22.2)
|
||||
ostruct
|
||||
globalid (1.2.1)
|
||||
activesupport (>= 6.1)
|
||||
gmail_xoauth (0.4.3)
|
||||
@@ -537,6 +538,7 @@ GEM
|
||||
openssl (3.2.0)
|
||||
orm_adapter (0.5.0)
|
||||
os (1.1.4)
|
||||
ostruct (0.6.1)
|
||||
parallel (1.23.0)
|
||||
parser (3.2.2.1)
|
||||
ast (~> 2.4.1)
|
||||
@@ -745,12 +747,13 @@ GEM
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
slack-ruby-client (2.2.0)
|
||||
slack-ruby-client (2.5.1)
|
||||
faraday (>= 2.0)
|
||||
faraday-mashify
|
||||
faraday-multipart
|
||||
gli
|
||||
hashie
|
||||
logger
|
||||
snaky_hash (2.0.1)
|
||||
hashie
|
||||
version_gem (~> 1.1, >= 1.1.1)
|
||||
@@ -951,7 +954,7 @@ DEPENDENCIES
|
||||
sidekiq (>= 7.3.1)
|
||||
sidekiq-cron (>= 1.12.0)
|
||||
simplecov (= 0.17.1)
|
||||
slack-ruby-client (~> 2.2.0)
|
||||
slack-ruby-client (~> 2.5.1)
|
||||
spring
|
||||
spring-watcher-listen
|
||||
squasher
|
||||
|
||||
@@ -119,12 +119,14 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
||||
def upload_file
|
||||
return unless message.attachments.first.with_attached_file?
|
||||
|
||||
result = slack_client.files_upload({
|
||||
channels: hook.reference_id,
|
||||
result = slack_client.files_upload_v2(
|
||||
filename: message.attachments.first.file.filename,
|
||||
content: message.attachments.first.file.download,
|
||||
initial_comment: 'Attached File!',
|
||||
thread_ts: conversation.identifier
|
||||
}.merge(file_information))
|
||||
Rails.logger.info(result)
|
||||
thread_ts: conversation.identifier,
|
||||
channel_id: hook.reference_id
|
||||
)
|
||||
Rails.logger.info "slack_upload_result: #{result}"
|
||||
end
|
||||
|
||||
def file_type
|
||||
|
||||
@@ -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!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user