diff --git a/app/models/upload.rb b/app/models/upload.rb index 9bc97dfc5..cfe822956 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,6 +1,8 @@ class Upload < ApplicationRecord class Error < StandardError; end + MAX_VIDEO_DURATION = 140 + class FileValidator < ActiveModel::Validator def validate(record) validate_file_ext(record) @@ -53,8 +55,8 @@ class Upload < ApplicationRecord end def validate_video_duration(record) - if !record.uploader.is_admin? && record.media_file.is_video? && record.media_file.duration > 120 - record.errors.add(:base, "video must not be longer than 2 minutes") + if !record.uploader.is_admin? && record.media_file.is_video? && record.media_file.duration > MAX_VIDEO_DURATION + record.errors.add(:base, "video must not be longer than #{MAX_VIDEO_DURATION.seconds.inspect}") end end end diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 86c58c815..1e7080776 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -336,6 +336,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest should_upload_successfully("https://twitter.com/noizave/status/875768175136317440") should_upload_successfully("https://pbs.twimg.com/media/DCdZ_FhUIAAYKFN?format=jpg&name=medium") should_upload_successfully("https://pbs.twimg.com/profile_banners/2371694594/1581832507/1500x500") + should_upload_successfully("https://twitter.com/zeth_total/1355597580814585856") # XXX should_upload_successfully("https://video.twimg.com/tweet_video/EWHWVrmVcAAp4Vw.mp4") should_upload_successfully("https://www.weibo.com/5501756072/J2UNKfbqV")