diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-05-13 10:58:41 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2015-05-13 10:58:41 +0100 |
commit | aa67dc94f8c5631ae5da889fa2d976196ee63f91 (patch) | |
tree | 1d9da3309826e35aa296637174c6485e2e5542f5 /app | |
parent | 738dcb2a39099be6fa79f1810d87bef90b09c332 (diff) | |
parent | d45fa666cb97f1beb7af93c5cad8f554c2e5de5a (diff) |
Merge branch 'hotfix/0.21.0.28'0.21.0.28
Diffstat (limited to 'app')
-rw-r--r-- | app/mailers/request_mailer.rb | 3 | ||||
-rw-r--r-- | app/models/info_request.rb | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index c9decc6db..252df861c 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -234,8 +234,9 @@ class RequestMailer < ApplicationMailer def requests_matching_email(email) # We deliberately don't use Envelope-to here, so ones that are BCC # drop into the holding pen for checking. + addresses = ((email.to || []) + (email.cc || [])).compact reply_info_requests = [] # TODO: should be set? - for address in (email.to || []) + (email.cc || []) + addresses.each do |address| reply_info_request = InfoRequest.find_by_incoming_email(address) reply_info_requests.push(reply_info_request) if reply_info_request end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 245de1e15..c203f75c3 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -427,6 +427,7 @@ public # A new incoming email to this request def receive(email, raw_email_data, override_stop_new_responses = false, rejected_reason = "") + # Is this request allowing responses? if !override_stop_new_responses allow = nil reason = nil @@ -457,9 +458,15 @@ public raise "Unknown allow_new_responses_from '" + self.allow_new_responses_from + "'" end + # If its not allowing responses, handle the message if !allow if self.handle_rejected_responses == 'bounce' - RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external? + if MailHandler.get_from_address(email).nil? + # do nothing – can't bounce the mail as there's no + # address to send it to + else + RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external? + end elsif self.handle_rejected_responses == 'holding_pen' InfoRequest.holding_pen_request.receive(email, raw_email_data, false, reason) elsif self.handle_rejected_responses == 'blackhole' @@ -921,7 +928,7 @@ public # Called by incoming_email - and used to be called to generate separate # envelope from address until we abandoned it. def magic_email(prefix_part) - raise "id required to make magic" if not self.id + raise "id required to create a magic email" if not self.id return InfoRequest.magic_email_for_id(prefix_part, self.id) end |