diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-12 16:42:16 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-12 16:42:16 +0000 |
commit | 734f1142f82549524b467f8247ad3bea9257d5c0 (patch) | |
tree | 08ca5316ca0c4f9fd2c53f61fcf1058983437aae /app/models/incoming_message.rb | |
parent | 883a720e0efbf44e198dffd8efcf65f8d219b08e (diff) | |
parent | 0aafbd4a25b5c4c0edbd87c2224dcdd18388ede5 (diff) |
Merge branch 'release/0.5' into develop
Diffstat (limited to 'app/models/incoming_message.rb')
-rw-r--r-- | app/models/incoming_message.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index f0f1680eb..2186d50dc 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -128,21 +128,23 @@ class IncomingMessage < ActiveRecord::Base # values in case we want to regenerate them (due to mail # parsing bugs, etc). if (!force.nil? || self.last_parsed.nil?) - self.extract_attachments! - self.sent_at = self.mail.date || self.created_at - self.subject = self.mail.subject - # XXX can probably remove from_name_if_present (which is a - # monkey patch) by just calling .from_addrs[0].name here - # instead? - self.mail_from = self.mail.from_name_if_present - begin - self.mail_from_domain = PublicBody.extract_domain_from_email(self.mail.from_addrs[0].spec) - rescue NoMethodError - self.mail_from_domain = "" + ActiveRecord::Base.transaction do + self.extract_attachments! + self.sent_at = self.mail.date || self.created_at + self.subject = self.mail.subject + # XXX can probably remove from_name_if_present (which is a + # monkey patch) by just calling .from_addrs[0].name here + # instead? + self.mail_from = self.mail.from_name_if_present + begin + self.mail_from_domain = PublicBody.extract_domain_from_email(self.mail.from_addrs[0].spec) + rescue NoMethodError + self.mail_from_domain = "" + end + self.valid_to_reply_to = self._calculate_valid_to_reply_to + self.last_parsed = Time.now + self.save! end - self.valid_to_reply_to = self._calculate_valid_to_reply_to - self.last_parsed = Time.now - self.save! end end |