Add block checks into `User#answer`

This commit is contained in:
Karina Kwiatek 2022-06-11 23:14:01 +02:00 committed by Karina Kwiatek
parent e9fa3b83b2
commit 65309edd8f
1 changed files with 3 additions and 0 deletions

View File

@ -106,6 +106,9 @@ class User < ApplicationRecord
# @param question [Question] the question to answer
# @param content [String] the answer content
def answer(question, content)
raise Errors::AnsweringOtherBlockedSelf if question.user.blocking?(self)
raise Errors::AnsweringSelfBlockedOther if self.blocking?(question.user)
Answer.create!(content: content,
user: self,
question: question)