mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat: Add appendN8nAttribution option to sendAndWait operation (#13697)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -18,7 +18,8 @@ import {
|
||||
ACTION_RECORDED_PAGE,
|
||||
BUTTON_STYLE_PRIMARY,
|
||||
BUTTON_STYLE_SECONDARY,
|
||||
createEmailBody,
|
||||
createEmailBodyWithN8nAttribution,
|
||||
createEmailBodyWithoutN8nAttribution,
|
||||
} from './email-templates';
|
||||
import type { IEmail } from './interfaces';
|
||||
import { formFieldsProperties } from '../../nodes/Form/Form.node';
|
||||
@@ -30,6 +31,7 @@ export type SendAndWaitConfig = {
|
||||
message: string;
|
||||
url: string;
|
||||
options: Array<{ label: string; value: string; style: string }>;
|
||||
appendAttribution?: boolean;
|
||||
};
|
||||
|
||||
type FormResponseTypeOptions = {
|
||||
@@ -57,6 +59,15 @@ const limitWaitTimeOption: INodeProperties = {
|
||||
],
|
||||
};
|
||||
|
||||
const appendAttributionOption: INodeProperties = {
|
||||
displayName: 'Append n8n Attribution',
|
||||
name: 'appendAttribution',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to include the phrase "This message was sent automatically with n8n" to the end of the message',
|
||||
};
|
||||
|
||||
// Operation Properties ----------------------------------------------------------
|
||||
export function getSendAndWaitProperties(
|
||||
targetProperties: INodeProperties[],
|
||||
@@ -232,7 +243,7 @@ export function getSendAndWaitProperties(
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
options: [limitWaitTimeOption],
|
||||
options: [limitWaitTimeOption, appendAttributionOption],
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseType: ['approval'],
|
||||
@@ -273,6 +284,7 @@ export function getSendAndWaitProperties(
|
||||
default: 'Submit',
|
||||
},
|
||||
limitWaitTimeOption,
|
||||
appendAttributionOption,
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
@@ -456,11 +468,14 @@ export function getSendAndWaitConfig(context: IExecuteFunctions): SendAndWaitCon
|
||||
buttonDisapprovalStyle?: string;
|
||||
};
|
||||
|
||||
const options = context.getNodeParameter('options', 0, {});
|
||||
|
||||
const config: SendAndWaitConfig = {
|
||||
title: subject,
|
||||
message,
|
||||
url: `${resumeUrl}/${nodeId}`,
|
||||
options: [],
|
||||
appendAttribution: options?.appendAttribution as boolean,
|
||||
};
|
||||
|
||||
const responseType = context.getNodeParameter('responseType', 0, 'approval') as string;
|
||||
@@ -525,14 +540,19 @@ export function createEmail(context: IExecuteFunctions) {
|
||||
for (const option of config.options) {
|
||||
buttons.push(createButton(config.url, option.label, option.value, option.style));
|
||||
}
|
||||
|
||||
const instanceId = context.getInstanceId();
|
||||
let emailBody: string;
|
||||
if (config.appendAttribution !== false) {
|
||||
const instanceId = context.getInstanceId();
|
||||
emailBody = createEmailBodyWithN8nAttribution(config.message, buttons.join('\n'), instanceId);
|
||||
} else {
|
||||
emailBody = createEmailBodyWithoutN8nAttribution(config.message, buttons.join('\n'));
|
||||
}
|
||||
|
||||
const email: IEmail = {
|
||||
to,
|
||||
subject: config.title,
|
||||
body: '',
|
||||
htmlBody: createEmailBody(config.message, buttons.join('\n'), instanceId),
|
||||
htmlBody: emailBody,
|
||||
};
|
||||
|
||||
return email;
|
||||
|
||||
Reference in New Issue
Block a user