@bobfrankston/mailx-imap 0.1.50 → 0.1.52

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.
Files changed (2) hide show
  1. package/index.js +24 -4
  2. package/package.json +11 -11
package/index.js CHANGED
@@ -951,11 +951,13 @@ export class ImapManager extends EventEmitter {
951
951
  let bodyPath = "";
952
952
  let preview = "";
953
953
  let hasAttachments = false;
954
+ let ftsBody = "";
954
955
  if (source) {
955
956
  bodyPath = await this.bodyStore.putMessage(accountId, folderId, msg.uid, Buffer.from(source, "utf-8"));
956
957
  const parsed = await extractPreview(source);
957
958
  preview = parsed.preview;
958
959
  hasAttachments = parsed.hasAttachments;
960
+ ftsBody = parsed.bodyText || "";
959
961
  }
960
962
  const flags = [];
961
963
  if (msg.seen)
@@ -966,7 +968,7 @@ export class ImapManager extends EventEmitter {
966
968
  flags.push("\\Answered");
967
969
  if (msg.draft)
968
970
  flags.push("\\Draft");
969
- this.db.upsertMessage({
971
+ const ftsRowId = this.db.upsertMessage({
970
972
  accountId, folderId, uid: msg.uid,
971
973
  messageId: msg.messageId || "",
972
974
  inReplyTo: msg.inReplyTo || "",
@@ -978,6 +980,12 @@ export class ImapManager extends EventEmitter {
978
980
  cc: toEmailAddresses(msg.cc || []),
979
981
  flags, size: msg.size || 0, hasAttachments, preview, bodyPath
980
982
  });
983
+ // Index the full body for search. extractPreview already
984
+ // parsed `source`, so the body text is free here — and
985
+ // indexing it at sync time means a word buried in the body
986
+ // is searchable without the user first opening the message.
987
+ if (ftsRowId && ftsBody)
988
+ this.db.updateFtsBody(ftsRowId, ftsBody);
981
989
  stored++;
982
990
  batchCount++;
983
991
  if (batchCount >= BATCH_SIZE) {
@@ -1476,7 +1484,7 @@ export class ImapManager extends EventEmitter {
1476
1484
  if (msg.draft)
1477
1485
  flags.push("\\Draft");
1478
1486
  // Store metadata
1479
- this.db.upsertMessage({
1487
+ const ftsRowId = this.db.upsertMessage({
1480
1488
  accountId,
1481
1489
  folderId,
1482
1490
  uid: msg.uid,
@@ -1494,6 +1502,11 @@ export class ImapManager extends EventEmitter {
1494
1502
  preview: parsed.preview,
1495
1503
  bodyPath
1496
1504
  });
1505
+ // Full body into the FTS index — the parse above already
1506
+ // produced the text, so search covers body content even
1507
+ // for messages the user hasn't opened.
1508
+ if (ftsRowId && parsed.bodyText)
1509
+ this.db.updateFtsBody(ftsRowId, parsed.bodyText);
1497
1510
  newCount++;
1498
1511
  }
1499
1512
  this.db.commitTransaction();
@@ -3039,7 +3052,13 @@ export class ImapManager extends EventEmitter {
3039
3052
  console.log(` [api] ${accountId}: flags synced UID ${action.uid}`);
3040
3053
  }
3041
3054
  else if ((action.action === "delete" || action.action === "trash") && api.trashMessage) {
3042
- await api.trashMessage(folder.path, action.uid);
3055
+ // Pass the stored Gmail message id (provider_id) so
3056
+ // the provider doesn't fall back to its capped
3057
+ // list-and-hash search — that search misses any
3058
+ // message past the most-recent ~1000 in a large
3059
+ // mailbox, fails, and the deletion un-happens.
3060
+ const env = this.db.getMessageByUid(accountId, action.uid);
3061
+ await api.trashMessage(folder.path, action.uid, env?.providerId);
3043
3062
  console.log(` [api] ${accountId}: trashed UID ${action.uid} from ${folder.path}`);
3044
3063
  }
3045
3064
  else if (action.action === "move" && api.moveMessage) {
@@ -3050,7 +3069,8 @@ export class ImapManager extends EventEmitter {
3050
3069
  this.db.completeSyncAction(action.id);
3051
3070
  continue;
3052
3071
  }
3053
- await api.moveMessage(folder.path, action.uid, target.path);
3072
+ const env = this.db.getMessageByUid(accountId, action.uid);
3073
+ await api.moveMessage(folder.path, action.uid, target.path, env?.providerId);
3054
3074
  console.log(` [api] ${accountId}: moved UID ${action.uid} ${folder.path} → ${target.path}`);
3055
3075
  }
3056
3076
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,14 +9,14 @@
9
9
  },
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@bobfrankston/mailx-types": "^0.1.14",
13
- "@bobfrankston/mailx-settings": "^0.1.17",
14
- "@bobfrankston/mailx-store": "^0.1.28",
12
+ "@bobfrankston/mailx-types": "^0.1.17",
13
+ "@bobfrankston/mailx-settings": "^0.1.19",
14
+ "@bobfrankston/mailx-store": "^0.1.29",
15
15
  "@bobfrankston/iflow-direct": "^0.1.50",
16
16
  "@bobfrankston/tcp-transport": "^0.1.6",
17
17
  "@bobfrankston/smtp-direct": "^0.1.8",
18
- "@bobfrankston/mailx-sync": "^0.1.17",
19
- "@bobfrankston/oauthsupport": "^1.0.26"
18
+ "@bobfrankston/mailx-sync": "^0.1.19",
19
+ "@bobfrankston/oauthsupport": "^1.0.27"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -37,14 +37,14 @@
37
37
  },
38
38
  ".transformedSnapshot": {
39
39
  "dependencies": {
40
- "@bobfrankston/mailx-types": "^0.1.14",
41
- "@bobfrankston/mailx-settings": "^0.1.17",
42
- "@bobfrankston/mailx-store": "^0.1.28",
40
+ "@bobfrankston/mailx-types": "^0.1.17",
41
+ "@bobfrankston/mailx-settings": "^0.1.19",
42
+ "@bobfrankston/mailx-store": "^0.1.29",
43
43
  "@bobfrankston/iflow-direct": "^0.1.50",
44
44
  "@bobfrankston/tcp-transport": "^0.1.6",
45
45
  "@bobfrankston/smtp-direct": "^0.1.8",
46
- "@bobfrankston/mailx-sync": "^0.1.17",
47
- "@bobfrankston/oauthsupport": "^1.0.26"
46
+ "@bobfrankston/mailx-sync": "^0.1.19",
47
+ "@bobfrankston/oauthsupport": "^1.0.27"
48
48
  }
49
49
  }
50
50
  }