0
0
Fork 0

Use normalizes to prepare CustomEmoji domain value (#28624)

This commit is contained in:
Matt Jankowski 2024-01-08 06:20:59 -05:00 committed by GitHub
parent 202951e6d9
commit aa6d07dbd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 10 deletions

View file

@ -41,7 +41,7 @@ class CustomEmoji < ApplicationRecord
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set date:modify +set date:create +set date:timestamp' } }, validate_media_type: false
before_validation :downcase_domain
normalizes :domain, with: ->(domain) { domain.downcase }
validates_attachment :image, content_type: { content_type: IMAGE_MIME_TYPES }, presence: true, size: { less_than: LIMIT }
validates :shortcode, uniqueness: { scope: :domain }, format: { with: SHORTCODE_ONLY_RE }, length: { minimum: 2 }
@ -95,8 +95,4 @@ class CustomEmoji < ApplicationRecord
def remove_entity_cache
Rails.cache.delete(EntityCache.instance.to_key(:emoji, shortcode, domain))
end
def downcase_domain
self.domain = domain.downcase unless domain.nil?
end
end