diff --git a/lib/integrations/slack/slack_message_helper.rb b/lib/integrations/slack/slack_message_helper.rb index 52ec4caad..0ee328fb3 100644 --- a/lib/integrations/slack/slack_message_helper.rb +++ b/lib/integrations/slack/slack_message_helper.rb @@ -70,7 +70,9 @@ module Integrations::Slack::SlackMessageHelper case attachment[:filetype] when 'png', 'jpeg', 'gif', 'bmp', 'tiff', 'jpg' :image - when 'pdf' + when 'mp4', 'avi', 'mov', 'wmv', 'flv', 'webm' + :video + else :file 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 608324e8f..2ce206489 100644 --- a/spec/lib/integrations/slack/incoming_message_builder_spec.rb +++ b/spec/lib/integrations/slack/incoming_message_builder_spec.rb @@ -157,6 +157,19 @@ describe Integrations::Slack::IncomingMessageBuilder do expect(conversation.messages.count).to eql(messages_count) end + + it 'handles different file types correctly' do + expect(hook).not_to be_nil + video_attachment_params = message_with_attachments.deep_dup + video_attachment_params[:event][:files][0][:filetype] = 'mp4' + video_attachment_params[:event][:files][0][:mimetype] = 'video/mp4' + + builder = described_class.new(video_attachment_params) + allow(builder).to receive(:sender).and_return(nil) + + expect { builder.perform }.not_to raise_error + expect(conversation.messages.last.attachments).to be_any + end end context 'when link shared' do