Improve admin UI for custom emojis, add copy/disable/enable (#5231)
This commit is contained in:
parent
b9c76e2edb
commit
49cc0eb3e7
13 changed files with 330 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue