FIX: don't allow blocked user to send emails in

This commit is contained in:
Régis Hanol
2016-02-11 10:39:57 +01:00
parent 5120dcfb3d
commit cad7fc1062
6 changed files with 28 additions and 3 deletions

View File

@ -13,6 +13,7 @@ module Email
class AutoGeneratedEmailError < ProcessingError; end
class NoBodyDetectedError < ProcessingError; end
class InactiveUserError < ProcessingError; end
class BlockedUserError < ProcessingError; end
class BadDestinationAddress < ProcessingError; end
class StrangersNotAllowedError < ProcessingError; end
class InsufficientTrustLevelError < ProcessingError; end
@ -53,8 +54,9 @@ module Email
body = select_body || ""
raise AutoGeneratedEmailError if is_auto_generated?
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
raise InactiveUserError if !user.active && !user.staged
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
raise InactiveUserError if !user.active && !user.staged
raise BlockedUserError if user.blocked
if action = subscription_action_for(body, subject)
message = SubscriptionMailer.send(action, user)