Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Create Action Mailbox Sample Application

Create Action Mailbox Sample Application

horikawa

June 25, 2019
Tweet

More Decks by horikawa

Other Decks in Technology

Transcript

  1. Rails 6.0ͷओཁ௥Ճػೳ • Action Text • Action Mailbox • Multiple

    Databases • Parallel Testing • Zeitwerk...etc
  2. ϝʔϧ͸ɺ
 ActionMailbox::InboundEmail
 Ϟσϧͱͯ͠ѻΘΕΔ • class InboundEmail < ActiveRecord::Base • https://github.com/rails/rails/blob/

    master/actionmailbox/app/models/ action_mailbox/inbound_email.rb • ActiveStorageͱࣅͨΑ͏ͳײ͡??
  3. ϝʔϧαʔϏεड͚ೖΕઃఆ • config/environments/֤؀ڥ.rb
 config.action_mailbox.ingress = # ͜͜ʹαʔϏε໊ # sendgridͷ৔߹ config.action_mailbox.ingress

    = :sendgrid # mailgunͷ৔߹ config.action_mailbox.ingress = :mailgun # exam, mailgun, mandrill, postfix, postmark, qmail, sendgridΛαϙʔτ͍ͯ͠Δ
  4. S3͔ΒϝʔϧϑΝΠϧΛμ΢ϯϩʔυ͢Δ͜ͱͰ Mail::MessageͷϝιουΛ࢖͑Δ • > ActionMailbox::InboundEmail.first.mail.class • D, [2019-06-25T00:41:49.319609 #4] DEBUG

    -- : ActionMailbox::InboundEmail Load (1.5ms) SELECT "action_mailbox_inbound_emails".* FROM "action_mailbox_inbound_emails" ORDER BY "action_mailbox_inbound_emails"."id" ASC LIMIT $1 [["LIMIT", 1]] • D, [2019-06-25T00:41:49.348480 #4] DEBUG -- : ActiveStorage::Attachment Load (2.6ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 9], ["record_type", "ActionMailbox::InboundEmail"], ["name", "raw_email"], ["LIMIT", 1]] • D, [2019-06-25T00:41:49.351096 #4] DEBUG -- : ActiveStorage::Blob Load (1.5ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 9], ["LIMIT", 1]] • I, [2019-06-25T00:41:50.006908 #4] INFO -- : S3 Storage (655.4ms) Downloaded file from key: hogehogehogehogehoge • => Mail::Message
  5. ·ͱΊ • ϝʔϧαʔϏεଆͷઃఆ΋ඞཁʹͳΔ • SendGridͳΒɺInbound ParseͳͲ • SES͸ɺRails 6.1͔ΒͷαϙʔτͱͳΓͦ͏ •

    https://github.com/rails/rails/commit/ f480cfabcd9000b5817b610e21466299025b12d2 • ࣍ճ͸ • ࣗಈฦ৴ͱ͔
 Ϣʔβʔςʔϒϧͱૹ৴͞ΕͨϝʔϧͷΞυϨεΛಥ͖߹Θͤͯɺ
 ͲͷϢʔβʔ͕ϝʔϧΛૹͬͨͷ͔Λ෼͔ΔΑ͏ʹͯ͠ΈΔ • InboundEmail͔Βͷ৘ใऔಘΛͲΕ͚ͩ޻෉Ͱ͖Δ͔
  6. ࢀߟ • Action Mailbox gem • https://github.com/rails/actionmailbox/tree/master • Rails Guides

    • https://edgeguides.rubyonrails.org/ action_mailbox_basics.html • bagelee • https://bagelee.com/programming/ruby-on-rails/rails6- action-mailbox/