Disallow commenting when blocked by the answer's author
This commit is contained in:
parent
bd0a4532a5
commit
b4e5037469
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue