feat(email-service): Delay sending emails for undo functionality#1071
feat(email-service): Delay sending emails for undo functionality#1071evanhutnik merged 7 commits intomainfrom
Conversation
Code ReviewI found one issue during the code review: Missing check for
|
| email-service:internal_auth_key: document-storage-service-auth-key-prod | ||
| email-service:cf_private_key: email-attachments-private-key-prod | ||
| email-service:notifications_enabled: true | ||
| email-service:sent_undo_delay_secs: 1 |
There was a problem hiding this comment.
we probably want this higher no?
There was a problem hiding this comment.
increased to 5 seconds for now
| pub contacts_queue: String, | ||
|
|
||
| /// The amount of time to delay processing of a sent message (undo send window) | ||
| pub sent_undo_delay_secs: u32, |
There was a problem hiding this comment.
can you add a comment here that it defaults to 10 seconds
| let notifications = fetch_pending_scheduled_messages(&ctx.db) | ||
| .await | ||
| .unwrap_or_else(|e| { | ||
| tracing::error!("Error fetching scheduled messages: {}", e); |
There was a problem hiding this comment.
please use the correct format
Summary
Add undo-send functionality by delaying email delivery through a configurable window.
Changes
Send Message Flow
Send Messageendpoint called Gmail's API directly to send messages immediately.SENT_UNDO_DELAY_SECS), allowing users to undo the send before the pubsub worker processes it.When users click "Undo" in the frontend, it calls the delete_scheduled_send endpoint, which converts the message back to a draft.
Configuration
SENT_UNDO_DELAY_SECSenvironment variable (initially set to 5 seconds)Infrastructure
Database
processingboolean toemail_scheduled_messagestable to prevent race conditions when users attempt to unschedule a message that's actively being sent (cleaner thanSELECT FOR UPDATElocks given potentially long send transactions with attachments)API Changes
send_timeoutside ofMessageToSendfor cleaner logic (old field retained temporarily for backward compatibility)Lambda Changes
is_draft = trueto exclude sent emails still within the undo window