Sha256: 0493e8475dca07b74578d8ecb1e90c33539ef93f72d1160e6233a777e333ac35

Contents?: true

Size: 1.11 KB

Versions: 35

Compression:

Stored size: 1.11 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(mail_params.except(:attachments).to_h).tap do |mail|
          mail[:bcc]&.include_in_headers = true
          mail_params[:attachments].to_a.each do |attachment|
            mail.add_file(filename: attachment.original_filename, content: attachment.read)
          end
        end
      end

      def mail_params
        params.require(:mail).permit(:from, :to, :cc, :bcc, :x_original_to, :in_reply_to, :subject, :body, attachments: [])
      end

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

Version data entries

35 entries across 31 versions & 2 rubygems

Version Path
actionmailbox-6.1.7.10 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.9 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.8 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.7 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionmailbox-6.1.6.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionmailbox-7.0.2.3/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionmailbox-7.0.3.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.6 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.5 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.4 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionmailbox-7.0.3.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionmailbox-7.0.2.3/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionmailbox-6.1.6.1/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.3 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.7 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.0.3.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.6.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-6.1.6 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb