Scheduling infrastructure for absolutely everyone.
fix: workflow reminder emails on reassigned bookings (#17305)
Carina Wollendorfer8811ebcc33b9
diff --git a/packages/features/ee/round-robin/roundRobinManualReassignment.ts b/packages/features/ee/round-robin/roundRobinManualReassignment.tsindex fa8f452ee25..f18f9970e0b 100644--- a/packages/features/ee/round-robin/roundRobinManualReassignment.ts+++ b/packages/features/ee/round-robin/roundRobinManualReassignment.ts@@ -16,6 +16,7 @@ import {import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";import { isPrismaObjOrUndefined } from "@calcom/lib";import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";+import { SENDER_NAME } from "@calcom/lib/constants";import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";import logger from "@calcom/lib/logger";import { getTranslation } from "@calcom/lib/server/i18n";@@ -347,8 +348,9 @@ async function handleWorkflowsUpdate({where: {bookingUid: booking.uid,method: WorkflowMethods.EMAIL,+ scheduled: true,+ OR: [{ cancelled: false }, { cancelled: null }],workflowStep: {- action: WorkflowActions.EMAIL_HOST,workflow: {trigger: {in: [@@ -365,6 +367,7 @@ async function handleWorkflowsUpdate({referenceId: true,workflowStep: {select: {+ id: true,template: true,workflow: {select: {@@ -373,6 +376,10 @@ async function handleWorkflowsUpdate({timeUnit: true,},},+ emailSubject: true,+ reminderBody: true,+ sender: true,+ includeCalendarEvent: true,},},},@@ -382,10 +389,10 @@ async function handleWorkflowsUpdate({const bookerUrl = await getBookerBaseUrl(orgId);for (const workflowReminder of workflowReminders) {- const workflowStep = workflowReminder?.workflowStep;- const workflow = workflowStep?.workflow;+ const workflowStep = workflowReminder.workflowStep;- if (workflowStep && workflow) {+ if (workflowStep) {+ const workflow = workflowStep.workflow;await scheduleEmailReminder({evt: {...evt,@@ -401,6 +408,12 @@ async function handleWorkflowsUpdate({},sendTo: newUser.email,template: workflowStep.template,+ emailSubject: workflowStep.emailSubject || undefined,+ emailBody: workflowStep.reminderBody || undefined,+ sender: workflowStep.sender || SENDER_NAME,+ hideBranding: true,+ includeCalendarEvent: workflowStep.includeCalendarEvent,+ workflowStepId: workflowStep.id,});}diff --git a/packages/features/ee/round-robin/roundRobinReassignment.ts b/packages/features/ee/round-robin/roundRobinReassignment.tsindex 9e402ec3d39..6650de3bf52 100644--- a/packages/features/ee/round-robin/roundRobinReassignment.ts+++ b/packages/features/ee/round-robin/roundRobinReassignment.ts@@ -18,6 +18,7 @@ import {import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";import { isPrismaObjOrUndefined } from "@calcom/lib";import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";+import { SENDER_NAME } from "@calcom/lib/constants";import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";import logger from "@calcom/lib/logger";import { getLuckyUser } from "@calcom/lib/server";@@ -382,12 +383,13 @@ export const roundRobinReassignment = async ({// Handle changing workflows with organizerif (hasOrganizerChanged) {- const workflowReminders = await prisma.workflowReminder.findMany({+ const scheduledWorkflowReminders = await prisma.workflowReminder.findMany({where: {bookingUid: booking.uid,method: WorkflowMethods.EMAIL,+ scheduled: true,+ OR: [{ cancelled: false }, { cancelled: null }],workflowStep: {- action: WorkflowActions.EMAIL_HOST,workflow: {trigger: {in: [@@ -404,6 +406,7 @@ export const roundRobinReassignment = async ({referenceId: true,workflowStep: {select: {+ id: true,template: true,workflow: {select: {@@ -412,6 +415,10 @@ export const roundRobinReassignment = async ({timeUnit: true,},},+ emailSubject: true,+ reminderBody: true,+ sender: true,+ includeCalendarEvent: true,},},},@@ -421,7 +428,7 @@ export const roundRobinReassignment = async ({const bookerUrl = await getBookerBaseUrl(orgId);- for (const workflowReminder of workflowReminders) {+ for (const workflowReminder of scheduledWorkflowReminders) {const workflowStep = workflowReminder?.workflowStep;const workflow = workflowStep?.workflow;@@ -441,6 +448,12 @@ export const roundRobinReassignment = async ({},sendTo: reassignedRRHost.email,template: workflowStep.template,+ emailSubject: workflowStep.emailSubject || undefined,+ emailBody: workflowStep.reminderBody || undefined,+ sender: workflowStep.sender || SENDER_NAME,+ hideBranding: true,+ includeCalendarEvent: workflowStep.includeCalendarEvent,+ workflowStepId: workflowStep.id,});}