fix: Stop sending Reminders when a 'Seat' cancels the Event (#10405)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-08-01 10:13:28 -04:00
1 parent a0fc045852
commit 17855251ff
14 files changed
+68 -22

No files matched your search

@@ -40,7 +40,8 @@ export const scheduleEmailReminder = async (
workflowStepId: number,
template: WorkflowTemplates,
sender: string,
hideBranding?: boolean
hideBranding?: boolean,
seatReferenceUid?: string
) => {
if (action === WorkflowActions.EMAIL_ADDRESS) return;
const { startTime, endTime } = evt;
@@ -221,6 +222,7 @@ export const scheduleEmailReminder = async (
scheduledDate: scheduledDate.toDate(),
scheduled: true,
referenceId: batchIdResponse[1].batch_id,
seatReferenceId: seatReferenceUid,
},
});
} catch (error) {
@@ -235,6 +237,7 @@ export const scheduleEmailReminder = async (
method: WorkflowMethods.EMAIL,
scheduledDate: scheduledDate.toDate(),
scheduled: false,
seatReferenceId: seatReferenceUid,
},
});
}
@@ -20,6 +20,7 @@ type ProcessWorkflowStepParams = {
calendarEvent: ExtendedCalendarEvent;
emailAttendeeSendToOverride?: string;
hideBranding?: boolean;
seatReferenceUid?: string;
};
export interface ScheduleWorkflowRemindersArgs extends ProcessWorkflowStepParams {
@@ -41,6 +42,7 @@ const processWorkflowStep = async (
calendarEvent: evt,
emailAttendeeSendToOverride,
hideBranding,
seatReferenceUid,
}: ProcessWorkflowStepParams
) => {
if (step.action === WorkflowActions.SMS_ATTENDEE || step.action === WorkflowActions.SMS_NUMBER) {
@@ -60,7 +62,8 @@ const processWorkflowStep = async (
step.sender || SENDER_ID,
workflow.userId,
workflow.teamId,
step.numberVerificationPending
step.numberVerificationPending,
seatReferenceUid
);
} else if (step.action === WorkflowActions.EMAIL_ATTENDEE || step.action === WorkflowActions.EMAIL_HOST) {
let sendTo: string[] = [];
@@ -93,7 +96,8 @@ const processWorkflowStep = async (
step.id,
step.template,
step.sender || SENDER_NAME,
hideBranding
hideBranding,
seatReferenceUid
);
} else if (isWhatsappAction(step.action)) {
const sendTo = step.action === WorkflowActions.WHATSAPP_ATTENDEE ? smsReminderNumber : step.sendTo;
@@ -111,7 +115,8 @@ const processWorkflowStep = async (
step.template,
workflow.userId,
workflow.teamId,
step.numberVerificationPending
step.numberVerificationPending,
seatReferenceUid
);
}
};
@@ -126,7 +131,9 @@ export const scheduleWorkflowReminders = async (args: ScheduleWorkflowRemindersA
isFirstRecurringEvent = false,
emailAttendeeSendToOverride = "",
hideBranding,
seatReferenceUid,
} = args;
if (requiresConfirmation || !workflows.length) return;
for (const workflowReference of workflows) {
@@ -157,6 +164,7 @@ export const scheduleWorkflowReminders = async (args: ScheduleWorkflowRemindersA
emailAttendeeSendToOverride,
smsReminderNumber,
hideBranding,
seatReferenceUid,
});
}
}
@@ -60,7 +60,8 @@ export const scheduleSMSReminder = async (
sender: string,
userId?: number | null,
teamId?: number | null,
isVerificationPending = false
isVerificationPending = false,
seatReferenceUid?: string
) => {
const { startTime, endTime } = evt;
const uid = evt.uid as string;
@@ -174,6 +175,7 @@ export const scheduleSMSReminder = async (
scheduledDate: scheduledDate.toDate(),
scheduled: true,
referenceId: scheduledSMS.sid,
seatReferenceId: seatReferenceUid,
},
});
} catch (error) {
@@ -188,6 +190,7 @@ export const scheduleSMSReminder = async (
method: WorkflowMethods.SMS,
scheduledDate: scheduledDate.toDate(),
scheduled: false,
seatReferenceId: seatReferenceUid,
},
});
}
@@ -200,6 +203,7 @@ export const deleteScheduledSMSReminder = async (reminderId: number, referenceId
if (referenceId) {
await twilio.cancelSMS(referenceId);
}
await prisma.workflowReminder.delete({
where: {
id: reminderId,
@@ -36,7 +36,8 @@ export const scheduleWhatsappReminder = async (
template: WorkflowTemplates,
userId?: number | null,
teamId?: number | null,
isVerificationPending = false
isVerificationPending = false,
seatReferenceUid?: string
) => {
const { startTime, endTime } = evt;
const uid = evt.uid as string;
@@ -184,6 +185,7 @@ export const scheduleWhatsappReminder = async (
scheduledDate: scheduledDate.toDate(),
scheduled: true,
referenceId: scheduledWHATSAPP.sid,
seatReferenceId: seatReferenceUid,
},
});
} catch (error) {
@@ -198,6 +200,7 @@ export const scheduleWhatsappReminder = async (
method: WorkflowMethods.WHATSAPP,
scheduledDate: scheduledDate.toDate(),
scheduled: false,
seatReferenceId: seatReferenceUid,
},
});
}