Merge pull request #1019 from lucamzanon/fix/compose-error-recovery

fix: keep the draft when a send is not confirmed
This commit is contained in:
Linus Rath
2026-10-02 10:32:27 +02:00
2 changed files with 27 additions and 3 deletions
+10 -2
View File
@@ -3868,7 +3868,8 @@ export class JMAPClient implements IJMAPClient {
if (response.methodResponses?.[0]?.[0] === "Email/set") {
const result = response.methodResponses[0][1];
if (result.notCreated) {
// An empty notCreated map is a success some servers spell out.
if (result.notCreated && Object.keys(result.notCreated).length) {
const errors = result.notCreated;
const firstError = Object.values(errors)[0] as { description?: string; type?: string };
console.error('Draft save error:', firstError);
@@ -4134,7 +4135,7 @@ export class JMAPClient implements IJMAPClient {
if (response.methodResponses) {
for (const [methodName, result] of response.methodResponses) {
if (result.notCreated) {
if (result.notCreated && Object.keys(result.notCreated).length) {
// Include method name + full error object so it's clear whether the
// failure came from Email/set (draft create) or EmailSubmission/set
// (actual send) and which JMAP error type/properties were returned.
@@ -4188,6 +4189,13 @@ export class JMAPClient implements IJMAPClient {
}
}
// No EmailSubmission came back - a method error, or no answer for it at
// all. Nothing confirms the message left: report a failure and keep the
// old draft rather than replacing it as if the send had worked.
if (!emailSubmissionId) {
throw new Error('Send confirmation was not received. Check Sent before sending again. Your draft has been kept.');
}
// With every recipient refused nothing was queued, yet the submission
// exists and its onSuccessUpdateEmail filed the copy into Sent (#1123).
// Drop that copy and keep the old draft: the send failed.