Sha256: b333f72d343090a63712cab8512597aafd574777e03980152543221e7ea00c5c

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

# :enddoc:

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]&.select(&:present?)&.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

28 entries across 28 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actionmailbox-7.1.3.4/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.2.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.5.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.5 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.1.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.4.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.1.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.4.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.4 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.0 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.0.rc1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionmailbox-7.1.3.4/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.0.beta3 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actionmailbox-7.1.3.4/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.0.beta2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.3.4 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.2.0.beta1 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
actionmailbox-7.1.3.2 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb