Sha256: c2cea0d9299e1615ed0ebe7ee2eb4f029bd2342404f6c46b754b1c1eb78f2d13

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module MailSpy
  class TrackingController < ApplicationController

    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

    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

    def action
      email_id = params[:eid]
      action_type = params[:action_type]
      count = params[:count] || 1
      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)

      MailSpy.track_action(email_id, action_type, details, count)
      head 200
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mail_spy-0.0.9 app/controllers/mail_spy/tracking_controller.rb
mail_spy-0.0.8 app/controllers/mail_spy/tracking_controller.rb
mail_spy-0.0.7 app/controllers/mail_spy/tracking_controller.rb
mail_spy-0.0.6 app/controllers/mail_spy/tracking_controller.rb