Prevent blocked users from reacting on comments

This commit is contained in:
Karina Kwiatek 2022-06-12 23:11:27 +02:00 committed by Karina Kwiatek
parent 25ed1e4605
commit e64d4f3ca7
1 changed files with 5 additions and 0 deletions

View File

@ -142,6 +142,11 @@ class User < ApplicationRecord
# smiles a comment # smiles a comment
# @param comment [Comment] the comment to smile # @param comment [Comment] the comment to smile
def smile_comment(comment) def smile_comment(comment)
# rubocop:disable Style/RedundantSelf
raise Errors::ReactingSelfBlockedOther if self.blocking?(comment.user)
raise Errors::ReactingOtherBlockedSelf if comment.user.blocking?(self)
# rubocop:enable Style/RedundantSelf
CommentSmile.create!(user: self, comment: comment) CommentSmile.create!(user: self, comment: comment)
end end