Scheduling infrastructure for absolutely everyone.
fix: send attendee email with event updates of reassignment (#17836)
Carina Wollendorferae70786b2b89
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex 2d7c7413b24..ba1a53e7566 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -130,7 +130,9 @@"download_your_transcripts": "Download your Transcripts","your_meeting_has_been_booked": "Your meeting has been booked","event_type_has_been_rescheduled_on_time_date": "Your {{title}} has been rescheduled to {{date}}.",+ "event_type_has_been_updated": "Your {{title}} has been updated.","event_has_been_rescheduled": "Updated - Your event has been rescheduled",+ "event_has_been_updated": "Event has been updated","your_event_has_been_rescheduled": "Your event has been rescheduled","request_reschedule_subtitle": "{{organizer}} has canceled the booking and requested you to pick another time.","request_reschedule_title_organizer": "You have requested {{attendee}} to reschedule",diff --git a/packages/emails/email-manager.ts b/packages/emails/email-manager.tsindex 5e18e8e3d71..92794500670 100644--- a/packages/emails/email-manager.ts+++ b/packages/emails/email-manager.ts@@ -38,6 +38,7 @@ import AttendeeLocationChangeEmail from "./templates/attendee-location-change-emimport AttendeeRequestEmail from "./templates/attendee-request-email";import AttendeeRescheduledEmail from "./templates/attendee-rescheduled-email";import AttendeeScheduledEmail from "./templates/attendee-scheduled-email";+import AttendeeUpdatedEmail from "./templates/attendee-updated-email";import type { EmailVerifyCode } from "./templates/attendee-verify-email";import AttendeeVerifyEmail from "./templates/attendee-verify-email";import AttendeeWasRequestedToRescheduleEmail from "./templates/attendee-was-requested-to-reschedule-email";@@ -195,6 +196,22 @@ export const sendRoundRobinRescheduledEmailsAndSMS = async (await Promise.all(emailsAndSMSToSend);};+export const sendRoundRobinUpdatedEmailsAndSMS = async ({+ calEvent,+ eventTypeMetadata,+}: {+ calEvent: CalendarEvent;+ eventTypeMetadata?: EventTypeMetadata;+}) => {+ if (eventTypeDisableAttendeeEmail(eventTypeMetadata)) return;++ const emailsToSend = calEvent.attendees.map((attendee) =>+ sendEmail(() => new AttendeeUpdatedEmail(calEvent, attendee))+ );++ await Promise.all(emailsToSend);+};+export const sendRoundRobinCancelledEmailsAndSMS = async (calEvent: CalendarEvent,members: Person[],diff --git a/packages/emails/src/templates/AttendeeUpdatedEmail.tsx b/packages/emails/src/templates/AttendeeUpdatedEmail.tsxnew file mode 100644index 00000000000..f9721c53413--- /dev/null+++ b/packages/emails/src/templates/AttendeeUpdatedEmail.tsx@@ -0,0 +1,10 @@+import { AttendeeScheduledEmail } from "./AttendeeScheduledEmail";++export const AttendeeUpdatedEmail = (props: React.ComponentProps<typeof AttendeeScheduledEmail>) => (+ <AttendeeScheduledEmail+ title="event_has_been_updated"+ headerType="calendarCircle"+ subject="event_type_has_been_updated"+ {...props}+ />+);diff --git a/packages/emails/src/templates/index.ts b/packages/emails/src/templates/index.tsindex c5df13bc2fd..129c9ac89eb 100644--- a/packages/emails/src/templates/index.ts+++ b/packages/emails/src/templates/index.ts@@ -6,6 +6,7 @@ export { AttendeeLocationChangeEmail } from "./AttendeeLocationChangeEmail";export { AttendeeRequestEmail } from "./AttendeeRequestEmail";export { AttendeeWasRequestedToRescheduleEmail } from "./AttendeeWasRequestedToRescheduleEmail";export { AttendeeRescheduledEmail } from "./AttendeeRescheduledEmail";+export { AttendeeUpdatedEmail } from "./AttendeeUpdatedEmail";export { AttendeeScheduledEmail } from "./AttendeeScheduledEmail";export { DisabledAppEmail } from "./DisabledAppEmail";export { SlugReplacementEmail } from "./SlugReplacementEmail";diff --git a/packages/emails/templates/attendee-updated-email.ts b/packages/emails/templates/attendee-updated-email.tsnew file mode 100644index 00000000000..5d4fa9c39b7--- /dev/null+++ b/packages/emails/templates/attendee-updated-email.ts@@ -0,0 +1,33 @@+import type { CalendarEvent, Person } from "@calcom/types/Calendar";++import { renderEmail } from "../";+import generateIcsFile, { GenerateIcsRole } from "../lib/generateIcsFile";+import AttendeeScheduledEmail from "./attendee-scheduled-email";++export default class AttendeeUpdatedEmail extends AttendeeScheduledEmail {+ protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {+ return {+ icalEvent: generateIcsFile({+ calEvent: this.calEvent,+ role: GenerateIcsRole.ATTENDEE,+ status: "CONFIRMED",+ }),+ to: `${this.attendee.name} <${this.attendee.email}>`,+ from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`,+ replyTo: [...this.calEvent.attendees.map(({ email }) => email), this.calEvent.organizer.email],+ subject: `${this.attendee.language.translate("event_type_has_been_updated", {+ title: this.calEvent.title,+ date: this.getFormattedDate(),+ })}`,+ html: await this.getHtml(this.calEvent, this.attendee),+ text: this.getTextBody("event_has_been_updated", "emailed_you_and_any_other_attendees"),+ };+ }++ async getHtml(calEvent: CalendarEvent, attendee: Person) {+ return await renderEmail("AttendeeUpdatedEmail", {+ calEvent,+ attendee,+ });+ }+}diff --git a/packages/features/ee/round-robin/roundRobinManualReassignment.ts b/packages/features/ee/round-robin/roundRobinManualReassignment.tsindex 92d805e208c..25f3432124c 100644--- a/packages/features/ee/round-robin/roundRobinManualReassignment.ts+++ b/packages/features/ee/round-robin/roundRobinManualReassignment.ts@@ -4,7 +4,11 @@ import { cloneDeep } from "lodash";import { OrganizerDefaultConferencingAppType, getLocationValueForDB } from "@calcom/app-store/locations";import { getEventName } from "@calcom/core/event";import dayjs from "@calcom/dayjs";-import { sendRoundRobinCancelledEmailsAndSMS, sendRoundRobinScheduledEmailsAndSMS } from "@calcom/emails";+import {+ sendRoundRobinCancelledEmailsAndSMS,+ sendRoundRobinScheduledEmailsAndSMS,+ sendRoundRobinUpdatedEmailsAndSMS,+} from "@calcom/emails";import getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema";import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";import { getEventTypesFromDB } from "@calcom/features/bookings/lib/handleNewBooking/getEventTypesFromDB";@@ -339,6 +343,13 @@ export const roundRobinManualReassignment = async ({}if (hasOrganizerChanged) {+ if (emailsEnabled) {+ // send email with event updates to attendees+ await sendRoundRobinUpdatedEmailsAndSMS({+ calEvent: evtWithoutCancellationReason,+ });+ }+// Handle changing workflows with organizerawait handleWorkflowsUpdate({booking,diff --git a/packages/features/ee/round-robin/roundRobinReassignment.ts b/packages/features/ee/round-robin/roundRobinReassignment.tsindex 709b4e8aed2..42ea0d2f2ff 100644--- a/packages/features/ee/round-robin/roundRobinReassignment.ts+++ b/packages/features/ee/round-robin/roundRobinReassignment.ts@@ -4,7 +4,11 @@ import { cloneDeep } from "lodash";import { OrganizerDefaultConferencingAppType, getLocationValueForDB } from "@calcom/app-store/locations";import { getEventName } from "@calcom/core/event";import dayjs from "@calcom/dayjs";-import { sendRoundRobinCancelledEmailsAndSMS, sendRoundRobinScheduledEmailsAndSMS } from "@calcom/emails";+import {+ sendRoundRobinCancelledEmailsAndSMS,+ sendRoundRobinScheduledEmailsAndSMS,+ sendRoundRobinUpdatedEmailsAndSMS,+} from "@calcom/emails";import getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema";import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";import { ensureAvailableUsers } from "@calcom/features/bookings/lib/handleNewBooking/ensureAvailableUsers";@@ -389,6 +393,13 @@ export const roundRobinReassignment = async ({// Handle changing workflows with organizerif (hasOrganizerChanged) {+ if (emailsEnabled) {+ // send email with event updates to attendees+ await sendRoundRobinUpdatedEmailsAndSMS({+ calEvent: evtWithoutCancellationReason,+ });+ }+const scheduledWorkflowReminders = await prisma.workflowReminder.findMany({where: {bookingUid: booking.uid,diff --git a/packages/platform/libraries/index.ts b/packages/platform/libraries/index.tsindex e53978b604c..dd977dd3b80 100644--- a/packages/platform/libraries/index.ts+++ b/packages/platform/libraries/index.ts@@ -10,6 +10,7 @@ import AttendeeDeclinedEmail from "@calcom/emails/templates/attendee-declined-emimport AttendeeRequestEmail from "@calcom/emails/templates/attendee-request-email";import AttendeeRescheduledEmail from "@calcom/emails/templates/attendee-rescheduled-email";import AttendeeScheduledEmail from "@calcom/emails/templates/attendee-scheduled-email";+import AttendeeUpdatedEmail from "@calcom/emails/templates/attendee-updated-email";import OrganizerCancelledEmail from "@calcom/emails/templates/organizer-cancelled-email";import OrganizerReassignedEmail from "@calcom/emails/templates/organizer-reassigned-email";import OrganizerRequestEmail from "@calcom/emails/templates/organizer-request-email";@@ -212,6 +213,8 @@ export { OrganizerRescheduledEmail };export { AttendeeRescheduledEmail };+export { AttendeeUpdatedEmail };+export { OrganizerRequestEmail };export { AttendeeRequestEmail };