@remit/smtp-worker 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -87,11 +87,18 @@ export interface SendMessageDeps {
|
|
|
87
87
|
*/
|
|
88
88
|
resolveCredentials: (account: AccountItem) => Promise<CredentialResolution>;
|
|
89
89
|
/**
|
|
90
|
-
* Persist the account's connectionState
|
|
91
|
-
*
|
|
92
|
-
* re-auths (mirrors the
|
|
90
|
+
* Persist the account's connectionState, and with it the sentence the
|
|
91
|
+
* account card shows. Called when a terminal OAuth/SMTP auth failure is
|
|
92
|
+
* detected so the account is fenced off until the user re-auths (mirrors the
|
|
93
|
+
* IMAP withOAuthLifecycle contract). `lastError` carries the server's own
|
|
94
|
+
* words when the refusal came with any, and its absence clears the stored
|
|
95
|
+
* reason rather than leaving an older failure to describe this one.
|
|
93
96
|
*/
|
|
94
|
-
updateConnectionState: (
|
|
97
|
+
updateConnectionState: (
|
|
98
|
+
accountId: string,
|
|
99
|
+
state: string,
|
|
100
|
+
lastError?: string,
|
|
101
|
+
) => Promise<void>;
|
|
95
102
|
send: typeof sendMail;
|
|
96
103
|
emitAppendSentMessage: (
|
|
97
104
|
accountId: string,
|
|
@@ -268,10 +275,14 @@ export const sendMessage = async (
|
|
|
268
275
|
throw err;
|
|
269
276
|
}
|
|
270
277
|
log.warn(
|
|
271
|
-
{ accountId, errorKind: err.kind },
|
|
278
|
+
{ accountId, errorKind: err.kind, error: err.message },
|
|
272
279
|
"SMTP auth rejected; marking account reauth_required",
|
|
273
280
|
);
|
|
274
|
-
await deps.updateConnectionState(
|
|
281
|
+
await deps.updateConnectionState(
|
|
282
|
+
accountId,
|
|
283
|
+
"reauth_required",
|
|
284
|
+
err.message,
|
|
285
|
+
);
|
|
275
286
|
await settleBlockedOnReauth();
|
|
276
287
|
return; // ACK — do not retry
|
|
277
288
|
}
|
|
@@ -311,10 +322,14 @@ export const sendMessage = async (
|
|
|
311
322
|
account.authType === AccountAuthType.OauthMicrosoft
|
|
312
323
|
) {
|
|
313
324
|
log.warn(
|
|
314
|
-
{ accountId, errorKind: err.kind },
|
|
325
|
+
{ accountId, errorKind: err.kind, error: err.message },
|
|
315
326
|
"SMTP auth rejected during send; marking account reauth_required",
|
|
316
327
|
);
|
|
317
|
-
await deps.updateConnectionState(
|
|
328
|
+
await deps.updateConnectionState(
|
|
329
|
+
accountId,
|
|
330
|
+
"reauth_required",
|
|
331
|
+
err.message,
|
|
332
|
+
);
|
|
318
333
|
await settleBlockedOnReauth(OutboxMessageStatus.sending);
|
|
319
334
|
return; // ACK — do not retry
|
|
320
335
|
}
|
|
@@ -162,12 +162,19 @@ export const handleSendMessage = (
|
|
|
162
162
|
secrets,
|
|
163
163
|
resolveCredentials: (account) =>
|
|
164
164
|
resolveConnectionCredentials(account, credentialDeps),
|
|
165
|
-
|
|
165
|
+
// A flip with no reason of its own removes the stored one, so the card
|
|
166
|
+
// never reads back a failure the account has moved on from.
|
|
167
|
+
updateConnectionState: async (id, state, lastError) => {
|
|
166
168
|
const { account } = await getPorts();
|
|
167
|
-
await account.update(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
await account.update(
|
|
170
|
+
id,
|
|
171
|
+
{
|
|
172
|
+
connectionState:
|
|
173
|
+
state as (typeof ConnectionState)[keyof typeof ConnectionState],
|
|
174
|
+
lastError,
|
|
175
|
+
},
|
|
176
|
+
lastError === undefined ? ["lastError"] : undefined,
|
|
177
|
+
);
|
|
171
178
|
},
|
|
172
179
|
send: sendMail,
|
|
173
180
|
emitAppendSentMessage,
|