From e64d4f3ca71e149d168ddca1f0e07ac7ec589cf2 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 12 Jun 2022 23:11:27 +0200 Subject: [PATCH] Prevent blocked users from reacting on comments --- app/models/user.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 3de6a619..c3f9b1ef 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -142,6 +142,11 @@ class User < ApplicationRecord # smiles a comment # @param comment [Comment] the comment to smile 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) end