diff --git a/.env.production.catcatnya b/.env.production.catcatnya index 9e5a275fb2..6d572f5310 100644 --- a/.env.production.catcatnya +++ b/.env.production.catcatnya @@ -40,5 +40,4 @@ MAX_DISPLAY_NAME_CHARS=50 MAX_POLL_OPTIONS=20 MAX_SEARCH_RESULTS=1000 MAX_REMOTE_EMOJI_SIZE=1048576 -# MAX_REMOTE_AVATAR_SIZE=4194304 IP_RETENTION_PERIOD=86400 diff --git a/.env.production.sample b/.env.production.sample index 2b56299955..ad058b2b79 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -286,13 +286,6 @@ MAX_POLL_OPTION_CHARS=100 # MAX_EMOJI_SIZE=262144 # MAX_REMOTE_EMOJI_SIZE=262144 -# Maximum avatar (upload) sizes -# If undefined or smaller than MAX_AVATAR_SIZE, the value -# of MAX_AVATAR_SIZE will be used for MAX_REMOTE_AVATAR_SIZE -# Units are in bytes -# MAX_AVATAR_SIZE=2097152 -# MAX_REMOTE_AVATAR_SIZE=2097152 - # Optional hCaptcha support # HCAPTCHA_SECRET_KEY= # HCAPTCHA_SITE_KEY= diff --git a/app/models/concerns/account_avatar.rb b/app/models/concerns/account_avatar.rb index 164ae98d2e..0cfd9167cd 100644 --- a/app/models/concerns/account_avatar.rb +++ b/app/models/concerns/account_avatar.rb @@ -4,8 +4,7 @@ module AccountAvatar extend ActiveSupport::Concern IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze - LOCAL_LIMIT = (ENV['MAX_AVATAR_SIZE'] || 2.megabytes).to_i - LIMIT = [LOCAL_LIMIT, (ENV['MAX_REMOTE_AVATAR_SIZE'] || 2.megabytes).to_i].max + LIMIT = 2.megabytes class_methods do def avatar_styles(file) @@ -21,8 +20,7 @@ module AccountAvatar # Avatar upload has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail] validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES - validates_attachment_size :avatar, less_than: LIMIT, unless: :local? - validates_attachment_size :avatar, less_than: LOCAL_LIMIT, if: :local? + validates_attachment_size :avatar, less_than: LIMIT remotable_attachment :avatar, LIMIT, suppress_errors: false end