]> cat aescling's git repositories - mastodon.git/commitdiff
Use video filesize limit with gifv (#9924)
authorrinsuki <428rinsuki+git@gmail.com>
Mon, 4 Feb 2019 03:46:05 +0000 (12:46 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 4 Feb 2019 03:46:05 +0000 (04:46 +0100)
app/models/media_attachment.rb

index 2e0f98cc6ff14fa3c70512394d1a2cfd8aeae34b..a57ba0b2ea0ed4e90bd3112967e22e78e8dd3b2b 100644 (file)
@@ -87,8 +87,8 @@ class MediaAttachment < ApplicationRecord
                     convert_options: { all: '-quality 90 -strip' }
 
   validates_attachment_content_type :file, content_type: IMAGE_MIME_TYPES + VIDEO_MIME_TYPES
-  validates_attachment_size :file, less_than: IMAGE_LIMIT, unless: :video?
-  validates_attachment_size :file, less_than: VIDEO_LIMIT, if: :video?
+  validates_attachment_size :file, less_than: IMAGE_LIMIT, unless: :video_or_gifv?
+  validates_attachment_size :file, less_than: VIDEO_LIMIT, if: :video_or_gifv?
   remotable_attachment :file, VIDEO_LIMIT
 
   include Attachmentable
@@ -111,6 +111,10 @@ class MediaAttachment < ApplicationRecord
     file.blank? && remote_url.present?
   end
 
+  def video_or_gifv?
+    video? || gifv?
+  end
+
   def to_param
     shortcode
   end