diff --git a/app/models/emoji_reaction.rb b/app/models/emoji_reaction.rb index 80d92c2424..011e593bfd 100644 --- a/app/models/emoji_reaction.rb +++ b/app/models/emoji_reaction.rb @@ -28,6 +28,7 @@ class EmojiReaction < ApplicationRecord has_one :notification, as: :activity, dependent: :destroy + validate :status_same_emoji_reaction validate :status_emoji_reactions_count after_create :refresh_cache @@ -53,6 +54,12 @@ class EmojiReaction < ApplicationRecord query end + def status_same_emoji_reaction + if status && account && status.emoji_reactions.where(account: account).where(name: name).where(custom_emoji_id: custom_emoji_id).any? + raise Mastodon::ValidationError, I18n.t('reactions.errors.duplication') + end + end + def status_emoji_reactions_count if status && account && status.emoji_reactions.where(account: account).count >= EMOJI_REACTION_PER_ACCOUNT_LIMIT raise Mastodon::ValidationError, I18n.t('reactions.errors.limit_reached') diff --git a/config/locales/en.yml b/config/locales/en.yml index 50934a335d..8b41597056 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1423,6 +1423,7 @@ en: title: Privacy Policy reactions: errors: + duplication: Cannot react same things limit_reached: Limit of different reactions reached unrecognized_emoji: is not a recognized emoji relationships: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 989a5b0a09..d8ec9ed394 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1390,6 +1390,7 @@ ja: title: プライバシーポリシー reactions: errors: + duplication: 同じリアクションを複数行おうとしました limit_reached: リアクションの種類が上限に達しました unrecognized_emoji: は絵文字として認識されていません relationships: