From 698684843748b9b847b8a6cf8cd2a30e3b507884 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 22 Jun 2019 16:54:06 +0200 Subject: port tootsuite#11151 to monsterfork: Fix audio-only OGG and WebM files not being processed as such Also, because Chrome sends audio/mp3 instead of audio/mpeg as it's supposed to, we need to whitelist that mime type as well --- app/models/concerns/attachmentable.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/concerns') diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb index 08af107c7..c3c7c7a35 100644 --- a/app/models/concerns/attachmentable.rb +++ b/app/models/concerns/attachmentable.rb @@ -11,10 +11,21 @@ module Attachmentable before_post_process :obfuscate_file_name before_post_process :set_file_extensions before_post_process :check_image_dimensions + before_post_process :set_file_content_type end private + def set_file_content_type + self.class.attachment_definitions.each_key do |attachment_name| + attachment = send(attachment_name) + + next if attachment.blank? || attachment.queued_for_write[:original].blank? + + attachment.instance_write :content_type, calculated_content_type(attachment) + end + end + def set_file_extensions self.class.attachment_definitions.each_key do |attachment_name| attachment = send(attachment_name) -- cgit