0
0
Fork 0

Improve admin UI for custom emojis, add copy/disable/enable (#5231)

This commit is contained in:
Eugen Rochko 2017-10-05 23:42:05 +02:00 committed by GitHub
parent b9c76e2edb
commit 49cc0eb3e7
13 changed files with 330 additions and 15 deletions

View file

@ -12,6 +12,7 @@
# image_updated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# disabled :boolean default(FALSE), not null
#
class CustomEmoji < ApplicationRecord
@ -26,10 +27,16 @@ class CustomEmoji < ApplicationRecord
validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { in: 0..50.kilobytes }
validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 }
scope :local, -> { where(domain: nil) }
scope :local, -> { where(domain: nil) }
scope :remote, -> { where.not(domain: nil) }
scope :alphabetic, -> { order(domain: :asc, shortcode: :asc) }
include Remotable
def local?
domain.nil?
end
class << self
def from_text(text, domain)
return [] if text.blank?
@ -38,7 +45,7 @@ class CustomEmoji < ApplicationRecord
return [] if shortcodes.empty?
where(shortcode: shortcodes, domain: domain)
where(shortcode: shortcodes, domain: domain, disabled: false)
end
end
end