apple-mail-mcp 2.8.4 → 2.8.5
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/build/index.js +29 -5
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -80308,6 +80308,28 @@ async function imapMoveMessageById(id, destMailbox, deps = {}) {
|
|
|
80308
80308
|
}
|
|
80309
80309
|
});
|
|
80310
80310
|
}
|
|
80311
|
+
async function resolveTrashPath(client) {
|
|
80312
|
+
try {
|
|
80313
|
+
const boxes = await client.list();
|
|
80314
|
+
const special = boxes.find((b) => b.specialUse === "\\Trash");
|
|
80315
|
+
if (special) return special.path;
|
|
80316
|
+
const named = boxes.find(
|
|
80317
|
+
(b) => /^(trash|deleted messages|deleted items|bin)$/i.test(b.name) || /(^|\/)trash$/i.test(b.path)
|
|
80318
|
+
);
|
|
80319
|
+
if (named) return named.path;
|
|
80320
|
+
} catch {
|
|
80321
|
+
}
|
|
80322
|
+
return resolveMailboxPath("trash", "list");
|
|
80323
|
+
}
|
|
80324
|
+
async function trashUids(client, uids, srcPath) {
|
|
80325
|
+
const dest = await resolveTrashPath(client);
|
|
80326
|
+
if (srcPath.trim().toLowerCase() === dest.trim().toLowerCase()) {
|
|
80327
|
+
await client.messageDelete(uids, { uid: true });
|
|
80328
|
+
return { dest, expunged: true };
|
|
80329
|
+
}
|
|
80330
|
+
await client.messageMove(uids, dest, { uid: true });
|
|
80331
|
+
return { dest, expunged: false };
|
|
80332
|
+
}
|
|
80311
80333
|
async function imapDeleteMessageById(id, deps = {}) {
|
|
80312
80334
|
const ref = decodeImapId(id);
|
|
80313
80335
|
if (!ref) return { success: false, error: `Not an IMAP message id: "${id}".` };
|
|
@@ -80316,9 +80338,11 @@ async function imapDeleteMessageById(id, deps = {}) {
|
|
|
80316
80338
|
{ ...deps, account: deps.account ?? ref.account },
|
|
80317
80339
|
async (client) => {
|
|
80318
80340
|
try {
|
|
80319
|
-
const
|
|
80320
|
-
|
|
80321
|
-
|
|
80341
|
+
const { dest, expunged } = await trashUids(client, [ref.uid], ref.path);
|
|
80342
|
+
return {
|
|
80343
|
+
success: true,
|
|
80344
|
+
info: expunged ? `Permanently deleted UID ${ref.uid} from Trash ("${ref.path}") via IMAP.` : `Moved UID ${ref.uid} to Trash ("${dest}") via IMAP.`
|
|
80345
|
+
};
|
|
80322
80346
|
} catch (e) {
|
|
80323
80347
|
return { success: false, error: `IMAP delete failed for UID ${ref.uid}: ${errText(e)}` };
|
|
80324
80348
|
}
|
|
@@ -80445,8 +80469,8 @@ var imapBatchFlag = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) =>
|
|
|
80445
80469
|
var imapBatchUnflag = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
80446
80470
|
await c.messageFlagsRemove(uids, ["\\Flagged"], { uid: true });
|
|
80447
80471
|
});
|
|
80448
|
-
var imapBatchDelete = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
80449
|
-
await c
|
|
80472
|
+
var imapBatchDelete = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids, path) => {
|
|
80473
|
+
await trashUids(c, uids, path);
|
|
80450
80474
|
});
|
|
80451
80475
|
function imapBatchMove(ids, destMailbox, deps = {}) {
|
|
80452
80476
|
return imapBatch(ids, deps, async (c, uids) => {
|
package/package.json
CHANGED