From 9c7428571d4ca13ba6b8eaf2d1f478900e2c23ea Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Wed, 12 Jul 2023 01:56:30 +0530 Subject: [PATCH] feat: added organizer daily video recording email (#9667) Co-authored-by: Shivam Kalra --- packages/emails/email-manager.ts | 3 + ...x => DailyVideoDownloadRecordingEmail.tsx} | 6 +- packages/emails/src/templates/index.ts | 2 +- ...ee-daily-video-download-recording-email.ts | 2 +- ...er-daily-video-download-recording-email.ts | 57 +++++++++++++++++++ 5 files changed, 65 insertions(+), 5 deletions(-) rename packages/emails/src/templates/{AttendeeDailyVideoDownloadRecordingEmail.tsx => DailyVideoDownloadRecordingEmail.tsx} (92%) create mode 100644 packages/emails/templates/organizer-daily-video-download-recording-email.ts diff --git a/packages/emails/email-manager.ts b/packages/emails/email-manager.ts index 44de262023..1c032dd91c 100644 --- a/packages/emails/email-manager.ts +++ b/packages/emails/email-manager.ts @@ -31,6 +31,7 @@ import type { OrganizationEmailVerify } from "./templates/organization-email-ver import OrganizationEmailVerification from "./templates/organization-email-verification"; import OrganizerAttendeeCancelledSeatEmail from "./templates/organizer-attendee-cancelled-seat-email"; import OrganizerCancelledEmail from "./templates/organizer-cancelled-email"; +import OrganizerDailyVideoDownloadRecordingEmail from "./templates/organizer-daily-video-download-recording-email"; import OrganizerLocationChangeEmail from "./templates/organizer-location-change-email"; import OrganizerPaymentRefundFailedEmail from "./templates/organizer-payment-refund-failed-email"; import OrganizerRequestEmail from "./templates/organizer-request-email"; @@ -355,6 +356,8 @@ export const sendNoShowFeeChargedEmail = async (attendee: Person, evt: CalendarE export const sendDailyVideoRecordingEmails = async (calEvent: CalendarEvent, downloadLink: string) => { const emailsToSend: Promise[] = []; + emailsToSend.push(sendEmail(() => new OrganizerDailyVideoDownloadRecordingEmail(calEvent, downloadLink))); + for (const attendee of calEvent.attendees) { emailsToSend.push( sendEmail(() => new AttendeeDailyVideoDownloadRecordingEmail(calEvent, attendee, downloadLink)) diff --git a/packages/emails/src/templates/AttendeeDailyVideoDownloadRecordingEmail.tsx b/packages/emails/src/templates/DailyVideoDownloadRecordingEmail.tsx similarity index 92% rename from packages/emails/src/templates/AttendeeDailyVideoDownloadRecordingEmail.tsx rename to packages/emails/src/templates/DailyVideoDownloadRecordingEmail.tsx index c21d0dfb28..5b176c8b13 100644 --- a/packages/emails/src/templates/AttendeeDailyVideoDownloadRecordingEmail.tsx +++ b/packages/emails/src/templates/DailyVideoDownloadRecordingEmail.tsx @@ -4,7 +4,7 @@ import { WEBAPP_URL, APP_NAME, COMPANY_NAME } from "@calcom/lib/constants"; import { V2BaseEmailHtml, CallToAction } from "../components"; -interface AttendeeDailyVideoDownloadRecordingEmailProps { +interface DailyVideoDownloadRecordingEmailProps { language: TFunction; downloadLink: string; title: string; @@ -12,8 +12,8 @@ interface AttendeeDailyVideoDownloadRecordingEmailProps { name: string; } -export const AttendeeDailyVideoDownloadRecordingEmail = ( - props: AttendeeDailyVideoDownloadRecordingEmailProps & Partial> +export const DailyVideoDownloadRecordingEmail = ( + props: DailyVideoDownloadRecordingEmailProps & Partial> ) => { const image = WEBAPP_URL + "/emails/logo.png"; return ( diff --git a/packages/emails/src/templates/index.ts b/packages/emails/src/templates/index.ts index 880a2d2a98..eb44d10278 100644 --- a/packages/emails/src/templates/index.ts +++ b/packages/emails/src/templates/index.ts @@ -25,6 +25,6 @@ export { OrganizerAttendeeCancelledSeatEmail } from "./OrganizerAttendeeCancelle export { NoShowFeeChargedEmail } from "./NoShowFeeChargedEmail"; export { VerifyAccountEmail } from "./VerifyAccountEmail"; export * from "@calcom/app-store/routing-forms/emails/components"; -export { AttendeeDailyVideoDownloadRecordingEmail } from "./AttendeeDailyVideoDownloadRecordingEmail"; +export { DailyVideoDownloadRecordingEmail } from "./DailyVideoDownloadRecordingEmail"; export { OrganisationAccountVerifyEmail } from "./OrganizationAccountVerifyEmail"; export { OrgAutoInviteEmail } from "./OrgAutoInviteEmail"; diff --git a/packages/emails/templates/attendee-daily-video-download-recording-email.ts b/packages/emails/templates/attendee-daily-video-download-recording-email.ts index e878f0b705..4a7d679a53 100644 --- a/packages/emails/templates/attendee-daily-video-download-recording-email.ts +++ b/packages/emails/templates/attendee-daily-video-download-recording-email.ts @@ -29,7 +29,7 @@ export default class AttendeeDailyVideoDownloadRecordingEmail extends BaseEmail title: this.calEvent.title, date: this.getFormattedDate(), })}`, - html: renderEmail("AttendeeDailyVideoDownloadRecordingEmail", { + html: renderEmail("DailyVideoDownloadRecordingEmail", { title: this.calEvent.title, date: this.getFormattedDate(), downloadLink: this.downloadLink, diff --git a/packages/emails/templates/organizer-daily-video-download-recording-email.ts b/packages/emails/templates/organizer-daily-video-download-recording-email.ts new file mode 100644 index 0000000000..923a1f9251 --- /dev/null +++ b/packages/emails/templates/organizer-daily-video-download-recording-email.ts @@ -0,0 +1,57 @@ +import type { TFunction } from "next-i18next"; + +import { APP_NAME } from "@calcom/lib/constants"; +import type { CalendarEvent } from "@calcom/types/Calendar"; + +import { renderEmail } from "../"; +import BaseEmail from "./_base-email"; + +export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmail { + calEvent: CalendarEvent; + downloadLink: string; + t: TFunction; + + constructor(calEvent: CalendarEvent, downloadLink: string) { + super(); + this.name = "SEND_RECORDING_DOWNLOAD_LINK"; + this.calEvent = calEvent; + this.downloadLink = downloadLink; + this.t = this.calEvent.organizer.language.translate; + } + protected getNodeMailerPayload(): Record { + return { + to: `${this.calEvent.organizer.email}>`, + from: `${APP_NAME} <${this.getMailerOptions().from}>`, + replyTo: [...this.calEvent.attendees.map(({ email }) => email), this.calEvent.organizer.email], + subject: `${this.t("download_recording_subject", { + title: this.calEvent.title, + date: this.getFormattedDate(), + })}`, + html: renderEmail("DailyVideoDownloadRecordingEmail", { + title: this.calEvent.title, + date: this.getFormattedDate(), + downloadLink: this.downloadLink, + language: this.t, + name: this.calEvent.organizer.name, + }), + }; + } + + protected getTimezone(): string { + return this.calEvent.organizer.timeZone; + } + + protected getOrganizerStart(format: string) { + return this.getRecipientTime(this.calEvent.startTime, format); + } + + protected getOrganizerEnd(format: string) { + return this.getRecipientTime(this.calEvent.endTime, format); + } + + protected getFormattedDate() { + return `${this.getOrganizerStart("h:mma")} - ${this.getOrganizerEnd("h:mma")}, ${this.t( + this.getOrganizerStart("dddd").toLowerCase() + )}, ${this.t(this.getOrganizerStart("MMMM").toLowerCase())} ${this.getOrganizerStart("D, YYYY")}`; + } +}