From 2dd0b329ca243de87eb1b59bf831593f70c42784 Mon Sep 17 00:00:00 2001 From: Nicolas-nwb <64306440+Nicolas-nwb@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:56:53 +0200 Subject: [PATCH] feat(Gmail Node): Add thread option for draft emails (#8729) Co-authored-by: Jonathan Bennetts --- .../nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts | 8 ++++++++ packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/packages/nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts b/packages/nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts index 8a87e40d4..e6dd7d86a 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts @@ -151,6 +151,14 @@ export const draftFields: INodeProperties[] = [ default: '', description: 'The email address that the reply message is sent to', }, + { + displayName: 'Thread ID', + name: 'threadId', + type: 'string', + placeholder: '18cc573e2431878f', + default: '', + description: 'The identifier of the thread to attach the draft', + }, { displayName: 'Attachments', name: 'attachmentsUi', diff --git a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts index a16d9c65d..ba8bdb668 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts @@ -528,6 +528,7 @@ export class GmailV2 implements INodeType { let cc = ''; let bcc = ''; let replyTo = ''; + let threadId = null; if (options.sendTo) { to += prepareEmailsInput.call(this, options.sendTo as string, 'To', i); @@ -545,6 +546,10 @@ export class GmailV2 implements INodeType { replyTo = prepareEmailsInput.call(this, options.replyTo as string, 'ReplyTo', i); } + if (options.threadId && typeof options.threadId === 'string') { + threadId = options.threadId; + } + let attachments: IDataObject[] = []; if (options.attachmentsUi) { attachments = await prepareEmailAttachments.call( @@ -574,6 +579,7 @@ export class GmailV2 implements INodeType { const body = { message: { raw: await encodeEmail(email), + threadId: threadId || undefined, }, };