fix: workflow reminder emails on reassigned bookings (#17305)
This commit is contained in:
1 parent
c0529a26c4
commit
8811ebcc33
2 files changed
+33
-7
No files matched your search
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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 organizer
|
||||
if (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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user