diff --git a/app/models/user.rb b/app/models/user.rb index de4f37c2..6ae0b3cc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -150,6 +150,9 @@ class User < ApplicationRecord end def comment(answer, content) + raise Errors::CommentingSelfBlockedOther if self.blocking?(answer.user) + raise Errors::CommentingOtherBlockedSelf if answer.user.blocking?(self) + Comment.create!(user: self, answer: answer, content: content) end diff --git a/lib/errors.rb b/lib/errors.rb index ab7a8b7a..a56cb778 100644 --- a/lib/errors.rb +++ b/lib/errors.rb @@ -73,5 +73,11 @@ module Errors class AnsweringSelfBlockedOther < SelfBlockedOther end + + class CommentingSelfBlockedOther < SelfBlockedOther + end + + class CommentingOtherBlockedSelf < OtherBlockedSelf + end # endregion end