Class: Admin::InboundEmailsController

Inherits:
CrmController
  • Object
show all
Defined in:
app/controllers/admin/inbound_emails_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/admin/inbound_emails_controller.rb', line 6

def index
  @status_filter = params[:status].presence
  scope = ActionMailbox::InboundEmail.order(created_at: :desc)
  scope = scope.where(status: @status_filter) if @status_filter.present?
  @pagy, @inbound_emails = pagy(scope, limit: 50)
  @status_counts = ActionMailbox::InboundEmail.group(:status).count
end

#reprocessObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/admin/inbound_emails_controller.rb', line 18

def reprocess
  @inbound_email = ActionMailbox::InboundEmail.find(params[:id])
  @inbound_email.pending!

  begin
    @inbound_email.route
    flash[:success] = "Email ##{@inbound_email.id} reprocessed successfully. New status: #{@inbound_email.reload.status}"
  rescue StandardError => e
    flash[:error] = "Error reprocessing email ##{@inbound_email.id}: #{e.class}: #{e.message}"
  end

  redirect_to admin_inbound_emails_path(status: params[:return_status])
end

#showObject



14
15
16
# File 'app/controllers/admin/inbound_emails_controller.rb', line 14

def show
  @inbound_email = ActionMailbox::InboundEmail.find(params[:id])
end