diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-12-26 11:02:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-26 11:02:59 -0500 |
commit | 9b35b9ff417e8ec9888deac1e66c2855677164cd (patch) | |
tree | 82dc9a20a23b855f91f743c5029ec7a97a35b824 /actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb | |
parent | b5ed468492387d42a44ca6af525d4a274cda756d (diff) | |
parent | a5b2fff64ca0c1fa7be5124f40a251d991c10a85 (diff) | |
download | rails-9b35b9ff417e8ec9888deac1e66c2855677164cd.tar.gz rails-9b35b9ff417e8ec9888deac1e66c2855677164cd.tar.bz2 rails-9b35b9ff417e8ec9888deac1e66c2855677164cd.zip |
Merge pull request #34786 from georgeclaghorn/actionmailbox
Import Action Mailbox
Diffstat (limited to 'actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb')
-rw-r--r-- | actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb b/actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb new file mode 100644 index 0000000000..7f7b0e004e --- /dev/null +++ b/actionmailbox/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class Rails::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, :in_reply_to, :subject, :body).to_h + end + + def create_inbound_email(mail) + ActionMailbox::InboundEmail.create! raw_email: \ + { io: StringIO.new(mail.to_s), filename: "inbound.eml", content_type: "message/rfc822" } + end +end |