Disallow reacting to an answer when blocked by its author

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

View File

@ -120,6 +120,9 @@ class User < ApplicationRecord
# smiles an answer
# @param answer [Answer] the answer to smile
def smile(answer)
raise Errors::ReactingSelfBlockedOther if self.blocking?(answer.user)
raise Errors::ReactingOtherBlockedSelf if answer.user.blocking?(self)
Smile.create!(user: self, answer: answer)
end

View File

@ -79,5 +79,11 @@ module Errors
class CommentingOtherBlockedSelf < OtherBlockedSelf
end
class ReactingSelfBlockedOther < SelfBlockedOther
end
class ReactingOtherBlockedSelf < OtherBlockedSelf
end
# endregion
end