Sha256: 971b10de6138b7361213fadcfda4f4e0f17f955d4d5a8fde27c8ecc0f65caefe

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

module Workarea
  module Admin
    class UnsubscribesController < Admin::ApplicationController
      skip_before_action :require_login
      skip_before_action :require_admin
      before_action :set_user

      def status_report
        if @user&.update(status_email_recipient: false)
          flash[:success] = t('workarea.admin.unsubscribe.flash_messages.status_report_success')
        else
          flash[:error] = t('workarea.admin.unsubscribe.flash_messages.status_report_error')
        end

        redirect_to storefront.root_url
      end

      def commentable
        commentable = GlobalID::Locator.locate(params[:commentable_id])

        if @user.present? && commentable&.remove_subscription(@user.id)
          flash[:success] = t(
            'workarea.admin.unsubscribe.flash_messages.commentable_success',
            commentable: commentable.name
          )
        else
          flash[:error] = t('workarea.admin.unsubscribe.flash_messages.commentable_error')
        end

        redirect_to storefront.root_url
      end

      private

      def set_user
        @user ||= User.find_by_token(params[:id])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.15 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/unsubscribes_controller.rb