2023-07-11 20:26:30 +00:00
|
|
|
import type { TFunction } from "next-i18next";
|
|
|
|
|
|
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
2023-07-28 14:22:19 +00:00
|
|
|
import { TimeFormat } from "@calcom/lib/timeFormat";
|
2023-07-11 20:26:30 +00:00
|
|
|
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<string, unknown> {
|
|
|
|
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) {
|
2023-07-28 14:22:19 +00:00
|
|
|
return this.getFormattedRecipientTime({ time: this.calEvent.startTime, format });
|
2023-07-11 20:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected getOrganizerEnd(format: string) {
|
2023-07-28 14:22:19 +00:00
|
|
|
return this.getFormattedRecipientTime({ time: this.calEvent.endTime, format });
|
2023-07-11 20:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected getFormattedDate() {
|
2023-07-28 14:22:19 +00:00
|
|
|
const organizerTimeFormat = this.calEvent.organizer.timeFormat || TimeFormat.TWELVE_HOUR;
|
|
|
|
return `${this.getOrganizerStart(organizerTimeFormat)} - ${this.getOrganizerEnd(
|
|
|
|
organizerTimeFormat
|
|
|
|
)}, ${this.t(this.getOrganizerStart("dddd").toLowerCase())}, ${this.t(
|
|
|
|
this.getOrganizerStart("MMMM").toLowerCase()
|
|
|
|
)} ${this.getOrganizerStart("D, YYYY")}`;
|
2023-07-11 20:26:30 +00:00
|
|
|
}
|
|
|
|
}
|