about summary refs log tree commit diff
path: root/app/models/media_attachment.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-10-06 16:46:32 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-10-06 16:46:32 +0200
commit079ed6c26d4a894d65cee6430db9e0e17871cf4c (patch)
tree3cd551000662445d4502c6954001e6da87be5107 /app/models/media_attachment.rb
parentb31748a496ac55e3f2763d74ea7e7a7ef5c4dfad (diff)
parent84ceebe1c4a7fbec883e37b90874145caea7bc76 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/models/media_attachment.rb')
-rw-r--r--app/models/media_attachment.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index b57600356..a80087fa3 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -167,12 +167,11 @@ class MediaAttachment < ApplicationRecord
                     processors: ->(f) { file_processors f },
                     convert_options: GLOBAL_CONVERT_OPTIONS
 
-  before_file_post_process :set_type_and_extension
-  before_file_post_process :check_video_dimensions
+  before_file_validate :set_type_and_extension
+  before_file_validate :check_video_dimensions
 
   validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES + AUDIO_MIME_TYPES
-  validates_attachment_size :file, less_than: IMAGE_LIMIT, unless: :larger_media_format?
-  validates_attachment_size :file, less_than: VIDEO_LIMIT, if: :larger_media_format?
+  validates_attachment_size :file, less_than: ->(m) { m.larger_media_format? ? VIDEO_LIMIT : IMAGE_LIMIT }
   remotable_attachment :file, VIDEO_LIMIT, suppress_errors: false, download_on_assign: false, attribute_name: :remote_url
 
   has_attached_file :thumbnail,