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.6 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.4 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.3 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.2 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.1 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.0 app/controllers/workarea/admin/unsubscribes_controller.rb
workarea-admin-3.5.0.beta.1 app/controllers/workarea/admin/unsubscribes_controller.rb