Disallow commenting when blocked by the answer's author

This commit is contained in:
Karina Kwiatek 2022-06-09 19:44:58 +02:00 committed by Karina Kwiatek
parent bd0a4532a5
commit b4e5037469
2 changed files with 9 additions and 0 deletions

View File

@ -150,6 +150,9 @@ class User < ApplicationRecord
end end
def comment(answer, content) 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) Comment.create!(user: self, answer: answer, content: content)
end end

View File

@ -73,5 +73,11 @@ module Errors
class AnsweringSelfBlockedOther < SelfBlockedOther class AnsweringSelfBlockedOther < SelfBlockedOther
end end
class CommentingSelfBlockedOther < SelfBlockedOther
end
class CommentingOtherBlockedSelf < OtherBlockedSelf
end
# endregion # endregion
end end