nx-webmail: fix full mailbox sync path for large inboxes
Publish nx-webmail Image (Gitea) / publish (push) Has been cancelled
Publish nx-webmail Image (Gitea) / publish (push) Has been cancelled
This commit is contained in:
+10
-6
@@ -159,8 +159,12 @@ app.post('/api/webmail/inbox', async (req, res) => {
|
||||
return res.json({ sync: true, total, newEmails, deletedUids });
|
||||
}
|
||||
|
||||
let results = [];
|
||||
let targetUids = sortedUids;
|
||||
if (!loadAll) {
|
||||
if (loadAll) {
|
||||
// For full mailbox sync, use ALL to avoid oversized UID query strings.
|
||||
results = await connection.search(['ALL'], fetchOptions);
|
||||
} else {
|
||||
if (oldest) {
|
||||
const start = safeOffset;
|
||||
const end = Math.min(total, start + safeLimit);
|
||||
@@ -170,13 +174,13 @@ app.post('/api/webmail/inbox', async (req, res) => {
|
||||
const start = Math.max(0, end - safeLimit);
|
||||
targetUids = sortedUids.slice(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetUids.length === 0) {
|
||||
return res.json({ emails: [], total, hasMore: false, nextOffset: safeOffset });
|
||||
}
|
||||
if (targetUids.length === 0) {
|
||||
return res.json({ emails: [], total, hasMore: false, nextOffset: safeOffset });
|
||||
}
|
||||
|
||||
const results = await connection.search([['UID', targetUids.join(',')]], fetchOptions);
|
||||
results = await connection.search([['UID', targetUids.join(',')]], fetchOptions);
|
||||
}
|
||||
const emails = results.map(parseHeaderRow).sort((a, b) => Number(a.id || 0) - Number(b.id || 0));
|
||||
const nextOffset = loadAll ? total : Math.min(total, safeOffset + targetUids.length);
|
||||
const hasMore = loadAll ? false : nextOffset < total;
|
||||
|
||||
Reference in New Issue
Block a user