app/controllers/ahoy/messages_controller.rb in ahoy_email-0.2.2 vs app/controllers/ahoy/messages_controller.rb in ahoy_email-0.2.3
- old
+ new
@@ -1,25 +1,25 @@
module Ahoy
class MessagesController < ActionController::Base
before_filter :set_message
def open
- if @message and !@message.opened_at
+ if @message && !@message.opened_at
@message.opened_at = Time.now
@message.save!
end
publish :open
send_data Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), type: "image/gif", disposition: "inline"
end
def click
- if @message and !@message.clicked_at
+ if @message && !@message.clicked_at
@message.clicked_at = Time.now
@message.opened_at ||= @message.clicked_at
@message.save!
end
- url = params[:url]
+ url = params[:url].to_s
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), AhoyEmail.secret_token, url)
publish :click, url: params[:url]
if secure_compare(params[:signature], signature)
redirect_to url
else
@@ -52,8 +52,7 @@
res = 0
b.each_byte { |byte| res |= byte ^ l.shift }
res == 0
end
-
end
end