@marlinjai/email-mcp 1.2.7 → 1.2.8
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 +24 -19
- package/dist/index.js.map +2 -2
- package/dist/setup/wizard.js +24 -19
- package/dist/setup/wizard.js.map +2 -2
- package/package.json +1 -1
package/dist/setup/wizard.js
CHANGED
|
@@ -1623,14 +1623,7 @@ var ImapAdapter = class {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
try {
|
|
1625
1625
|
const mailboxExists = this.client.mailbox?.exists ?? 0;
|
|
1626
|
-
|
|
1627
|
-
try {
|
|
1628
|
-
const status = await this.client.status(folder, { messages: true });
|
|
1629
|
-
statusCount = status.messages ?? 0;
|
|
1630
|
-
} catch {
|
|
1631
|
-
}
|
|
1632
|
-
const effectiveCount = Math.max(mailboxExists, statusCount);
|
|
1633
|
-
if (effectiveCount === 0) {
|
|
1626
|
+
if (mailboxExists === 0) {
|
|
1634
1627
|
return [];
|
|
1635
1628
|
}
|
|
1636
1629
|
const criteria = this.buildSearchCriteria(query);
|
|
@@ -1643,7 +1636,11 @@ var ImapAdapter = class {
|
|
|
1643
1636
|
);
|
|
1644
1637
|
allUids = Array.isArray(searchResult) ? searchResult : [];
|
|
1645
1638
|
} catch {
|
|
1646
|
-
|
|
1639
|
+
try {
|
|
1640
|
+
allUids = await this.collectUidsViaFetch(query);
|
|
1641
|
+
} catch {
|
|
1642
|
+
return [];
|
|
1643
|
+
}
|
|
1647
1644
|
}
|
|
1648
1645
|
const offset = query.offset || 0;
|
|
1649
1646
|
const slicedUids = query.limit ? allUids.slice(offset, offset + query.limit) : allUids.slice(offset);
|
|
@@ -1705,19 +1702,27 @@ var ImapAdapter = class {
|
|
|
1705
1702
|
async fetchEmails(uids, folder, returnBody) {
|
|
1706
1703
|
if (!this.client) return [];
|
|
1707
1704
|
const emails = [];
|
|
1708
|
-
|
|
1709
|
-
|
|
1705
|
+
const fetchOpts = returnBody ? { source: true, uid: true, flags: true } : { envelope: true, uid: true, flags: true, bodyStructure: true };
|
|
1706
|
+
const uidRange = uids.join(",");
|
|
1707
|
+
let messages;
|
|
1708
|
+
try {
|
|
1709
|
+
messages = await this.client.fetchAll(uidRange, fetchOpts, { uid: true });
|
|
1710
|
+
} catch {
|
|
1711
|
+
messages = [];
|
|
1712
|
+
for (const uid of uids) {
|
|
1713
|
+
try {
|
|
1714
|
+
const batch = await this.client.fetchAll(String(uid), fetchOpts, { uid: true });
|
|
1715
|
+
messages.push(...batch);
|
|
1716
|
+
} catch {
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
for (const msg of messages) {
|
|
1721
|
+
if (returnBody) {
|
|
1710
1722
|
const parsed = await simpleParser(msg.source);
|
|
1711
1723
|
parsed.flags = msg.flags;
|
|
1712
1724
|
emails.push(mapParsedEmail(parsed, folder, this.accountId, msg.uid));
|
|
1713
|
-
}
|
|
1714
|
-
} else {
|
|
1715
|
-
for await (const msg of this.client.fetch(uids, {
|
|
1716
|
-
envelope: true,
|
|
1717
|
-
uid: true,
|
|
1718
|
-
flags: true,
|
|
1719
|
-
bodyStructure: true
|
|
1720
|
-
})) {
|
|
1725
|
+
} else {
|
|
1721
1726
|
const env = msg.envelope;
|
|
1722
1727
|
emails.push({
|
|
1723
1728
|
id: String(msg.uid),
|