diff options
author | Robin Houston <robin@lenny.robin> | 2011-09-07 13:02:40 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-09-07 13:02:40 +0100 |
commit | 6e200cc8e025d1989fcfacb99b7e9e70cf7540d1 (patch) | |
tree | 460e1fc86a1aeef465e97658d5ef4ff3a52ca986 | |
parent | 8978e9d23082732074cf447416625e1979d6f598 (diff) |
Record bounces
Add information to the users model recording whether email to a user
has bounced hard (meaning we should not try to send further messages
to that email address).
-rw-r--r-- | app/models/user.rb | 22 | ||||
m--------- | commonlib | 0 |
2 files changed, 22 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index fddb6b035..1043474d3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,8 @@ # admin_level :string(255) default("none"), not null # ban_text :text default(""), not null # about_me :text default(""), not null +# email_bounced_at :datetime +# email_bounce_message :string(1024) default(""), not null # # models/user.rb: @@ -351,5 +353,25 @@ class User < ActiveRecord::Base def create_new_salt self.salt = self.object_id.to_s + rand.to_s end + + def record_bounce(message) + self.email_bounced_at = Time.now + self.email_bounce_message = message + self.save! + end + + def should_be_emailed? + return (self.email_confirmed && self.email_bounced_at.nil?) + end + + def User.record_bounce_for_email(email, message) + user = self.find_user_by_email(email) + return false if user.nil? + + if user.self.email_bounced_at.nil? + user.record_bounce(message) + end + return true + end end diff --git a/commonlib b/commonlib -Subproject cf056c6678d59f74fc29eb2b2c1427573fc643a +Subproject a87ebeae21166b3b4a8a66b32399861fcd6d0c4 |