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;
|
||||
cc?: string;
|
||||
bcc?: string;
|
||||
replyTo?: string;
|
||||
inReplyTo?: string;
|
||||
reference?: string;
|
||||
subject: string;
|
||||
|
@ -222,6 +223,7 @@ export async function encodeEmail(email: IEmail) {
|
|||
to: email.to,
|
||||
cc: email.cc,
|
||||
bcc: email.bcc,
|
||||
replyTo: email.replyTo,
|
||||
inReplyTo: email.inReplyTo,
|
||||
references: email.reference,
|
||||
subject: email.subject,
|
||||
|
@ -509,7 +511,7 @@ export function unescapeSnippets(items: INodeExecutionData[]) {
|
|||
return result;
|
||||
}
|
||||
|
||||
export async function replayToEmail(
|
||||
export async function replyToEmail(
|
||||
this: IExecuteFunctions,
|
||||
items: INodeExecutionData[],
|
||||
gmailId: string,
|
||||
|
|
|
@ -143,6 +143,14 @@ export const draftFields: INodeProperties[] = [
|
|||
placeholder: 'info@example.com',
|
||||
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',
|
||||
name: 'attachmentsUi',
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
prepareEmailBody,
|
||||
prepareEmailsInput,
|
||||
prepareQuery,
|
||||
replayToEmail,
|
||||
replyToEmail,
|
||||
simplifyOutput,
|
||||
unescapeSnippets,
|
||||
} from '../GenericFunctions';
|
||||
|
@ -282,6 +282,7 @@ export class GmailV2 implements INodeType {
|
|||
const to = prepareEmailsInput.call(this, sendTo, 'To', i);
|
||||
let cc = '';
|
||||
let bcc = '';
|
||||
let replyTo = '';
|
||||
|
||||
if (options.ccList) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (options.replyTo) {
|
||||
replyTo = prepareEmailsInput.call(this, options.replyTo as string, 'ReplyTo', i);
|
||||
}
|
||||
|
||||
let attachments: IDataObject[] = [];
|
||||
|
||||
if (options.attachmentsUi) {
|
||||
|
@ -323,6 +328,7 @@ export class GmailV2 implements INodeType {
|
|||
to,
|
||||
cc,
|
||||
bcc,
|
||||
replyTo,
|
||||
subject: this.getNodeParameter('subject', i) as string,
|
||||
...prepareEmailBody.call(this, i),
|
||||
attachments,
|
||||
|
@ -340,7 +346,7 @@ export class GmailV2 implements INodeType {
|
|||
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
||||
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') {
|
||||
//https://developers.google.com/gmail/api/v1/reference/users/messages/get
|
||||
|
@ -514,6 +520,7 @@ export class GmailV2 implements INodeType {
|
|||
let to = '';
|
||||
let cc = '';
|
||||
let bcc = '';
|
||||
let replyTo = '';
|
||||
|
||||
if (options.sendTo) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (options.replyTo) {
|
||||
replyTo = prepareEmailsInput.call(this, options.replyTo as string, 'ReplyTo', i);
|
||||
}
|
||||
|
||||
let attachments: IDataObject[] = [];
|
||||
if (options.attachmentsUi) {
|
||||
attachments = await prepareEmailAttachments.call(
|
||||
|
@ -547,6 +558,7 @@ export class GmailV2 implements INodeType {
|
|||
to,
|
||||
cc,
|
||||
bcc,
|
||||
replyTo,
|
||||
subject: this.getNodeParameter('subject', i) as string,
|
||||
...prepareEmailBody.call(this, i),
|
||||
attachments,
|
||||
|
@ -741,7 +753,7 @@ export class GmailV2 implements INodeType {
|
|||
const messageIdGmail = this.getNodeParameter('messageId', i) as string;
|
||||
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') {
|
||||
//https://developers.google.com/gmail/api/reference/rest/v1/users.threads/trash
|
||||
|
|
|
@ -225,6 +225,19 @@ export const messageFields: INodeProperties[] = [
|
|||
default: '',
|
||||
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',
|
||||
name: 'replyToSenderOnly',
|
||||
|
|
Loading…
Reference in a new issue