@bobfrankston/mailx-imap 0.1.33 → 0.1.35
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/index.js +47 -23
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -943,6 +943,9 @@ export class ImapManager extends EventEmitter {
|
|
|
943
943
|
const parsed = await simpleParser(source);
|
|
944
944
|
// Coerce mailparser AddressObject(s) into the flat `{name, address}[]`
|
|
945
945
|
// shape storeMessages's downstream toEmailAddresses expects.
|
|
946
|
+
// RFC 2047 encoded-word decoding (incl. inside quoted-strings) is
|
|
947
|
+
// handled uniformly in db.upsertMessage, not per-callsite — see
|
|
948
|
+
// `decodeHeaderWords` there.
|
|
946
949
|
const flat = (a) => {
|
|
947
950
|
if (!a)
|
|
948
951
|
return [];
|
|
@@ -3121,33 +3124,54 @@ export class ImapManager extends EventEmitter {
|
|
|
3121
3124
|
return;
|
|
3122
3125
|
if (!draftUid && !draftId)
|
|
3123
3126
|
return;
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3127
|
+
let succeeded = false;
|
|
3128
|
+
try {
|
|
3129
|
+
await this.withConnection(accountId, async (client) => {
|
|
3130
|
+
if (draftUid) {
|
|
3131
|
+
try {
|
|
3132
|
+
await client.deleteMessageByUid(drafts.path, draftUid);
|
|
3133
|
+
console.log(` [drafts] Deleted draft UID ${draftUid}`);
|
|
3134
|
+
succeeded = true;
|
|
3135
|
+
}
|
|
3136
|
+
catch (e) {
|
|
3137
|
+
console.error(` [drafts] Delete by UID ${draftUid} failed: ${e.message}`);
|
|
3138
|
+
}
|
|
3132
3139
|
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
+
if (draftId) {
|
|
3141
|
+
try {
|
|
3142
|
+
const uids = await client.searchByHeader(drafts.path, "X-Mailx-Draft-ID", draftId);
|
|
3143
|
+
for (const uid of uids) {
|
|
3144
|
+
try {
|
|
3145
|
+
await client.deleteMessageByUid(drafts.path, uid);
|
|
3146
|
+
succeeded = true;
|
|
3147
|
+
}
|
|
3148
|
+
catch { /* next */ }
|
|
3140
3149
|
}
|
|
3141
|
-
|
|
3150
|
+
if (uids.length > 0)
|
|
3151
|
+
console.log(` [drafts] Deleted ${uids.length} draft(s) by ID ${draftId}`);
|
|
3152
|
+
}
|
|
3153
|
+
catch (e) {
|
|
3154
|
+
console.error(` [drafts] searchByHeader for ${draftId} failed: ${e.message}`);
|
|
3142
3155
|
}
|
|
3143
|
-
if (uids.length > 0)
|
|
3144
|
-
console.log(` [drafts] Deleted ${uids.length} draft(s) by ID ${draftId}`);
|
|
3145
|
-
}
|
|
3146
|
-
catch (e) {
|
|
3147
|
-
console.error(` [drafts] searchByHeader for ${draftId} failed: ${e.message}`);
|
|
3148
3156
|
}
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
catch (e) {
|
|
3160
|
+
// withConnection itself failed (no socket, auth refresh wedged) —
|
|
3161
|
+
// fall through to queue a retry if we have a UID to anchor on.
|
|
3162
|
+
console.error(` [drafts] withConnection failed for ${accountId}: ${e?.message || e}`);
|
|
3163
|
+
}
|
|
3164
|
+
// Reliable cleanup: if the inline attempt didn't actually delete the
|
|
3165
|
+
// draft, queue a sync_action so the regular processSyncActions loop
|
|
3166
|
+
// retries it later. Without this, transient IMAP failures left stale
|
|
3167
|
+
// drafts in the folder ("draft droppings" that pile up after sends).
|
|
3168
|
+
// Only the UID path can be queued — searchByHeader retries on every
|
|
3169
|
+
// future call anyway, and queuing a header-lookup isn't a real
|
|
3170
|
+
// sync_action shape.
|
|
3171
|
+
if (!succeeded && draftUid) {
|
|
3172
|
+
console.log(` [drafts] Queueing sync_action for retry: delete UID ${draftUid} in ${drafts.path}`);
|
|
3173
|
+
this.db.queueSyncAction(accountId, "delete", draftUid, drafts.id);
|
|
3174
|
+
}
|
|
3151
3175
|
}
|
|
3152
3176
|
/** Queue outgoing message locally — never fails, worker handles IMAP+SMTP.
|
|
3153
3177
|
* Single path: write `~/.mailx/outbox/<acct>/*.ltr` synchronously, then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@bobfrankston/mailx-types": "^0.1.10",
|
|
13
13
|
"@bobfrankston/mailx-settings": "^0.1.14",
|
|
14
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
14
|
+
"@bobfrankston/mailx-store": "^0.1.17",
|
|
15
15
|
"@bobfrankston/iflow-direct": "^0.1.39",
|
|
16
16
|
"@bobfrankston/tcp-transport": "^0.1.6",
|
|
17
17
|
"@bobfrankston/smtp-direct": "^0.1.8",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@bobfrankston/mailx-types": "^0.1.10",
|
|
41
41
|
"@bobfrankston/mailx-settings": "^0.1.14",
|
|
42
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
42
|
+
"@bobfrankston/mailx-store": "^0.1.17",
|
|
43
43
|
"@bobfrankston/iflow-direct": "^0.1.39",
|
|
44
44
|
"@bobfrankston/tcp-transport": "^0.1.6",
|
|
45
45
|
"@bobfrankston/smtp-direct": "^0.1.8",
|