Sha256: d422bc06335056f7af04597c88dab227747045dafb837b92f1895b095e690069
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'virtus' require 'uuidtools' class EmailEvents::Service::TrackDataInHeader < EmailEvents::Service include Virtus.model attribute :mailer attribute :sent_email_data_class attribute :data def call # a UUID is much more secure identifier to send along in an email header (as opposed to the db primary key, # for which someone could easily guess a valid integer in an attack) uuid = generate_uuid data_obj = sent_email_data_class.create!( mailer_class: mailer_class, mailer_action: mailer_action, to: recipient_email, uuid: uuid, data: data ) # add the uuid to of the SentEmailData to the email Message-ID header for tracking it add_data_uuid_to_email_headers(uuid) data_obj end private def mailer_class mailer.class.to_s end def mailer_action mailer.action_name end def recipient_email mailer.headers.to.first end def generate_uuid UUIDTools::UUID.random_create.to_s.gsub(/\-/,'') end def add_data_uuid_to_email_headers(content) mailer.headers["Message-ID"] = "<#{content}@uuid.email_events>" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
email_events-1.0 | lib/email_events/services/track_data_in_header.rb |