Sha256: 6ae8f8e2ace042d00045fd2a795b9d60bbbc2948b42a5ade61944ac81913427f

Contents?: true

Size: 1.02 KB

Versions: 20

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Rails
  class Conductor::ActionMailbox::InboundEmailsController < Rails::Conductor::BaseController
    def index
      @inbound_emails = ActionMailbox::InboundEmail.order(created_at: :desc)
    end

    def new
    end

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

    def create
      inbound_email = create_inbound_email(new_mail)
      redirect_to main_app.rails_conductor_inbound_email_url(inbound_email)
    end

    private
      def new_mail
        Mail.new(params.require(:mail).permit(:from, :to, :cc, :bcc, :x_original_to, :in_reply_to, :subject, :body).to_h).tap do |mail|
          mail[:bcc]&.include_in_headers = true
          params[:mail][:attachments].to_a.each do |attachment|
            mail.add_file(filename: attachment.original_filename, content: attachment.read)
          end
        end
      end

      def create_inbound_email(mail)
        ActionMailbox::InboundEmail.create_and_extract_message_id!(mail.to_s)
      end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
actionmailbox-6.1.4.7 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.6 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.5 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.4 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.3 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionmailbox-6.1.4.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/actionmailbox-6.1.4.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/actionmailbox-6.1.4/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.4 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.3.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.3.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.3 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.2.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.0 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.0.rc2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.0.rc1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb