From ea1f53f55031c6e85a70c05d5706f220400a4e47 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 29 Aug 2026 22:28:41 +0200 Subject: [PATCH] fix: keep the created message id when the server answers a send with an implicit filing update --- src/api/email.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/email.ts b/src/api/email.ts index 5681fd73..27fe3ca2 100644 --- a/src/api/email.ts +++ b/src/api/email.ts @@ -1185,7 +1185,13 @@ export async function sendEmail( const props = notCreated.properties?.length ? ` (properties: ${notCreated.properties.join(', ')})` : ''; throw new Error(`${notCreated.description ?? notCreated.type ?? 'Failed to create message'}${props}`); } - emailId = (result as { created?: Record }).created?.draft?.id; + // Stalwart answers a submission carrying `onSuccessUpdateEmail` with a + // SECOND `Email/set` response (reusing the submission's call id) that + // reports the filing update and carries no `created`. Only take an id + // when one is actually there - assigning unconditionally overwrote the + // real id with undefined, which silently disabled the undo-send window. + const createdId = (result as { created?: Record }).created?.draft?.id; + if (createdId) emailId = createdId; // Filing problems from onSuccessUpdateEmail come back on the implicit // Email/set; the message already left, so warn rather than fail. const notUpdated = (result as { notUpdated?: Record }).notUpdated;