feat: translate attendee scheduled email in bookers locale (#7654)

This commit is contained in:
Nafees Nazik authored and GitHub committed 2023-03-10 14:38:29 +00:00
1 parent d50473468a
commit e24f1d8bdb
2 files changed
+24 -8

No files matched your search

+15 -2
View File
@@ -1,5 +1,7 @@
import type { TFunction } from "next-i18next";
import type { EventNameObjectType } from "@calcom/core/event";
import { getEventName } from "@calcom/core/event";
import type BaseEmail from "@calcom/emails/templates/_base-email";
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
@@ -39,7 +41,7 @@ const sendEmail = (prepare: () => BaseEmail) => {
});
};
export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
export const sendScheduledEmails = async (calEvent: CalendarEvent, eventNameObject?: EventNameObjectType) => {
const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent })));
@@ -52,7 +54,18 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
emailsToSend.push(
...calEvent.attendees.map((attendee) => {
return sendEmail(() => new AttendeeScheduledEmail(calEvent, attendee));
return sendEmail(
() =>
new AttendeeScheduledEmail(
{
...calEvent,
...(eventNameObject && {
title: getEventName({ ...eventNameObject, t: attendee.language.translate }),
}),
},
attendee
)
);
})
);
@@ -1267,12 +1267,15 @@ async function handler(
videoCallUrl = metadata.hangoutLink || defaultLocationUrl || videoCallUrl;
}
if (noEmail !== true) {
await sendScheduledEmails({
...evt,
additionalInformation: metadata,
additionalNotes,
customInputs,
});
await sendScheduledEmails(
{
...evt,
additionalInformation: metadata,
additionalNotes,
customInputs,
},
eventNameObject
);
}
}
}