+ Hello {{ fullName }}, +
- Someone has requested a link to change your password, and you can do this through the link below. ++ Someone has requested a link to change your password, and you can do this through the link below. +
- Change my password + - If you didn't request this, please ignore this email. - Your password won't change until you access the link above and create a new one. ++ If you didn't request this, please ignore this email. Your password won't change until you access the link above and create a new one. +
diff --git a/packages/backend/src/worker.ts b/packages/backend/src/worker.ts index 8a5cb447..9e0d5646 100644 --- a/packages/backend/src/worker.ts +++ b/packages/backend/src/worker.ts @@ -4,6 +4,7 @@ import './workers/flow'; import './workers/trigger'; import './workers/action'; import './workers/email'; +import './workers/delete-user.ee'; import telemetry from './helpers/telemetry'; telemetry.setServiceType('worker'); diff --git a/packages/backend/src/workers/action.ts b/packages/backend/src/workers/action.ts index 40c2e6c8..22d1169e 100644 --- a/packages/backend/src/workers/action.ts +++ b/packages/backend/src/workers/action.ts @@ -21,7 +21,7 @@ const DEFAULT_DELAY_DURATION = 0; export const worker = new Worker( 'action', async (job) => { - const { stepId, flowId, executionId, computedParameters } = await processAction( + const { stepId, flowId, executionId, computedParameters, executionStep } = await processAction( job.data as JobData ); @@ -48,6 +48,10 @@ export const worker = new Worker( jobOptions.delay = delayAsMilliseconds(step.key, computedParameters); } + if (step.appKey === 'filter' && !executionStep.dataOut) { + return; + } + await actionQueue.add(jobName, jobPayload, jobOptions); }, { connection: redisConfig } diff --git a/packages/backend/src/workers/delete-user.ee.ts b/packages/backend/src/workers/delete-user.ee.ts new file mode 100644 index 00000000..887149a2 --- /dev/null +++ b/packages/backend/src/workers/delete-user.ee.ts @@ -0,0 +1,44 @@ +import { Worker } from 'bullmq'; +import redisConfig from '../config/redis'; +import logger from '../helpers/logger'; +import User from '../models/user'; +import Execution from '../models/execution'; +import ExecutionStep from '../models/execution-step'; + +export const worker = new Worker( + 'delete-user', + async (job) => { + const { id } = job.data; + + const user = await User.query().findById(id).throwIfNotFound(); + + const executionIds = ( + await user.$relatedQuery('executions').select('executions.id') + ).map((execution: Execution) => execution.id); + + await ExecutionStep.query().hardDelete().whereIn('execution_id', executionIds); + await user.$relatedQuery('executions').hardDelete(); + await user.$relatedQuery('steps').hardDelete(); + await user.$relatedQuery('flows').hardDelete(); + await user.$relatedQuery('connections').hardDelete(); + + await user.$query().hardDelete(); + }, + { connection: redisConfig } +); + +worker.on('completed', (job) => { + logger.info( + `JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has been deleted!` + ); +}); + +worker.on('failed', (job, err) => { + logger.info( + `JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has failed to be deleted! ${err.message}` + ); +}); + +process.on('SIGTERM', async () => { + await worker.close(); +}); diff --git a/packages/backend/src/workers/email.ts b/packages/backend/src/workers/email.ts index d8ff037c..953f9c41 100644 --- a/packages/backend/src/workers/email.ts +++ b/packages/backend/src/workers/email.ts @@ -8,13 +8,13 @@ import appConfig from '../config/app'; export const worker = new Worker( 'email', async (job) => { - const { email, subject, templateName, params } = job.data; + const { email, subject, template, params } = job.data; await mailer.sendMail({ to: email, from: appConfig.fromEmail, subject: subject, - html: compileEmail(templateName, params), + html: compileEmail(template, params), }); }, { connection: redisConfig } diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index 7f56d0e7..145c68a6 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -82,6 +82,7 @@ export interface IFlow { export interface IUser { id: string; + fullName: string; email: string; password: string; connections: IConnection[]; @@ -104,6 +105,7 @@ export interface IFieldDropdown { dependsOn?: string[]; options?: IFieldDropdownOption[]; source?: IFieldDropdownSource; + additionalFields?: IFieldDropdownAdditionalFields; } export interface IFieldDropdownSource { @@ -114,6 +116,14 @@ export interface IFieldDropdownSource { value: string; }[]; } +export interface IFieldDropdownAdditionalFields { + type: string; + name: string; + arguments: { + name: string; + value: string; + }[]; +} export interface IFieldDropdownOption { label: string; @@ -167,6 +177,7 @@ export interface IApp { flowCount?: number; beforeRequest?: TBeforeRequest[]; dynamicData?: IDynamicData; + dynamicFields?: IDynamicFields; triggers?: ITrigger[]; actions?: IAction[]; connections?: IConnection[]; @@ -180,6 +191,10 @@ export interface IDynamicData { [index: string]: any; } +export interface IDynamicFields { + [index: string]: any; +} + export interface IAuth { generateAuthUrl?($: IGlobalVariable): Promise