Fix #4695: Raise max video length to match Twitter's (2:20).

This commit is contained in:
evazion
2021-02-03 23:58:29 -06:00
parent 3f16fe3d80
commit 520b72948f
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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")