Skip to content

Commit

Permalink
feat(Gmail Node): Add thread option for draft emails (#8729)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
  • Loading branch information
Nicolas-nwb and Joffcom committed Apr 25, 2024
1 parent 756012b commit 2dd0b32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/nodes-base/nodes/Google/Gmail/v2/DraftDescription.ts
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts
Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -574,6 +579,7 @@ export class GmailV2 implements INodeType {
const body = {
message: {
raw: await encodeEmail(email),
threadId: threadId || undefined,
},
};

Expand Down

0 comments on commit 2dd0b32

Please sign in to comment.