fix: creating workflow reminders for existing bookings when new step is added (#12878)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
parent
e248dfbda7
commit
24264c32dc
|
@ -262,7 +262,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const promiseSteps = steps.map(async (step) => {
|
const promiseSteps = userWorkflow.steps.map(async (step) => {
|
||||||
if (
|
if (
|
||||||
step.action !== WorkflowActions.SMS_ATTENDEE &&
|
step.action !== WorkflowActions.SMS_ATTENDEE &&
|
||||||
step.action !== WorkflowActions.WHATSAPP_ATTENDEE
|
step.action !== WorkflowActions.WHATSAPP_ATTENDEE
|
||||||
|
@ -327,7 +327,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||||
emailSubject: step.emailSubject || "",
|
emailSubject: step.emailSubject || "",
|
||||||
emailBody: step.reminderBody || "",
|
emailBody: step.reminderBody || "",
|
||||||
template: step.template,
|
template: step.template,
|
||||||
sender: step.senderName,
|
sender: step.sender,
|
||||||
workflowStepId: step.id,
|
workflowStepId: step.id,
|
||||||
});
|
});
|
||||||
} else if (step.action === WorkflowActions.SMS_NUMBER) {
|
} else if (step.action === WorkflowActions.SMS_NUMBER) {
|
||||||
|
@ -619,11 +619,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||||
return stepToAdd;
|
return stepToAdd;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (addedSteps) {
|
if (addedSteps) {
|
||||||
const eventTypesToCreateReminders = activeOn.filter(
|
|
||||||
(activeEventType) => activeEventType && !newEventTypes.includes(activeEventType)
|
|
||||||
);
|
|
||||||
const promiseAddedSteps = addedSteps.map(async (step) => {
|
const promiseAddedSteps = addedSteps.map(async (step) => {
|
||||||
if (step) {
|
if (step) {
|
||||||
const { senderName, ...newStep } = step;
|
const { senderName, ...newStep } = step;
|
||||||
|
@ -637,13 +633,12 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
(trigger === WorkflowTriggerEvents.BEFORE_EVENT || trigger === WorkflowTriggerEvents.AFTER_EVENT) &&
|
(trigger === WorkflowTriggerEvents.BEFORE_EVENT || trigger === WorkflowTriggerEvents.AFTER_EVENT) &&
|
||||||
eventTypesToCreateReminders &&
|
|
||||||
step.action !== WorkflowActions.SMS_ATTENDEE &&
|
step.action !== WorkflowActions.SMS_ATTENDEE &&
|
||||||
step.action !== WorkflowActions.WHATSAPP_ATTENDEE
|
step.action !== WorkflowActions.WHATSAPP_ATTENDEE
|
||||||
) {
|
) {
|
||||||
const bookingsForReminders = await ctx.prisma.booking.findMany({
|
const bookingsForReminders = await ctx.prisma.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
eventTypeId: { in: eventTypesToCreateReminders as number[] },
|
eventTypeId: { in: activeOn },
|
||||||
status: BookingStatus.ACCEPTED,
|
status: BookingStatus.ACCEPTED,
|
||||||
startTime: {
|
startTime: {
|
||||||
gte: new Date(),
|
gte: new Date(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user