-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate ActionMailbox into `RequestMailer.receive` for inbound email handling. This maintains existing functionality but lays the groundwork for future enhancements. Added an `origin` column to the ActionMailbox::InboundEmail table. This change was necessary to preserve the functionality of checking the mail `source`, avoiding a naming clash with the `source` method. Benefits of using ActionMailbox include: 1. Enhanced email routing capabilities, enabling specialized processing like the Excel hidden data spreadsheet analyzer. 2. Refactoring opportunities for `RequestMailer#receive`, particularly for spam detection, duplicate email handling, and initial request assessment. 3. Clear separation of concerns between Mailers (for sending) and Mailboxes (for receiving). 4. Improved email processing efficiency through ActionMailbox, facilitating background job handling and potential simplification of mail ingress. 5. Provides a solution for re-users to receive emails without needing their own mail server setup. WIP
- Loading branch information
Showing
10 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationMailbox < ActionMailbox::Base | ||
Check warning on line 1 in app/mailboxes/application_mailbox.rb GitHub Actions / build
|
||
routing all: :request | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class RequestMailbox < ApplicationMailbox | ||
Check warning on line 1 in app/mailboxes/request_mailbox.rb GitHub Actions / build
|
||
def process | ||
mail = MailHandler.mail_from_raw_email(inbound_email.source) | ||
|
||
RequestMailer.new.receive( | ||
mail, | ||
inbound_email.source, | ||
inbound_email.origin&.to_sym | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
db/migrate/20231214125336_create_action_mailbox_tables.action_mailbox.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This migration comes from action_mailbox (originally 20180917164000) | ||
class CreateActionMailboxTables < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :action_mailbox_inbound_emails do |t| | ||
t.integer :status, default: 0, null: false | ||
t.string :message_id, null: false | ||
t.string :message_checksum, null: false | ||
|
||
t.timestamps | ||
|
||
t.index [ :message_id, :message_checksum ], name: "index_action_mailbox_inbound_emails_uniqueness", unique: true | ||
Check warning on line 11 in db/migrate/20231214125336_create_action_mailbox_tables.action_mailbox.rb GitHub Actions / build
Check warning on line 11 in db/migrate/20231214125336_create_action_mailbox_tables.action_mailbox.rb GitHub Actions / build
Check warning on line 11 in db/migrate/20231214125336_create_action_mailbox_tables.action_mailbox.rb GitHub Actions / build
|
||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20231214135151_add_origin_to_action_mailbox_inbound_emails.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddOriginToActionMailboxInboundEmails < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :action_mailbox_inbound_emails, :origin, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe RequestMailbox, type: :mailbox do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |