fix(Email Trigger (IMAP) Node): backport V2 mark-seen-after-processing to V1 (#4435)

backport V2 mark-seen-after-processing to V1
This commit is contained in:
Michael Auerswald 2022-10-25 12:53:06 +02:00 committed by GitHub
parent 3143292a68
commit b296fb06f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -314,13 +314,13 @@ export class EmailReadImapV1 implements INodeType {
if (format === 'simple' || format === 'raw') { if (format === 'simple' || format === 'raw') {
fetchOptions = { fetchOptions = {
bodies: ['TEXT', 'HEADER'], bodies: ['TEXT', 'HEADER'],
markSeen: postProcessAction === 'read', markSeen: false,
struct: true, struct: true,
}; };
} else if (format === 'resolved') { } else if (format === 'resolved') {
fetchOptions = { fetchOptions = {
bodies: [''], bodies: [''],
markSeen: postProcessAction === 'read', markSeen: false,
struct: true, struct: true,
}; };
} }
@ -459,6 +459,13 @@ export class EmailReadImapV1 implements INodeType {
} }
} }
// only mark messages as seen once processing has finished
if (postProcessAction === 'read') {
const uidList = results.map((e) => e.attributes.uid);
if (uidList.length > 0) {
connection.addFlags(uidList, '\\SEEN');
}
}
return newEmails; return newEmails;
}; };