aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailbox/test/dummy/db
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2019-01-17 11:13:40 -0600
committerPratik Naik <pratiknaik@gmail.com>2019-01-17 11:13:40 -0600
commit5cd733a334846669d6435517f7d9913c4a9b1eb1 (patch)
treeb79c74e9f818c53c8b2a800ef500d1334f3b574f /actionmailbox/test/dummy/db
parent2dee59fed1e78b983aed4db53dc8fc59e49b9200 (diff)
downloadrails-5cd733a334846669d6435517f7d9913c4a9b1eb1.tar.gz
rails-5cd733a334846669d6435517f7d9913c4a9b1eb1.tar.bz2
rails-5cd733a334846669d6435517f7d9913c4a9b1eb1.zip
Ensure Action Mailbox processes an email only once when received multiple times
This also adds a new column, message_checksum, to the action_mailbox_inbound_emails table for storing SHA1 digest of the email source. Additionally, it makes generating the missing message id deterministic and adds a unique index on message_checksum and message_id to detect duplicate emails.
Diffstat (limited to 'actionmailbox/test/dummy/db')
-rw-r--r--actionmailbox/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb5
-rw-r--r--actionmailbox/test/dummy/db/schema.rb2
2 files changed, 6 insertions, 1 deletions
diff --git a/actionmailbox/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb b/actionmailbox/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb
index 0124b4b98f..f587f37095 100644
--- a/actionmailbox/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb
+++ b/actionmailbox/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb
@@ -2,10 +2,13 @@ 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
+ t.string :message_id, null: false
+ t.string :message_checksum, null: false
t.datetime :created_at, precision: 6
t.datetime :updated_at, precision: 6
+
+ t.index [ :message_id, :message_checksum ], unique: true
end
end
end
diff --git a/actionmailbox/test/dummy/db/schema.rb b/actionmailbox/test/dummy/db/schema.rb
index 6cfe7de765..4aba92bfc6 100644
--- a/actionmailbox/test/dummy/db/schema.rb
+++ b/actionmailbox/test/dummy/db/schema.rb
@@ -15,8 +15,10 @@ ActiveRecord::Schema.define(version: 2018_02_12_164506) do
create_table "action_mailbox_inbound_emails", force: :cascade do |t|
t.integer "status", default: 0, null: false
t.string "message_id"
+ t.string "message_checksum"
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
+ t.index ["message_id", "message_checksum"], name: "index_action_mailbox_inbound_emails_uniqueness", unique: true
end
create_table "active_storage_attachments", force: :cascade do |t|