Create Action Mailbox Sample Application

Create Action Mailbox Sample Application

Ecf4ad5c20312b8499a615263519290a?s=128

horikawa

June 25, 2019
Tweet

Transcript

  1. 6.

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

    Databases • Parallel Testing • Zeitwerk...etc
  2. 20.

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

    master/actionmailbox/app/models/ action_mailbox/inbound_email.rb • ActiveStorageͱࣅͨΑ͏ͳײ͡??
  3. 22.
  4. 23.

    ϝʔϧαʔϏεड͚ೖΕઃఆ • 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Λαϙʔτ͍ͯ͠Δ
  5. 28.
  6. 30.
  7. 32.

    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
  8. 35.
  9. 36.

    ·ͱΊ • ϝʔϧαʔϏεଆͷઃఆ΋ඞཁʹͳΔ • SendGridͳΒɺInbound ParseͳͲ • SES͸ɺRails 6.1͔ΒͷαϙʔτͱͳΓͦ͏ •

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

    ࢀߟ • 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/