Add disable custom emoji validation on emoji_reaction

This commit is contained in:
KMY 2023-06-13 18:27:28 +09:00
parent 7bce7745f6
commit 77c6121503

View file

@ -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