fix(imap client): harden IMAP client message processing and modernize test tooling
This commit is contained in:
@@ -68,6 +68,9 @@ export class ImapClient extends plugins.events.EventEmitter {
|
||||
|
||||
try {
|
||||
const searchResult = await this.client.search(this.filter);
|
||||
if (!searchResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert searchResult to a regular array
|
||||
const searchResultArray = Array.from(searchResult);
|
||||
@@ -80,6 +83,9 @@ export class ImapClient extends plugins.events.EventEmitter {
|
||||
|
||||
// Fetch messages
|
||||
for await (const message of this.client.fetch(newUids, { envelope: true, source: true })) {
|
||||
if (!message.source) {
|
||||
continue;
|
||||
}
|
||||
const parsed = await plugins.mailparser.simpleParser(message.source);
|
||||
this.emit('message', parsed);
|
||||
this.seenUids.add(message.uid);
|
||||
@@ -102,4 +108,4 @@ export class ImapClient extends plugins.events.EventEmitter {
|
||||
this.emit('disconnected');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user