DEV: Pass the is_image flag when triggering the before_upload_creation event (#10031)

This commit is contained in:
Roman Rizzi 2020-06-11 11:06:48 -03:00 committed by GitHub
parent 3d55f2e3b7
commit a4bfa35420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -34,16 +34,14 @@ class UploadCreator
return @upload
end
DiscourseEvent.trigger(:before_upload_creation, @file)
@image_info = FastImage.new(@file) rescue nil
is_image = FileHelper.is_supported_image?(@filename)
is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")
is_image = false if @opts[:for_theme]
DiscourseEvent.trigger(:before_upload_creation, @file, is_image)
DistributedMutex.synchronize("upload_#{user_id}_#{@filename}") do
# test for image regardless of input
@image_info = FastImage.new(@file) rescue nil
is_image = FileHelper.is_supported_image?(@filename)
is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")
is_image = false if @opts[:for_theme]
if is_image
extract_image_info!
return @upload if @upload.errors.present?