diff options
-rw-r--r-- | app/models/incoming_message.rb | 6 | ||||
-rw-r--r-- | app/models/info_request.rb | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 21c15607e..43809074a 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -97,6 +97,12 @@ class IncomingMessage < ActiveRecord::Base self.mail.from_addrs[0].spec end + def addresses + ((self.mail.to || []) + + (self.mail.cc || []) + + (self.mail.envelope_to || [])).uniq + end + # Returns the name of the person the incoming message is from, or nil if # there isn't one or if there is only an email address. XXX can probably # remove from_name_if_present (which is a monkey patch) by just calling diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 89893a396..813e97cdf 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -355,12 +355,7 @@ public def InfoRequest.guess_by_incoming_email(incoming_message) guesses = [] # 1. Try to guess based on the email address(es) - addresses = - (incoming_message.mail.to || []) + - (incoming_message.mail.cc || []) + - (incoming_message.mail.envelope_to || []) - addresses.uniq! - for address in addresses + for address in incoming_message.addresses id, hash = InfoRequest._extract_id_hash_from_email(address) guesses.push(InfoRequest.find_by_id(id)) guesses.push(InfoRequest.find_by_idhash(hash)) |