actionmailbox 6.0.0.beta1 → 6.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +1 -1
- data/app/controllers/action_mailbox/base_controller.rb +1 -5
- data/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb +2 -1
- data/app/jobs/action_mailbox/incineration_job.rb +3 -0
- data/app/models/action_mailbox/inbound_email/incineratable.rb +1 -1
- data/app/views/layouts/rails/conductor.html.erb +1 -0
- data/config/routes.rb +0 -1
- data/db/migrate/20180917164000_create_action_mailbox_tables.rb +1 -5
- data/lib/action_mailbox.rb +1 -0
- data/lib/action_mailbox/engine.rb +3 -12
- data/lib/action_mailbox/gem_version.rb +2 -2
- data/lib/action_mailbox/test_helper.rb +11 -7
- data/lib/rails/generators/installer.rb +1 -1
- data/lib/rails/generators/test_unit/templates/mailbox_test.rb.tt +0 -2
- metadata +18 -16
- data/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa9acac3cac950102cb5612fc2b093021332c03d88b4a4bb8821ca4d4437971d
|
4
|
+
data.tar.gz: c692699865f256282048d88de47e1783e8bae27d9e212a7d2ace6456ef95f95e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8289a08e3d4df08f9324f8eb18a67fec8a483ba99051a0938ee434f07b242f32a95a93454e818c7d20599c4283273c04d287bf47baff28de2094ae520108c757
|
7
|
+
data.tar.gz: ad714eac330be0048402d5f61f0ed089a41671a1ce3cd4c1f16bbcb107a57c0115db4f89afa8df673a6b30dbe56a7781939f63241ac6f27d1243f1b9ac592383
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
## Rails 6.0.1.rc1 (October 31, 2019) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
7
|
+
|
8
|
+
* Fix Bcc header not being included with emails from `create_inbound_email_from` test helpers.
|
9
|
+
|
10
|
+
*jduff*
|
11
|
+
|
12
|
+
|
13
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
14
|
+
|
15
|
+
* No changes.
|
16
|
+
|
17
|
+
|
18
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
19
|
+
|
20
|
+
* No changes.
|
21
|
+
|
22
|
+
|
23
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
24
|
+
|
25
|
+
* No changes.
|
26
|
+
|
27
|
+
|
28
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
29
|
+
|
30
|
+
* Allow skipping incineration of processed emails.
|
31
|
+
|
32
|
+
This can be done by setting `config.action_mailbox.incinerate` to `false`.
|
33
|
+
|
34
|
+
*Pratik Naik*
|
35
|
+
|
36
|
+
|
1
37
|
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
2
38
|
|
3
39
|
* Added to Rails.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Action Mailbox
|
2
2
|
|
3
|
-
Action Mailbox routes incoming emails to controller-like mailboxes for processing in Rails. It ships with ingresses for
|
3
|
+
Action Mailbox routes incoming emails to controller-like mailboxes for processing in Rails. It ships with ingresses for Mailgun, Mandrill, Postmark, and SendGrid. You can also handle inbound mails directly via the built-in Exim, Postfix, and Qmail ingresses.
|
4
4
|
|
5
5
|
The inbound emails are turned into `InboundEmail` records using Active Record and feature lifecycle tracking, storage of the original email on cloud storage via Active Storage, and responsible data handling with on-by-default incineration.
|
6
6
|
|
@@ -3,14 +3,10 @@
|
|
3
3
|
module ActionMailbox
|
4
4
|
# The base class for all Action Mailbox ingress controllers.
|
5
5
|
class BaseController < ActionController::Base
|
6
|
-
skip_forgery_protection
|
6
|
+
skip_forgery_protection if default_protect_from_forgery
|
7
7
|
|
8
8
|
before_action :ensure_configured
|
9
9
|
|
10
|
-
def self.prepare
|
11
|
-
# Override in concrete controllers to run code on load.
|
12
|
-
end
|
13
|
-
|
14
10
|
private
|
15
11
|
def ensure_configured
|
16
12
|
unless ActionMailbox.ingress == ingress_name
|
@@ -21,8 +21,9 @@ module Rails
|
|
21
21
|
private
|
22
22
|
def new_mail
|
23
23
|
Mail.new(params.require(:mail).permit(:from, :to, :cc, :bcc, :in_reply_to, :subject, :body).to_h).tap do |mail|
|
24
|
+
mail[:bcc]&.include_in_headers = true
|
24
25
|
params[:mail][:attachments].to_a.each do |attachment|
|
25
|
-
mail.
|
26
|
+
mail.add_file(filename: attachment.original_filename, content: attachment.read)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -6,6 +6,9 @@ module ActionMailbox
|
|
6
6
|
#
|
7
7
|
# Since this incineration is set for the future, it'll automatically ignore any <tt>InboundEmail</tt>s
|
8
8
|
# that have already been deleted and discard itself if so.
|
9
|
+
#
|
10
|
+
# You can disable incinerating processed emails by setting +config.action_mailbox.incinerate+ or
|
11
|
+
# +ActionMailbox.incinerate+ to +false+.
|
9
12
|
class IncinerationJob < ActiveJob::Base
|
10
13
|
queue_as { ActionMailbox.queues[:incineration] }
|
11
14
|
|
@@ -7,7 +7,7 @@ module ActionMailbox::InboundEmail::Incineratable
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
after_update_commit :incinerate_later, if: -> { status_previously_changed? && processed? }
|
10
|
+
after_update_commit :incinerate_later, if: -> { ActionMailbox.incinerate && status_previously_changed? && processed? }
|
11
11
|
end
|
12
12
|
|
13
13
|
def incinerate_later
|
data/config/routes.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
4
|
scope "/rails/action_mailbox", module: "action_mailbox/ingresses" do
|
5
|
-
post "/amazon/inbound_emails" => "amazon/inbound_emails#create", as: :rails_amazon_inbound_emails
|
6
5
|
post "/mandrill/inbound_emails" => "mandrill/inbound_emails#create", as: :rails_mandrill_inbound_emails
|
7
6
|
post "/postmark/inbound_emails" => "postmark/inbound_emails#create", as: :rails_postmark_inbound_emails
|
8
7
|
post "/relay/inbound_emails" => "relay/inbound_emails#create", as: :rails_relay_inbound_emails
|
@@ -5,11 +5,7 @@ class CreateActionMailboxTables < ActiveRecord::Migration[6.0]
|
|
5
5
|
t.string :message_id, null: false
|
6
6
|
t.string :message_checksum, null: false
|
7
7
|
|
8
|
-
|
9
|
-
t.timestamps precision: 6
|
10
|
-
else
|
11
|
-
t.timestamps
|
12
|
-
end
|
8
|
+
t.timestamps
|
13
9
|
|
14
10
|
t.index [ :message_id, :message_checksum ], name: "index_action_mailbox_inbound_emails_uniqueness", unique: true
|
15
11
|
end
|
data/lib/action_mailbox.rb
CHANGED
@@ -14,6 +14,7 @@ module ActionMailbox
|
|
14
14
|
config.eager_load_namespaces << ActionMailbox
|
15
15
|
|
16
16
|
config.action_mailbox = ActiveSupport::OrderedOptions.new
|
17
|
+
config.action_mailbox.incinerate = true
|
17
18
|
config.action_mailbox.incinerate_after = 30.days
|
18
19
|
|
19
20
|
config.action_mailbox.queues = ActiveSupport::InheritableOptions.new \
|
@@ -22,20 +23,10 @@ module ActionMailbox
|
|
22
23
|
initializer "action_mailbox.config" do
|
23
24
|
config.after_initialize do |app|
|
24
25
|
ActionMailbox.logger = app.config.action_mailbox.logger || Rails.logger
|
26
|
+
ActionMailbox.incinerate = app.config.action_mailbox.incinerate.nil? ? true : app.config.action_mailbox.incinerate
|
25
27
|
ActionMailbox.incinerate_after = app.config.action_mailbox.incinerate_after || 30.days
|
26
28
|
ActionMailbox.queues = app.config.action_mailbox.queues || {}
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
initializer "action_mailbox.ingress" do
|
31
|
-
config.after_initialize do |app|
|
32
|
-
if ActionMailbox.ingress = app.config.action_mailbox.ingress.presence
|
33
|
-
config.to_prepare do
|
34
|
-
if ingress_controller_class = "ActionMailbox::Ingresses::#{ActionMailbox.ingress.to_s.classify}::InboundEmailsController".safe_constantize
|
35
|
-
ingress_controller_class.prepare
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
29
|
+
ActionMailbox.ingress = app.config.action_mailbox.ingress
|
39
30
|
end
|
40
31
|
end
|
41
32
|
end
|
@@ -14,7 +14,11 @@ module ActionMailbox
|
|
14
14
|
#
|
15
15
|
# create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")
|
16
16
|
def create_inbound_email_from_mail(status: :processing, **mail_options)
|
17
|
-
|
17
|
+
mail = Mail.new(mail_options)
|
18
|
+
# Bcc header is not encoded by default
|
19
|
+
mail[:bcc].include_in_headers = true if mail[:bcc]
|
20
|
+
|
21
|
+
create_inbound_email_from_source mail.to_s, status: status
|
18
22
|
end
|
19
23
|
|
20
24
|
# Create an +InboundEmail+ using the raw rfc822 +source+ as text.
|
@@ -29,16 +33,16 @@ module ActionMailbox
|
|
29
33
|
create_inbound_email_from_fixture(*args).tap(&:route)
|
30
34
|
end
|
31
35
|
|
32
|
-
# Create an +InboundEmail+
|
33
|
-
#
|
36
|
+
# Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_mail+ and immediately route it to
|
37
|
+
# processing.
|
34
38
|
def receive_inbound_email_from_mail(**kwargs)
|
35
39
|
create_inbound_email_from_mail(**kwargs).tap(&:route)
|
36
40
|
end
|
37
41
|
|
38
|
-
# Create an +InboundEmail+
|
39
|
-
#
|
40
|
-
def receive_inbound_email_from_source(
|
41
|
-
create_inbound_email_from_source(
|
42
|
+
# Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_source+ and immediately route it
|
43
|
+
# to processing.
|
44
|
+
def receive_inbound_email_from_source(*args)
|
45
|
+
create_inbound_email_from_source(*args).tap(&:route)
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -5,6 +5,6 @@ copy_file "#{__dir__}/mailbox/templates/application_mailbox.rb", "app/mailboxes/
|
|
5
5
|
|
6
6
|
environment <<~end_of_config, env: "production"
|
7
7
|
# Prepare the ingress controller used to receive mail
|
8
|
-
# config.action_mailbox.ingress = :
|
8
|
+
# config.action_mailbox.ingress = :relay
|
9
9
|
|
10
10
|
end_of_config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmailbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,70 +17,70 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 6.0.
|
20
|
+
version: 6.0.1.rc1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 6.0.
|
27
|
+
version: 6.0.1.rc1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activerecord
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 6.0.
|
34
|
+
version: 6.0.1.rc1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 6.0.
|
41
|
+
version: 6.0.1.rc1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: activestorage
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 6.0.
|
48
|
+
version: 6.0.1.rc1
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 6.0.
|
55
|
+
version: 6.0.1.rc1
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: activejob
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - '='
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 6.0.
|
62
|
+
version: 6.0.1.rc1
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - '='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 6.0.
|
69
|
+
version: 6.0.1.rc1
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: actionpack
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - '='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 6.0.
|
76
|
+
version: 6.0.1.rc1
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - '='
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 6.0.
|
83
|
+
version: 6.0.1.rc1
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: mail
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- MIT-LICENSE
|
108
108
|
- README.md
|
109
109
|
- app/controllers/action_mailbox/base_controller.rb
|
110
|
-
- app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb
|
111
110
|
- app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
|
112
111
|
- app/controllers/action_mailbox/ingresses/mandrill/inbound_emails_controller.rb
|
113
112
|
- app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb
|
@@ -160,8 +159,11 @@ homepage: https://rubyonrails.org
|
|
160
159
|
licenses:
|
161
160
|
- MIT
|
162
161
|
metadata:
|
163
|
-
|
164
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
162
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
163
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/actionmailbox/CHANGELOG.md
|
164
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
|
165
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
|
166
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/actionmailbox
|
165
167
|
post_install_message:
|
166
168
|
rdoc_options: []
|
167
169
|
require_paths:
|
@@ -177,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
179
|
- !ruby/object:Gem::Version
|
178
180
|
version: 1.3.1
|
179
181
|
requirements: []
|
180
|
-
rubygems_version: 3.0.
|
182
|
+
rubygems_version: 3.0.3
|
181
183
|
signing_key:
|
182
184
|
specification_version: 4
|
183
185
|
summary: Inbound email handling framework.
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionMailbox
|
4
|
-
# Ingests inbound emails from Amazon's Simple Email Service (SES).
|
5
|
-
#
|
6
|
-
# Requires the full RFC 822 message in the +content+ parameter. Authenticates requests by validating their signatures.
|
7
|
-
#
|
8
|
-
# Returns:
|
9
|
-
#
|
10
|
-
# - <tt>204 No Content</tt> if an inbound email is successfully recorded and enqueued for routing to the appropriate mailbox
|
11
|
-
# - <tt>401 Unauthorized</tt> if the request's signature could not be validated
|
12
|
-
# - <tt>404 Not Found</tt> if Action Mailbox is not configured to accept inbound emails from SES
|
13
|
-
# - <tt>422 Unprocessable Entity</tt> if the request is missing the required +content+ parameter
|
14
|
-
# - <tt>500 Server Error</tt> if one of the Active Record database, the Active Storage service, or
|
15
|
-
# the Active Job backend is misconfigured or unavailable
|
16
|
-
#
|
17
|
-
# == Usage
|
18
|
-
#
|
19
|
-
# 1. Install the {aws-sdk-sns}[https://rubygems.org/gems/aws-sdk-sns] gem:
|
20
|
-
#
|
21
|
-
# # Gemfile
|
22
|
-
# gem "aws-sdk-sns", ">= 1.9.0", require: false
|
23
|
-
#
|
24
|
-
# 2. Tell Action Mailbox to accept emails from SES:
|
25
|
-
#
|
26
|
-
# # config/environments/production.rb
|
27
|
-
# config.action_mailbox.ingress = :amazon
|
28
|
-
#
|
29
|
-
# 3. {Configure SES}[https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications.html]
|
30
|
-
# to deliver emails to your application via POST requests to +/rails/action_mailbox/amazon/inbound_emails+.
|
31
|
-
# If your application lived at <tt>https://example.com</tt>, you would specify the fully-qualified URL
|
32
|
-
# <tt>https://example.com/rails/action_mailbox/amazon/inbound_emails</tt>.
|
33
|
-
class Ingresses::Amazon::InboundEmailsController < BaseController
|
34
|
-
before_action :authenticate
|
35
|
-
|
36
|
-
cattr_accessor :verifier
|
37
|
-
|
38
|
-
def self.prepare
|
39
|
-
self.verifier ||= begin
|
40
|
-
require "aws-sdk-sns"
|
41
|
-
Aws::SNS::MessageVerifier.new
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def create
|
46
|
-
ActionMailbox::InboundEmail.create_and_extract_message_id! params.require(:content)
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
def authenticate
|
51
|
-
head :unauthorized unless verifier.authentic?(request.body)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|