From 6b0ac96b38b0dbd78809a73e19010192f31cc769 Mon Sep 17 00:00:00 2001 From: alannnc Date: Thu, 7 Jul 2022 16:25:05 -0600 Subject: [PATCH] Fix request reschedule organiser email (#3227) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix request reschedule organizer email * Updated book a new time link and removed manage or cancel action on user owner email request reschedule * Fix let with const for a variable and change env var to a constant from lib Co-authored-by: Omar López Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/web/pages/api/book/request-reschedule.ts | 6 +++--- apps/web/public/static/locales/en/common.json | 2 +- packages/core/builders/CalendarEvent/builder.ts | 8 ++++---- .../templates/OrganizerRequestRescheduledEmail.tsx | 1 + .../organizer-request-reschedule-email.ts | 14 +++++++++++++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/web/pages/api/book/request-reschedule.ts b/apps/web/pages/api/book/request-reschedule.ts index 85a0e65527..b8ff512fef 100644 --- a/apps/web/pages/api/book/request-reschedule.ts +++ b/apps/web/pages/api/book/request-reschedule.ts @@ -173,10 +173,10 @@ const handler = async ( director.setBuilder(builder); director.setExistingBooking(bookingToReschedule); director.setCancellationReason(cancellationReason); - if (!!event) { - await director.buildWithoutEventTypeForRescheduleEmail(); - } else { + if (event) { await director.buildForRescheduleEmail(); + } else { + await director.buildWithoutEventTypeForRescheduleEmail(); } // Handling calendar and videos cancellation diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 9e603c75e6..d1d75bc397 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -92,7 +92,7 @@ "meeting_password": "Meeting Password", "meeting_url": "Meeting URL", "meeting_request_rejected": "Your meeting request has been rejected", - "rescheduled_event_type_subject": "Rescheduled: {{eventType}} with {{name}} at {{date}}", + "rescheduled_event_type_subject": "Request for reschedule sent: {{eventType}} with {{name}} at {{date}}", "requested_to_reschedule_subject_attendee": "Action Required Reschedule: Please book a new time for {{eventType}} with {{name}}", "rejected_event_type_with_organizer": "Rejected: {{eventType}} with {{organizer}} on {{date}}", "hi": "Hi", diff --git a/packages/core/builders/CalendarEvent/builder.ts b/packages/core/builders/CalendarEvent/builder.ts index 304b489a7a..0ae27e9091 100644 --- a/packages/core/builders/CalendarEvent/builder.ts +++ b/packages/core/builders/CalendarEvent/builder.ts @@ -1,8 +1,9 @@ import { Prisma, Booking } from "@prisma/client"; -import dayjs from "@calcom/dayjs"; import short from "short-uuid"; import { v5 as uuidv5 } from "uuid"; +import dayjs from "@calcom/dayjs"; +import { WEBAPP_URL } from "@calcom/lib/constants"; import { getTranslation } from "@calcom/lib/server/i18n"; import prisma from "@calcom/prisma"; import { CalendarEvent } from "@calcom/types/Calendar"; @@ -70,7 +71,7 @@ export class CalendarEventBuilder implements ICalendarEventBuilder { if (!this.eventType) { throw new Error("exec BuildEventObjectFromInnerClass before calling this function"); } - let users = this.eventType.users; + const users = this.eventType.users; /* If this event was pre-relationship migration */ if (!users.length && this.eventType.userId) { @@ -314,8 +315,7 @@ export class CalendarEventBuilder implements ICalendarEventBuilder { const queryParams = new URLSearchParams(); queryParams.set("rescheduleUid", `${booking.uid}`); slug = `${slug}?${queryParams.toString()}`; - - const rescheduleLink = `${process.env.NEXT_PUBLIC_WEBAPP_URL}/${slug}`; + const rescheduleLink = `${WEBAPP_URL}/${slug}?${queryParams.toString()}`; this.rescheduleLink = rescheduleLink; } catch (error) { if (error instanceof Error) { diff --git a/packages/emails/src/templates/OrganizerRequestRescheduledEmail.tsx b/packages/emails/src/templates/OrganizerRequestRescheduledEmail.tsx index 07175867d3..476634c22e 100644 --- a/packages/emails/src/templates/OrganizerRequestRescheduledEmail.tsx +++ b/packages/emails/src/templates/OrganizerRequestRescheduledEmail.tsx @@ -16,6 +16,7 @@ export const OrganizerRequestRescheduledEmail = ( } headerType="calendarCircle" subject="rescheduled_event_type_subject" + callToAction={null} {...props} /> ); diff --git a/packages/emails/templates/organizer-request-reschedule-email.ts b/packages/emails/templates/organizer-request-reschedule-email.ts index 5de6e4698d..06d6b77d4f 100644 --- a/packages/emails/templates/organizer-request-reschedule-email.ts +++ b/packages/emails/templates/organizer-request-reschedule-email.ts @@ -1,6 +1,7 @@ import { createEvent, DateArray, Person } from "ics"; import dayjs from "@calcom/dayjs"; +import { getRichDescription } from "@calcom/lib/CalEventParser"; import { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -27,7 +28,7 @@ export default class OrganizerRequestRescheduledEmail extends OrganizerScheduled name: this.calEvent.attendees[0].name, date: this.getFormattedDate(), })}`, - html: renderEmail("OrganizerScheduledEmail", { + html: renderEmail("OrganizerRequestRescheduledEmail", { calEvent: this.calEvent, attendee: this.calEvent.organizer, }), @@ -78,4 +79,15 @@ export default class OrganizerRequestRescheduledEmail extends OrganizerScheduled } return icsEvent.value; } + + // @OVERRIDE + protected getTextBody(title = "", subtitle = "", extraInfo = "", callToAction = ""): string { + return ` +${this.t(title)} +${this.t(subtitle)} +${extraInfo} +${getRichDescription(this.calEvent)} +${callToAction} +`.trim(); + } }