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