fix: improve cancellation email of reschedule RR booking (#17768)
* fix: improve cancellation email of reschedule RR booking * fix failing test * fix: uses same lucky user when rescheduling RR booking also has a fixed host * chore * chore * better message in the cancelled email * fix * fix * add booker rescheduled in reassigned email to old host * test * add reassigned subtite * fix: use same lucky user when reschedule RR booking has a fixed host * fix: test * fix: subtitle --------- Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
1 parent
a4915184cd
commit
afea724e4d
10 files changed
+107
-44
No files matched your search
@@ -80,8 +80,8 @@ import { CreationSource } from "@calcom/prisma/enums";
|
||||
import {
|
||||
eventTypeAppMetadataOptionalSchema,
|
||||
eventTypeMetaDataSchemaWithTypedApps,
|
||||
userMetadata as userMetadataSchema,
|
||||
} from "@calcom/prisma/zod-utils";
|
||||
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util";
|
||||
import type {
|
||||
AdditionalInformation,
|
||||
@@ -1929,7 +1929,21 @@ async function handler(
|
||||
members: newBookedMembers,
|
||||
eventTypeMetadata: eventType.metadata,
|
||||
});
|
||||
sendRoundRobinCancelledEmailsAndSMS(cancelledRRHostEvt, cancelledMembers, eventType.metadata);
|
||||
const reassignedTo = users.find(
|
||||
(user) => !user.isFixed && newBookedMembers.some((member) => member.email === user.email)
|
||||
);
|
||||
sendRoundRobinCancelledEmailsAndSMS(
|
||||
cancelledRRHostEvt,
|
||||
cancelledMembers,
|
||||
eventType.metadata,
|
||||
!!reassignedTo
|
||||
? {
|
||||
name: reassignedTo.name,
|
||||
email: reassignedTo.email,
|
||||
...(reqBody.rescheduledBy === bookerEmail && { reason: "Booker Rescheduled" }),
|
||||
}
|
||||
: undefined
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!isDryRun) {
|
||||
|
||||
@@ -2006,7 +2006,7 @@ describe("handleNewBooking", () => {
|
||||
});
|
||||
describe("Team event-type", () => {
|
||||
test(
|
||||
"should send correct schedule/cancellation emails to hosts when round robin is rescheduled to different host",
|
||||
"should send correct schedule/cancellation/reassigned emails to hosts when round robin is rescheduled to different host",
|
||||
async ({ emails }) => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const booker = getBooker({
|
||||
@@ -2158,6 +2158,7 @@ describe("handleNewBooking", () => {
|
||||
prevOrganizer: roundRobinHost1,
|
||||
newOrganizer: roundRobinHost2,
|
||||
emails,
|
||||
bookerReschedule: true,
|
||||
});
|
||||
},
|
||||
timeout
|
||||
|
||||
@@ -463,9 +463,9 @@ describe("roundRobinManualReassignment test", () => {
|
||||
const roundRobinManualReassignment = (await import("./roundRobinManualReassignment")).default;
|
||||
await mockEventManagerReschedule();
|
||||
|
||||
const sendRoundRobinCancelledEmailsAndSMSSpy = vi.spyOn(
|
||||
const sendRoundRobinReassignedEmailsAndSMSSpy = vi.spyOn(
|
||||
await import("@calcom/emails"),
|
||||
"sendRoundRobinCancelledEmailsAndSMS"
|
||||
"sendRoundRobinReassignedEmailsAndSMS"
|
||||
);
|
||||
|
||||
const testDestinationCalendar = createTestDestinationCalendar();
|
||||
@@ -521,7 +521,7 @@ describe("roundRobinManualReassignment test", () => {
|
||||
reassignedById: 1,
|
||||
});
|
||||
|
||||
expect(sendRoundRobinCancelledEmailsAndSMSSpy).toHaveBeenCalledTimes(1);
|
||||
expect(sendRoundRobinReassignedEmailsAndSMSSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cloneDeep } from "lodash";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import {
|
||||
sendRoundRobinCancelledEmailsAndSMS,
|
||||
sendRoundRobinReassignedEmailsAndSMS,
|
||||
sendRoundRobinScheduledEmailsAndSMS,
|
||||
sendRoundRobinUpdatedEmailsAndSMS,
|
||||
} from "@calcom/emails";
|
||||
@@ -373,9 +373,9 @@ export const roundRobinManualReassignment = async ({
|
||||
};
|
||||
|
||||
if (previousRRHost && emailsEnabled) {
|
||||
await sendRoundRobinCancelledEmailsAndSMS(
|
||||
cancelledEvt,
|
||||
[
|
||||
await sendRoundRobinReassignedEmailsAndSMS({
|
||||
calEvent: cancelledEvt,
|
||||
members: [
|
||||
{
|
||||
...previousRRHost,
|
||||
name: previousRRHost.name || "",
|
||||
@@ -384,9 +384,9 @@ export const roundRobinManualReassignment = async ({
|
||||
language: { translate: previousRRHostT, locale: previousRRHost.locale || "en" },
|
||||
},
|
||||
],
|
||||
eventType?.metadata as EventTypeMetadata,
|
||||
{ name: newUser.name, email: newUser.email }
|
||||
);
|
||||
reassignedTo: { name: newUser.name, email: newUser.email },
|
||||
eventTypeMetadata: eventType?.metadata as EventTypeMetadata,
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOrganizerChanged) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { cloneDeep } from "lodash";
|
||||
import { OrganizerDefaultConferencingAppType, getLocationValueForDB } from "@calcom/app-store/locations";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import {
|
||||
sendRoundRobinCancelledEmailsAndSMS,
|
||||
sendRoundRobinReassignedEmailsAndSMS,
|
||||
sendRoundRobinScheduledEmailsAndSMS,
|
||||
sendRoundRobinUpdatedEmailsAndSMS,
|
||||
} from "@calcom/emails";
|
||||
@@ -420,9 +420,9 @@ export const roundRobinReassignment = async ({
|
||||
}
|
||||
|
||||
if (emailsEnabled) {
|
||||
await sendRoundRobinCancelledEmailsAndSMS(
|
||||
cancelledRRHostEvt,
|
||||
[
|
||||
await sendRoundRobinReassignedEmailsAndSMS({
|
||||
calEvent: cancelledRRHostEvt,
|
||||
members: [
|
||||
{
|
||||
...previousRRHost,
|
||||
name: previousRRHost.name || "",
|
||||
@@ -431,9 +431,9 @@ export const roundRobinReassignment = async ({
|
||||
language: { translate: previousRRHostT, locale: previousRRHost.locale || "en" },
|
||||
},
|
||||
],
|
||||
eventType?.metadata as EventTypeMetadata,
|
||||
{ name: reassignedRRHost.name, email: reassignedRRHost.email }
|
||||
);
|
||||
reassignedTo: { name: reassignedRRHost.name, email: reassignedRRHost.email },
|
||||
eventTypeMetadata: eventType?.metadata as EventTypeMetadata,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user