mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
feat(Gmail Node): Add reply to email (#6453)
Co-authored-by: Matthias Stallmann <feelgood.interface@gmail.com>
This commit is contained in:
parent
bbe493896c
commit
fddc69ee2c
|
@ -24,6 +24,7 @@ export interface IEmail {
|
||||||
to?: string;
|
to?: string;
|
||||||
cc?: string;
|
cc?: string;
|
||||||
bcc?: string;
|
bcc?: string;
|
||||||
|
replyTo?: string;
|
||||||
inReplyTo?: string;
|
inReplyTo?: string;
|
||||||
reference?: string;
|
reference?: string;
|
||||||
subject: string;
|
subject: string;
|
||||||
|
@ -222,6 +223,7 @@ export async function encodeEmail(email: IEmail) {
|
||||||
to: email.to,
|
to: email.to,
|
||||||
cc: email.cc,
|
cc: email.cc,
|
||||||
bcc: email.bcc,
|
bcc: email.bcc,
|
||||||
|
replyTo: email.replyTo,
|
||||||
inReplyTo: email.inReplyTo,
|
inReplyTo: email.inReplyTo,
|
||||||
references: email.reference,
|
references: email.reference,
|
||||||
subject: email.subject,
|
subject: email.subject,
|
||||||
|
@ -509,7 +511,7 @@ export function unescapeSnippets(items: INodeExecutionData[]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function replayToEmail(
|
export async function replyToEmail(
|
||||||
this: IExecuteFunctions,
|
this: IExecuteFunctions,
|
||||||
items: INodeExecutionData[],
|
items: INodeExecutionData[],
|
||||||
gmailId: string,
|
gmailId: string,
|
||||||
|
|
|
@ -143,6 +143,14 @@ export const draftFields: INodeProperties[] = [
|
||||||
placeholder: 'info@example.com',
|
placeholder: 'info@example.com',
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Send Replies To',
|
||||||
|
name: 'replyTo',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'reply@example.com',
|
||||||
|
default: '',
|
||||||
|
description: 'The email address that the reply message is sent to',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Attachments',
|
displayName: 'Attachments',
|
||||||
name: 'attachmentsUi',
|
name: 'attachmentsUi',
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
prepareEmailBody,
|
prepareEmailBody,
|
||||||
prepareEmailsInput,
|
prepareEmailsInput,
|
||||||
prepareQuery,
|
prepareQuery,
|
||||||
replayToEmail,
|
replyToEmail,
|
||||||
simplifyOutput,
|
simplifyOutput,
|
||||||
unescapeSnippets,
|
unescapeSnippets,
|
||||||
} from '../GenericFunctions';
|
} from '../GenericFunctions';
|
||||||
|
@ -282,6 +282,7 @@ export class GmailV2 implements INodeType {
|
||||||
const to = prepareEmailsInput.call(this, sendTo, 'To', i);
|
const to = prepareEmailsInput.call(this, sendTo, 'To', i);
|
||||||
let cc = '';
|
let cc = '';
|
||||||
let bcc = '';
|
let bcc = '';
|
||||||
|
let replyTo = '';
|
||||||
|
|
||||||
if (options.ccList) {
|
if (options.ccList) {
|
||||||
cc = prepareEmailsInput.call(this, options.ccList as string, 'CC', i);
|
cc = prepareEmailsInput.call(this, options.ccList as string, 'CC', i);
|
||||||
|
@ -291,6 +292,10 @@ export class GmailV2 implements INodeType {
|
||||||
bcc = prepareEmailsInput.call(this, options.bccList as string, 'BCC', i);
|
bcc = prepareEmailsInput.call(this, options.bccList as string, 'BCC', i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.replyTo) {
|
||||||
|
replyTo = prepareEmailsInput.call(this, options.replyTo as string, 'ReplyTo', i);
|
||||||
|
}
|
||||||
|
|
||||||
let attachments: IDataObject[] = [];
|
let attachments: IDataObject[] = [];
|
||||||
|
|
||||||
if (options.attachmentsUi) {
|
if (options.attachmentsUi) {
|
||||||
|
@ -323,6 +328,7 @@ export class GmailV2 implements INodeType {
|
||||||
to,
|
to,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
|
replyTo,
|
||||||
subject: this.getNodeParameter('subject', i) as string,
|
subject: this.getNodeParameter('subject', i) as string,
|
||||||
...prepareEmailBody.call(this, i),
|
...prepareEmailBody.call(this, i),
|
||||||
attachments,
|
attachments,
|
||||||
|
@ -340,7 +346,7 @@ export class GmailV2 implements INodeType {
|
||||||
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
||||||
const options = this.getNodeParameter('options', i);
|
const options = this.getNodeParameter('options', i);
|
||||||
|
|
||||||
responseData = await replayToEmail.call(this, items, messageIdGmail, options, i);
|
responseData = await replyToEmail.call(this, items, messageIdGmail, options, i);
|
||||||
}
|
}
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
//https://developers.google.com/gmail/api/v1/reference/users/messages/get
|
//https://developers.google.com/gmail/api/v1/reference/users/messages/get
|
||||||
|
@ -514,6 +520,7 @@ export class GmailV2 implements INodeType {
|
||||||
let to = '';
|
let to = '';
|
||||||
let cc = '';
|
let cc = '';
|
||||||
let bcc = '';
|
let bcc = '';
|
||||||
|
let replyTo = '';
|
||||||
|
|
||||||
if (options.sendTo) {
|
if (options.sendTo) {
|
||||||
to += prepareEmailsInput.call(this, options.sendTo as string, 'To', i);
|
to += prepareEmailsInput.call(this, options.sendTo as string, 'To', i);
|
||||||
|
@ -527,6 +534,10 @@ export class GmailV2 implements INodeType {
|
||||||
bcc = prepareEmailsInput.call(this, options.bccList as string, 'BCC', i);
|
bcc = prepareEmailsInput.call(this, options.bccList as string, 'BCC', i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.replyTo) {
|
||||||
|
replyTo = prepareEmailsInput.call(this, options.replyTo as string, 'ReplyTo', i);
|
||||||
|
}
|
||||||
|
|
||||||
let attachments: IDataObject[] = [];
|
let attachments: IDataObject[] = [];
|
||||||
if (options.attachmentsUi) {
|
if (options.attachmentsUi) {
|
||||||
attachments = await prepareEmailAttachments.call(
|
attachments = await prepareEmailAttachments.call(
|
||||||
|
@ -547,6 +558,7 @@ export class GmailV2 implements INodeType {
|
||||||
to,
|
to,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
|
replyTo,
|
||||||
subject: this.getNodeParameter('subject', i) as string,
|
subject: this.getNodeParameter('subject', i) as string,
|
||||||
...prepareEmailBody.call(this, i),
|
...prepareEmailBody.call(this, i),
|
||||||
attachments,
|
attachments,
|
||||||
|
@ -741,7 +753,7 @@ export class GmailV2 implements INodeType {
|
||||||
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
||||||
const options = this.getNodeParameter('options', i);
|
const options = this.getNodeParameter('options', i);
|
||||||
|
|
||||||
responseData = await replayToEmail.call(this, items, messageIdGmail, options, i);
|
responseData = await replyToEmail.call(this, items, messageIdGmail, options, i);
|
||||||
}
|
}
|
||||||
if (operation === 'trash') {
|
if (operation === 'trash') {
|
||||||
//https://developers.google.com/gmail/api/reference/rest/v1/users.threads/trash
|
//https://developers.google.com/gmail/api/reference/rest/v1/users.threads/trash
|
||||||
|
|
|
@ -225,6 +225,19 @@ export const messageFields: INodeProperties[] = [
|
||||||
default: '',
|
default: '',
|
||||||
description: "The name that will be shown in recipients' inboxes",
|
description: "The name that will be shown in recipients' inboxes",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Send Replies To',
|
||||||
|
name: 'replyTo',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'reply@example.com',
|
||||||
|
default: '',
|
||||||
|
description: 'The email address that the reply message is sent to',
|
||||||
|
displayOptions: {
|
||||||
|
hide: {
|
||||||
|
'/operation': ['reply'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Reply to Sender Only',
|
displayName: 'Reply to Sender Only',
|
||||||
name: 'replyToSenderOnly',
|
name: 'replyToSenderOnly',
|
||||||
|
|
Loading…
Reference in a new issue