diff --git a/Gemfile b/Gemfile index 72330acbf..e8639a5bd 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index ff0197a90..080883b67 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/lib/integrations/slack/send_on_slack_service.rb b/lib/integrations/slack/send_on_slack_service.rb index 20a65905c..c1454b869 100644 --- a/lib/integrations/slack/send_on_slack_service.rb +++ b/lib/integrations/slack/send_on_slack_service.rb @@ -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 diff --git a/spec/lib/integrations/slack/send_on_slack_service_spec.rb b/spec/lib/integrations/slack/send_on_slack_service_spec.rb index 6524154b4..684f2bc54 100644 --- a/spec/lib/integrations/slack/send_on_slack_service_spec.rb +++ b/spec/lib/integrations/slack/send_on_slack_service_spec.rb @@ -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!