Class: EmailEvents::Service::TrackDataInHeader

Inherits:
EmailEvents::Service show all
Defined in:
lib/email_events/services/track_data_in_header.rb

Instance Method Summary collapse

Methods inherited from EmailEvents::Service

call

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/email_events/services/track_data_in_header.rb', line 10

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