@bobfrankston/mailx-store 0.1.38 → 0.1.40
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/db.d.ts +25 -4
- package/db.js +36 -9
- package/package.json +3 -3
- package/store.js +2 -2
package/db.d.ts
CHANGED
|
@@ -294,7 +294,14 @@ export declare class MailxDB {
|
|
|
294
294
|
* is stable. Use this as the identity in any long-lived reference
|
|
295
295
|
* (compose in-reply-to, dally, undo stacks). */
|
|
296
296
|
getMessageByUuid(uuid: string): MessageEnvelope;
|
|
297
|
-
|
|
297
|
+
/** Look up a message's body_path. folderId is REQUIRED when available
|
|
298
|
+
* because (account, uid) is not a unique key — the same numeric UID
|
|
299
|
+
* refers to different messages in INBOX vs Outbox vs Sent etc. Passing
|
|
300
|
+
* no folderId returns the first matching row, which may be the wrong
|
|
301
|
+
* message's body — same class of bug as the parsedCache UID collision.
|
|
302
|
+
* Existing callers without folderId are tolerated (legacy) but should
|
|
303
|
+
* be migrated. */
|
|
304
|
+
getMessageBodyPath(accountId: string, uid: number, folderId?: number): string;
|
|
298
305
|
updateMessageFlags(accountId: string, uid: number, flags: string[]): void;
|
|
299
306
|
updateMessageFolder(accountId: string, uid: number, targetFolderId: number): void;
|
|
300
307
|
/** Local-first move of a message between folders. Updates BOTH the
|
|
@@ -392,9 +399,23 @@ export declare class MailxDB {
|
|
|
392
399
|
* appended at a different real UID). Idempotent: if no row matches
|
|
393
400
|
* (already rebound by an earlier sync), it's a no-op. */
|
|
394
401
|
updateMessageUid(accountId: string, folderId: number, oldUid: number, newUid: number): void;
|
|
395
|
-
/** Delete a message by account + UID.
|
|
396
|
-
*
|
|
397
|
-
|
|
402
|
+
/** Delete a message by account + folder + UID. folderId is REQUIRED:
|
|
403
|
+
* IMAP UIDs are per-folder, so the same numeric UID refers to different
|
|
404
|
+
* messages in INBOX vs Sent vs any other folder. The pre-2026-05-27
|
|
405
|
+
* implementation accepted (accountId, uid) only and ran
|
|
406
|
+
* `DELETE FROM messages WHERE account_id=? AND uid=?` — which on a
|
|
407
|
+
* QRESYNC VANISHED for INBOX uid=N would also delete the row for the
|
|
408
|
+
* SAME numeric uid=N living in Sent, Drafts, every label folder, etc.
|
|
409
|
+
* That's what wiped 70k bobma rows on 2026-05-27 when QRESYNC reported
|
|
410
|
+
* a handful of vanished UIDs. Never again — folderId required.
|
|
411
|
+
*
|
|
412
|
+
* folderId === null is allowed as an explicit "I want every folder's
|
|
413
|
+
* copy of this UID gone" (used by cross-account move where the source
|
|
414
|
+
* is being abandoned entirely). All other callers MUST pass a folderId.
|
|
415
|
+
*
|
|
416
|
+
* Reason is propagated into the audit_log so the DB carries an
|
|
417
|
+
* authoritative trail of every removal. */
|
|
418
|
+
deleteMessage(accountId: string, folderId: number | null, uid: number, reason?: string, source?: string): void;
|
|
398
419
|
/** Recalculate folder total/unread counts from actual messages */
|
|
399
420
|
recalcFolderCounts(folderId: number): void;
|
|
400
421
|
/** Bulk insert within a transaction for sync performance */
|
package/db.js
CHANGED
|
@@ -1802,8 +1802,17 @@ export class MailxDB {
|
|
|
1802
1802
|
return null;
|
|
1803
1803
|
return this.rowToEnvelope(r);
|
|
1804
1804
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1805
|
+
/** Look up a message's body_path. folderId is REQUIRED when available
|
|
1806
|
+
* because (account, uid) is not a unique key — the same numeric UID
|
|
1807
|
+
* refers to different messages in INBOX vs Outbox vs Sent etc. Passing
|
|
1808
|
+
* no folderId returns the first matching row, which may be the wrong
|
|
1809
|
+
* message's body — same class of bug as the parsedCache UID collision.
|
|
1810
|
+
* Existing callers without folderId are tolerated (legacy) but should
|
|
1811
|
+
* be migrated. */
|
|
1812
|
+
getMessageBodyPath(accountId, uid, folderId) {
|
|
1813
|
+
const r = folderId != null
|
|
1814
|
+
? this.db.prepare("SELECT body_path FROM messages WHERE account_id = ? AND folder_id = ? AND uid = ?").get(accountId, folderId, uid)
|
|
1815
|
+
: this.db.prepare("SELECT body_path FROM messages WHERE account_id = ? AND uid = ?").get(accountId, uid);
|
|
1807
1816
|
return r?.body_path || "";
|
|
1808
1817
|
}
|
|
1809
1818
|
updateMessageFlags(accountId, uid, flags) {
|
|
@@ -2012,13 +2021,31 @@ export class MailxDB {
|
|
|
2012
2021
|
}
|
|
2013
2022
|
}
|
|
2014
2023
|
}
|
|
2015
|
-
/** Delete a message by account + UID.
|
|
2016
|
-
*
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2024
|
+
/** Delete a message by account + folder + UID. folderId is REQUIRED:
|
|
2025
|
+
* IMAP UIDs are per-folder, so the same numeric UID refers to different
|
|
2026
|
+
* messages in INBOX vs Sent vs any other folder. The pre-2026-05-27
|
|
2027
|
+
* implementation accepted (accountId, uid) only and ran
|
|
2028
|
+
* `DELETE FROM messages WHERE account_id=? AND uid=?` — which on a
|
|
2029
|
+
* QRESYNC VANISHED for INBOX uid=N would also delete the row for the
|
|
2030
|
+
* SAME numeric uid=N living in Sent, Drafts, every label folder, etc.
|
|
2031
|
+
* That's what wiped 70k bobma rows on 2026-05-27 when QRESYNC reported
|
|
2032
|
+
* a handful of vanished UIDs. Never again — folderId required.
|
|
2033
|
+
*
|
|
2034
|
+
* folderId === null is allowed as an explicit "I want every folder's
|
|
2035
|
+
* copy of this UID gone" (used by cross-account move where the source
|
|
2036
|
+
* is being abandoned entirely). All other callers MUST pass a folderId.
|
|
2037
|
+
*
|
|
2038
|
+
* Reason is propagated into the audit_log so the DB carries an
|
|
2039
|
+
* authoritative trail of every removal. */
|
|
2040
|
+
deleteMessage(accountId, folderId, uid, reason, source) {
|
|
2041
|
+
// Get message_id + subject before deleting so the audit row carries
|
|
2042
|
+
// enough context to identify what was removed.
|
|
2043
|
+
const msg = folderId != null
|
|
2044
|
+
? this.db.prepare("SELECT folder_id, message_id, subject FROM messages WHERE account_id = ? AND folder_id = ? AND uid = ?").get(accountId, folderId, uid)
|
|
2045
|
+
: this.db.prepare("SELECT folder_id, message_id, subject FROM messages WHERE account_id = ? AND uid = ?").get(accountId, uid);
|
|
2046
|
+
const r = folderId != null
|
|
2047
|
+
? this.db.prepare("DELETE FROM messages WHERE account_id = ? AND folder_id = ? AND uid = ?").run(accountId, folderId, uid)
|
|
2048
|
+
: this.db.prepare("DELETE FROM messages WHERE account_id = ? AND uid = ?").run(accountId, uid);
|
|
2022
2049
|
if (r.changes && msg) {
|
|
2023
2050
|
this.audit({
|
|
2024
2051
|
kind: "delete-msg",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-store",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@bobfrankston/mailx-types": "^0.1.18",
|
|
13
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
13
|
+
"@bobfrankston/mailx-settings": "^0.1.25",
|
|
14
14
|
"@bobfrankston/mailx-bus": "^0.1.2",
|
|
15
15
|
"mailparser": "^3.7.2"
|
|
16
16
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
".transformedSnapshot": {
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@bobfrankston/mailx-types": "^0.1.18",
|
|
33
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
33
|
+
"@bobfrankston/mailx-settings": "^0.1.25",
|
|
34
34
|
"@bobfrankston/mailx-bus": "^0.1.2",
|
|
35
35
|
"mailparser": "^3.7.2"
|
|
36
36
|
}
|
package/store.js
CHANGED
|
@@ -224,7 +224,7 @@ export class Store {
|
|
|
224
224
|
// the historical lookup. Either may be empty (body never fetched).
|
|
225
225
|
let storedPath = envelope.bodyPath || "";
|
|
226
226
|
if (!storedPath)
|
|
227
|
-
storedPath = this.db.getMessageBodyPath(accountId, uid) || "";
|
|
227
|
+
storedPath = this.db.getMessageBodyPath(accountId, uid, folderId) || "";
|
|
228
228
|
const empty = {
|
|
229
229
|
...envelope,
|
|
230
230
|
bodyHtml: "", bodyText: "",
|
|
@@ -531,7 +531,7 @@ export class Store {
|
|
|
531
531
|
});
|
|
532
532
|
return "moved-to-trash";
|
|
533
533
|
}
|
|
534
|
-
this.db.deleteMessage(accountId, uid, "user-initiated trash (already in trash → expunge)", "Store.trashMessage");
|
|
534
|
+
this.db.deleteMessage(accountId, folderId, uid, "user-initiated trash (already in trash → expunge)", "Store.trashMessage");
|
|
535
535
|
this.db.recalcFolderCounts(folderId);
|
|
536
536
|
if (msgUuid) {
|
|
537
537
|
this.bus.publish({
|