Fix movie width and frame_rate returning nil (#14357)
* Fix movie width and frame_rate returning nil * Add StreamValidationError and raise * Fix code styleshrike
parent
47931db1f5
commit
7540e235a2
|
@ -7,6 +7,7 @@ module Mastodon
|
||||||
class HostValidationError < ValidationError; end
|
class HostValidationError < ValidationError; end
|
||||||
class LengthValidationError < ValidationError; end
|
class LengthValidationError < ValidationError; end
|
||||||
class DimensionsValidationError < ValidationError; end
|
class DimensionsValidationError < ValidationError; end
|
||||||
|
class StreamValidationError < ValidationError; end
|
||||||
class RaceConditionError < Error; end
|
class RaceConditionError < Error; end
|
||||||
class RateLimitExceededError < Error; end
|
class RateLimitExceededError < Error; end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Remotable
|
||||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
|
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
|
||||||
Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
|
Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
|
||||||
raise e unless suppress_errors
|
raise e unless suppress_errors
|
||||||
rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError => e
|
rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e
|
||||||
Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
|
Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
|
|
||||||
return unless movie.valid?
|
return unless movie.valid?
|
||||||
|
|
||||||
|
raise Mastodon::StreamValidationError, 'Video has no video stream' if movie.width.nil? || movie.frame_rate.nil?
|
||||||
raise Mastodon::DimensionsValidationError, "#{movie.width}x#{movie.height} videos are not supported" if movie.width * movie.height > MAX_VIDEO_MATRIX_LIMIT
|
raise Mastodon::DimensionsValidationError, "#{movie.width}x#{movie.height} videos are not supported" if movie.width * movie.height > MAX_VIDEO_MATRIX_LIMIT
|
||||||
raise Mastodon::DimensionsValidationError, "#{movie.frame_rate.to_i}fps videos are not supported" if movie.frame_rate > MAX_VIDEO_FRAME_RATE
|
raise Mastodon::DimensionsValidationError, "#{movie.frame_rate.to_i}fps videos are not supported" if movie.frame_rate > MAX_VIDEO_FRAME_RATE
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ class UpdateAccountService < BaseService
|
||||||
check_links(account)
|
check_links(account)
|
||||||
process_hashtags(account)
|
process_hashtags(account)
|
||||||
end
|
end
|
||||||
rescue Mastodon::DimensionsValidationError => de
|
rescue Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => de
|
||||||
account.errors.add(:avatar, de.message)
|
account.errors.add(:avatar, de.message)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue