Class: MailSpy::TrackingController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mail_spy/tracking_controller.rb

Instance Method Summary collapse

Instance Method Details

#actionObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/mail_spy/tracking_controller.rb', line 33

def action
  email_id = params[:eid]
  action_type = params[:action_type]
  details = params[:details]

  head :unprocessable_entity and return if email_id.blank? || action_type.blank?
  head :unprocessable_entity and return if details.present? && !details.kind_of?(Hash)

  hash ={}
  hash[:action_type] = action_type
  hash[:count] = params[:count] if !params[:count].nil?
  hash[:details] = details if details.present? && details.kind_of?(Hash)

  # Save it up
  email = MailSpy::Email.find(email_id)
  email.actions.create!(hash)

  head 200
end

#bugObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/mail_spy/tracking_controller.rb', line 20

def bug
  email_id = params[:eid]
  head :unprocessable_entity and return if email_id.blank?

  #Mark the email as opened
  email = MailSpy::Email.find(email_id)
  email.actions.create!(
    :action_type => MailSpy::Action::ACTION_TYPE_OPEN
  )

  head 200
end


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/mail_spy/tracking_controller.rb', line 4

def link
  email_id = params[:eid]
  head :unprocessable_entity and return if email_id.blank?

  email = MailSpy::Email.find(email_id)
  email.actions.create!(
    :action_type => MailSpy::Action::ACTION_TYPE_CLICK,
    :details => {
      :url => params[:url],
      :link_number => params[:n]
    }
  )

  redirect_to params[:url]
end