@bobfrankston/mailx 1.0.299 → 1.0.300
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/package.json +1 -1
- package/packages/mailx-imap/index.js +13 -1
package/package.json
CHANGED
|
@@ -1060,8 +1060,20 @@ export class ImapManager extends EventEmitter {
|
|
|
1060
1060
|
console.log(` [api] ${accountId}/${folder.path}: syncing (highestUid=${highestUid})...`);
|
|
1061
1061
|
let messages;
|
|
1062
1062
|
if (highestUid > 0) {
|
|
1063
|
-
// Incremental: fetch messages since last known UID
|
|
1063
|
+
// Incremental: fetch messages since last known UID.
|
|
1064
|
+
// Gmail "UIDs" are hashed (not chronological), so fetchSince
|
|
1065
|
+
// returns messages in hash order — they can be from ANY date.
|
|
1066
|
+
// Filter by the history window so years-old messages don't
|
|
1067
|
+
// suddenly flood the inbox on every incremental sync.
|
|
1064
1068
|
messages = await api.fetchSince(folder.path, highestUid, { source: false });
|
|
1069
|
+
if (effectiveDays > 0) {
|
|
1070
|
+
const cutoff = startDate.getTime();
|
|
1071
|
+
const before = messages.length;
|
|
1072
|
+
messages = messages.filter(m => !m.date || m.date.getTime() >= cutoff);
|
|
1073
|
+
if (messages.length < before) {
|
|
1074
|
+
console.log(` [api] ${accountId}/${folder.path}: filtered ${before - messages.length} messages older than ${effectiveDays}d`);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1065
1077
|
}
|
|
1066
1078
|
else {
|
|
1067
1079
|
// First sync: fetch by date range
|