Class: MailerLog::Email
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MailerLog::Email
- Defined in:
- app/models/mailer_log/email.rb
Constant Summary collapse
- STATUSES =
%w[pending sent delivered opened clicked bounced complained].freeze
Instance Method Summary collapse
Instance Method Details
#recipients ⇒ Object
43 44 45 |
# File 'app/models/mailer_log/email.rb', line 43 def recipients (to_addresses + cc_addresses + bcc_addresses).compact.uniq end |
#update_status_from_event!(event_type) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/mailer_log/email.rb', line 28 def update_status_from_event!(event_type) case event_type when 'delivered' update!(status: 'delivered', delivered_at: Time.current) unless opened_at? || clicked_at? when 'opened' update!(status: 'opened', opened_at: Time.current) unless clicked_at? when 'clicked' update!(status: 'clicked', clicked_at: Time.current) when 'bounced', 'failed', 'dropped' update!(status: 'bounced', bounced_at: Time.current) when 'complained' update!(status: 'complained') end end |