diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-08-12 16:24:22 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-08-12 16:24:22 +0200 |
commit | c4ae7aab6f9f66073b0200a837652df5942e9b7b (patch) | |
tree | 39be81a1bd3270e2a32a11be3340bf26a463f858 /app/models/custom_emoji.rb | |
parent | aa485d6f055b93fd7a9df8b47ed96122b38af39e (diff) | |
parent | 74111bbb1c643aae516bd4bcb201052161ee725d (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/models/custom_emoji.rb')
-rw-r--r-- | app/models/custom_emoji.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 514cf4845..643a7e46a 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -28,6 +28,8 @@ class CustomEmoji < ApplicationRecord :(#{SHORTCODE_RE_FRAGMENT}): (?=[^[:alnum:]:]|$)/x + IMAGE_MIME_TYPES = %w(image/png image/gif image/webp).freeze + belongs_to :category, class_name: 'CustomEmojiCategory', optional: true has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode @@ -35,7 +37,7 @@ class CustomEmoji < ApplicationRecord before_validation :downcase_domain - validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { less_than: LIMIT } + validates_attachment :image, content_type: { content_type: IMAGE_MIME_TYPES }, presence: true, size: { less_than: LIMIT } validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 } scope :local, -> { where(domain: nil) } |