From b296fb06f3222ad56c9d8267f8b8283097fde113 Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Tue, 25 Oct 2022 12:53:06 +0200 Subject: [PATCH] fix(Email Trigger (IMAP) Node): backport V2 mark-seen-after-processing to V1 (#4435) backport V2 mark-seen-after-processing to V1 --- .../nodes/EmailReadImap/v1/EmailReadImapV1.node.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts index bee4de0099..28a48d98a3 100644 --- a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts @@ -314,13 +314,13 @@ export class EmailReadImapV1 implements INodeType { if (format === 'simple' || format === 'raw') { fetchOptions = { bodies: ['TEXT', 'HEADER'], - markSeen: postProcessAction === 'read', + markSeen: false, struct: true, }; } else if (format === 'resolved') { fetchOptions = { bodies: [''], - markSeen: postProcessAction === 'read', + markSeen: false, 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; };