Sha256: 45cd7d3eebf5a95e500123a0c4973631b6040ba06355cb946790c875c2f478fe

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 Bytes

Contents

module EmailTracker
  class EmailOpensController < ActionController::Base
    def track_open
      token = params[:token]

      email_open = TrackedEmail.find_by(token: token)
      if email_open.present?
        email_open.opened_at = Time.zone.now
        email_open.save
      end


      # Serve a 1x1 pixel image
      # send_file Rails.root.join('app/assets/images/pixel.png'), type: 'image/png', disposition: 'inline'

      pixel_image_path = File.join(__dir__, 'pixel.png')

      if File.exist?(pixel_image_path)
        send_file pixel_image_path, type: 'image/png', disposition: 'inline'
      else
        render plain: "Image not found", status: :ok
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
custom_email_tracker-0.1.0 app/controllers/email_tracker/email_opens_controller.rb