The global reserve is claimed atomically with the budget check by deleting a live attempt for the same address (under 5 failures, under 3 resends, chain under 30 minutes), so it cannot fund mail to other addresses, branch or race.
5 lines
350 B
SQL
5 lines
350 B
SQL
-- Resends from a browser with a live attempt may draw on a reserved global budget, but
|
|
-- only along a bounded chain: each attempt records how many resends led to it and when
|
|
-- the chain began.
|
|
ALTER TABLE email_attempts ADD COLUMN resends INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE email_attempts ADD COLUMN chain_started INTEGER NOT NULL DEFAULT 0;
|