@marlinjai/email-mcp 1.2.2 → 1.2.3

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/dist/index.js CHANGED
@@ -8624,7 +8624,8 @@ var init_adapter3 = __esm({
8624
8624
  }
8625
8625
  async deleteEmail(emailId, permanent, sourceFolder) {
8626
8626
  if (!this.client) throw new Error("Not connected");
8627
- const folder = sourceFolder || "INBOX";
8627
+ const folder = sourceFolder ? await this.resolveFolder(sourceFolder) : "INBOX";
8628
+ const trashFolder = await this.resolveFolder("Trash");
8628
8629
  let lock;
8629
8630
  try {
8630
8631
  lock = await this.client.getMailboxLock(folder);
@@ -8632,10 +8633,10 @@ var init_adapter3 = __esm({
8632
8633
  throw formatImapError(error48, `Failed to open folder "${folder}"`);
8633
8634
  }
8634
8635
  try {
8635
- if (permanent) {
8636
+ if (permanent || folder === trashFolder) {
8636
8637
  await this.client.messageDelete(emailId, { uid: true });
8637
8638
  } else {
8638
- await this.client.messageMove(emailId, "Trash", { uid: true });
8639
+ await this.client.messageMove(emailId, trashFolder, { uid: true });
8639
8640
  }
8640
8641
  } finally {
8641
8642
  lock.release();
@@ -8668,7 +8669,9 @@ var init_adapter3 = __esm({
8668
8669
  async batchDelete(emailIds, permanent, sourceFolder) {
8669
8670
  if (!this.client) throw new Error("Not connected");
8670
8671
  const result = { succeeded: [], failed: [] };
8671
- const folder = sourceFolder || "INBOX";
8672
+ const folder = sourceFolder ? await this.resolveFolder(sourceFolder) : "INBOX";
8673
+ const trashFolder = await this.resolveFolder("Trash");
8674
+ const shouldPermanentDelete = permanent || folder === trashFolder;
8672
8675
  let lock;
8673
8676
  try {
8674
8677
  lock = await this.client.getMailboxLock(folder);
@@ -8677,19 +8680,19 @@ var init_adapter3 = __esm({
8677
8680
  }
8678
8681
  try {
8679
8682
  const uidRange = emailIds.join(",");
8680
- if (permanent) {
8683
+ if (shouldPermanentDelete) {
8681
8684
  await this.client.messageDelete(uidRange, { uid: true });
8682
8685
  } else {
8683
- await this.client.messageMove(uidRange, "Trash", { uid: true });
8686
+ await this.client.messageMove(uidRange, trashFolder, { uid: true });
8684
8687
  }
8685
8688
  result.succeeded = [...emailIds];
8686
8689
  } catch (error48) {
8687
8690
  for (const id of emailIds) {
8688
8691
  try {
8689
- if (permanent) {
8692
+ if (shouldPermanentDelete) {
8690
8693
  await this.client.messageDelete(id, { uid: true });
8691
8694
  } else {
8692
- await this.client.messageMove(id, "Trash", { uid: true });
8695
+ await this.client.messageMove(id, trashFolder, { uid: true });
8693
8696
  }
8694
8697
  result.succeeded.push(id);
8695
8698
  } catch (e) {