diff --git a/lib/integrations/slack/incoming_message_builder.rb b/lib/integrations/slack/incoming_message_builder.rb index ec4f8e2b5..86c3c232b 100644 --- a/lib/integrations/slack/incoming_message_builder.rb +++ b/lib/integrations/slack/incoming_message_builder.rb @@ -37,7 +37,7 @@ class Integrations::Slack::IncomingMessageBuilder if message.present? SUPPORTED_MESSAGE_TYPES.include?(message[:type]) && !attached_file_message? else - params[:event][:files].any? && !attached_file_message? + params[:event][:files].present? && !attached_file_message? end end diff --git a/spec/lib/integrations/slack/incoming_message_builder_spec.rb b/spec/lib/integrations/slack/incoming_message_builder_spec.rb index 1695331c3..0eede30cf 100644 --- a/spec/lib/integrations/slack/incoming_message_builder_spec.rb +++ b/spec/lib/integrations/slack/incoming_message_builder_spec.rb @@ -61,6 +61,15 @@ describe Integrations::Slack::IncomingMessageBuilder do expect(conversation.messages.count).to eql(messages_count) end + it 'does not create message for invalid event type and event files is not present' do + messages_count = conversation.messages.count + message_with_attachments[:event][:files] = nil + builder = described_class.new(message_with_attachments) + allow(builder).to receive(:sender).and_return(nil) + builder.perform + expect(conversation.messages.count).to eql(messages_count) + end + it 'saves attachment if params files present' do expect(hook).not_to eq nil messages_count = conversation.messages.count