Sha256: 63c08c77b2addfb5902ddd878844d237966e527d6c711ee5ca5f3db45fad314d

Contents?: true

Size: 937 Bytes

Versions: 22

Compression:

Stored size: 937 Bytes

Contents

require_dependency "ishapi/application_controller"

module ::Ishapi
  class EmailUnsubscribesController < ApplicationController

    layout false

    def create
      authorize! :open_permission, ::Ishapi
      @lead = Lead.find params[:lead_id]

      if( !params[:token] ||
          @lead.unsubscribe_token != params[:token] )
        render code: 400, message: "We're sorry, but something went wrong. Please try again later."
        return
      end

      @unsubscribe = ::Ish::EmailUnsubscribe.find_or_create_by({
        lead_id:     params[:lead_id],
        template_id: params[:template_id],
        campaign_id: params[:campaign_id],
      })
      flag = @unsubscribe.update_attributes({
        unsubscribed_at: Time.now,
      })
      if flag
        flash_notice "You have been unsubscribed."
      else
        flash_alert "We're sorry, but something went wrong. Please try again later."
      end

    end
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ishapi-0.1.8.316 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.315 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.314 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.313 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.312 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.310 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.309 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.308 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.307 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.306 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.305 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.304 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.303 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.302 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.301 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.300 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.298 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.297 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.296 app/controllers/ishapi/email_unsubscribes_controller.rb
ishapi-0.1.8.295 app/controllers/ishapi/email_unsubscribes_controller.rb