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

pull/7215/head^2
Nafees Nazik 2023-03-10 20:08:29 +05:30 committed by GitHub
parent d50473468a
commit e24f1d8bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View File

@ -1,5 +1,7 @@
import type { TFunction } from "next-i18next"; 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 BaseEmail from "@calcom/emails/templates/_base-email";
import type { CalendarEvent, Person } from "@calcom/types/Calendar"; 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>[] = []; const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent }))); emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent })));
@ -52,7 +54,18 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
emailsToSend.push( emailsToSend.push(
...calEvent.attendees.map((attendee) => { ...calEvent.attendees.map((attendee) => {
return sendEmail(() => new AttendeeScheduledEmail(calEvent, attendee)); return sendEmail(
() =>
new AttendeeScheduledEmail(
{
...calEvent,
...(eventNameObject && {
title: getEventName({ ...eventNameObject, t: attendee.language.translate }),
}),
},
attendee
)
);
}) })
); );

View File

@ -1267,12 +1267,15 @@ async function handler(
videoCallUrl = metadata.hangoutLink || defaultLocationUrl || videoCallUrl; videoCallUrl = metadata.hangoutLink || defaultLocationUrl || videoCallUrl;
} }
if (noEmail !== true) { if (noEmail !== true) {
await sendScheduledEmails({ await sendScheduledEmails(
...evt, {
additionalInformation: metadata, ...evt,
additionalNotes, additionalInformation: metadata,
customInputs, additionalNotes,
}); customInputs,
},
eventNameObject
);
} }
} }
} }