summaryrefslogtreecommitdiff
path: root/app/models/custom_emoji.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/custom_emoji.rb')
-rw-r--r--app/models/custom_emoji.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb
index 643b4060ad6..ed22d4ba231 100644
--- a/app/models/custom_emoji.rb
+++ b/app/models/custom_emoji.rb
@@ -3,14 +3,21 @@
class CustomEmoji < ApplicationRecord
belongs_to :namespace, inverse_of: :custom_emoji
+ belongs_to :group, -> { where(type: 'Group') }, foreign_key: 'namespace_id'
+
+ # For now only external emoji are supported. See https://gitlab.com/gitlab-org/gitlab/-/issues/230467
+ validates :external, inclusion: { in: [true] }
+
+ validates :file, public_url: true, if: :external
+
validate :valid_emoji_name
- validates :namespace, presence: true
+ validates :group, presence: true
validates :name,
uniqueness: { scope: [:namespace_id, :name] },
presence: true,
length: { maximum: 36 },
- format: { with: /\A\w+\z/ }
+ format: { with: /\A([a-z0-9]+[-_]?)+[a-z0-9]+\z/ }
private