Add disable custom emoji validation on emoji_reaction
This commit is contained in:
parent
7bce7745f6
commit
77c6121503
1 changed files with 5 additions and 0 deletions
|
@ -7,6 +7,7 @@ class EmojiReactionValidator < ActiveModel::Validator
|
|||
return if emoji_reaction.name.blank?
|
||||
|
||||
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.blank? && !unicode_emoji?(emoji_reaction.name)
|
||||
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.present? && disabled_custom_emoji?(emoji_reaction.custom_emoji)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -14,4 +15,8 @@ class EmojiReactionValidator < ActiveModel::Validator
|
|||
def unicode_emoji?(name)
|
||||
SUPPORTED_EMOJIS.include?(name)
|
||||
end
|
||||
|
||||
def disabled_custom_emoji?(custom_emoji)
|
||||
custom_emoji.nil? ? false : custom_emoji.disabled
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue