@bobfrankston/rmfmail 1.1.72 → 1.1.74

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.
@@ -5201,6 +5201,14 @@ var WebMailxDB = class {
5201
5201
  const r = this.get("SELECT body_path FROM messages WHERE account_id = ? AND uid = ?", [accountId, uid]);
5202
5202
  return r?.body_path || "";
5203
5203
  }
5204
+ /** The provider's own message id (Gmail message id) for a uid. Passed to
5205
+ * the Gmail provider's trash/move so it doesn't fall back to a capped
5206
+ * list-and-hash search that misses messages in a large mailbox. "" when
5207
+ * unknown — the provider then uses its (capped) fallback. */
5208
+ getProviderId(accountId, uid) {
5209
+ const r = this.get("SELECT provider_id FROM messages WHERE account_id = ? AND uid = ?", [accountId, uid]);
5210
+ return r?.provider_id || "";
5211
+ }
5204
5212
  updateMessageFlags(accountId, uid, flags) {
5205
5213
  this.run("UPDATE messages SET flags_json = ? WHERE account_id = ? AND uid = ?", [JSON.stringify(flags), accountId, uid]);
5206
5214
  }
@@ -6901,10 +6909,12 @@ Accept: application/json\r
6901
6909
  * as a destination folder — `POST /messages/{id}/trash` is the native
6902
6910
  * path (equivalent to setting TRASH and removing INBOX in one op).
6903
6911
  * Used by mailx's delete/trash path. */
6904
- async trashMessage(folder, uid) {
6905
- const query = `in:${this.folderToLabel(folder)}`;
6906
- const ids = await this.listMessageIds(query, 1e3);
6907
- const id = ids.find((id2) => idToUid(id2) === uid);
6912
+ async trashMessage(folder, uid, gmailId) {
6913
+ let id = gmailId;
6914
+ if (!id) {
6915
+ const ids = await this.listMessageIds(`in:${this.folderToLabel(folder)}`, 1e3);
6916
+ id = ids.find((x) => idToUid(x) === uid);
6917
+ }
6908
6918
  if (!id)
6909
6919
  throw new Error(`Gmail trashMessage: UID ${uid} not found in ${folder}`);
6910
6920
  await this.fetch(`/messages/${id}/trash`, { method: "POST" });
@@ -6912,10 +6922,12 @@ Accept: application/json\r
6912
6922
  /** Move between "folders" == swap one label for another via modifyLabels.
6913
6923
  * System labels (INBOX/SENT/TRASH/SPAM) are translated from the folder
6914
6924
  * path; user labels use the folder path verbatim as the label id. */
6915
- async moveMessage(fromFolder, uid, toFolder) {
6916
- const query = `in:${this.folderToLabel(fromFolder)}`;
6917
- const ids = await this.listMessageIds(query, 1e3);
6918
- const id = ids.find((id2) => idToUid(id2) === uid);
6925
+ async moveMessage(fromFolder, uid, toFolder, gmailId) {
6926
+ let id = gmailId;
6927
+ if (!id) {
6928
+ const ids = await this.listMessageIds(`in:${this.folderToLabel(fromFolder)}`, 1e3);
6929
+ id = ids.find((x) => idToUid(x) === uid);
6930
+ }
6919
6931
  if (!id)
6920
6932
  throw new Error(`Gmail moveMessage: UID ${uid} not found in ${fromFolder}`);
6921
6933
  const toLabel = this.folderPathToLabelId(toFolder);
@@ -10007,7 +10019,7 @@ var AndroidSyncManager = class {
10007
10019
  if (p.action === "flags" && typeof provider.setFlags === "function") {
10008
10020
  await provider.setFlags(path, p.uid, Array.isArray(p.flags) ? p.flags : p.flags ? [p.flags] : []);
10009
10021
  } else if (p.action === "trash" && typeof provider.trashMessage === "function") {
10010
- await provider.trashMessage(path, p.uid);
10022
+ await provider.trashMessage(path, p.uid, this.db.getProviderId(accountId, p.uid));
10011
10023
  } else if (p.action === "move" && typeof provider.moveMessage === "function") {
10012
10024
  const toId = p.targetFolderId;
10013
10025
  const toPath = folderPath(toId);
@@ -10015,7 +10027,7 @@ var AndroidSyncManager = class {
10015
10027
  this.db.failSyncActionByUid(accountId, p.action, p.uid, `unknown target folder ${toId}`);
10016
10028
  continue;
10017
10029
  }
10018
- await provider.moveMessage(path, p.uid, toPath);
10030
+ await provider.moveMessage(path, p.uid, toPath, this.db.getProviderId(accountId, p.uid));
10019
10031
  } else {
10020
10032
  this.db.failSyncActionByUid(accountId, p.action, p.uid, `provider does not support ${p.action}`);
10021
10033
  continue;