Merge remote-tracking branch 'parent/main' into upstream-20240918

This commit is contained in:
KMY 2024-09-18 08:31:34 +09:00
commit 4ce35dd837
188 changed files with 1994 additions and 980 deletions

View file

@ -30,6 +30,7 @@ class CustomEmoji < ApplicationRecord
include Attachmentable
LIMIT = 512.kilobytes
MINIMUM_SHORTCODE_SIZE = 2
SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}'
@ -47,7 +48,7 @@ class CustomEmoji < ApplicationRecord
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 }
validates :shortcode, uniqueness: { scope: :domain }, format: { with: SHORTCODE_ONLY_RE }, length: { minimum: MINIMUM_SHORTCODE_SIZE }
scope :local, -> { where(domain: nil) }
scope :remote, -> { where.not(domain: nil) }