From c709f9ed1bc8621f3874867aa0f8b63eb373da4e Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Thu, 3 Feb 2022 17:59:41 +0530 Subject: [PATCH] fixed attendee language per attendee (#1694) Co-authored-by: Peer Richelsen --- .../attendee-awaiting-payment-email.ts | 22 ++++++++-------- .../templates/attendee-cancelled-email.ts | 22 ++++++++-------- .../templates/attendee-declined-email.ts | 20 +++++++------- .../templates/attendee-rescheduled-email.ts | 26 +++++++++---------- .../templates/attendee-scheduled-email.ts | 4 +-- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/emails/templates/attendee-awaiting-payment-email.ts b/lib/emails/templates/attendee-awaiting-payment-email.ts index 7455ecfd..9cf8823e 100644 --- a/lib/emails/templates/attendee-awaiting-payment-email.ts +++ b/lib/emails/templates/attendee-awaiting-payment-email.ts @@ -25,14 +25,14 @@ export default class AttendeeAwaitingPaymentEmail extends AttendeeScheduledEmail to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, - subject: `${this.calEvent.attendees[0].language.translate("awaiting_payment_subject", { + subject: `${this.attendee.language.translate("awaiting_payment_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, @@ -43,8 +43,8 @@ export default class AttendeeAwaitingPaymentEmail extends AttendeeScheduledEmail protected getTextBody(): string { return ` -${this.calEvent.attendees[0].language.translate("meeting_awaiting_payment")} -${this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees")} +${this.attendee.language.translate("meeting_awaiting_payment")} +${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} @@ -53,14 +53,14 @@ ${this.getAdditionalNotes()} } protected getHtmlBody(): string { - const headerContent = this.calEvent.attendees[0].language.translate("awaiting_payment_subject", { + const headerContent = this.attendee.language.translate("awaiting_payment_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); @@ -73,8 +73,8 @@ ${this.getAdditionalNotes()}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( - this.calEvent.attendees[0].language.translate("meeting_awaiting_payment"), - this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees") + this.attendee.language.translate("meeting_awaiting_payment"), + this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()} @@ -148,7 +148,7 @@ ${this.getAdditionalNotes()} } protected getManageLink(): string { - const manageText = this.calEvent.attendees[0].language.translate("pay_now"); + const manageText = this.attendee.language.translate("pay_now"); if (this.calEvent.paymentInfo) { return ` diff --git a/lib/emails/templates/attendee-cancelled-email.ts b/lib/emails/templates/attendee-cancelled-email.ts index 25762e24..477ec5e4 100644 --- a/lib/emails/templates/attendee-cancelled-email.ts +++ b/lib/emails/templates/attendee-cancelled-email.ts @@ -24,14 +24,14 @@ export default class AttendeeCancelledEmail extends AttendeeScheduledEmail { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, - subject: `${this.calEvent.attendees[0].language.translate("event_cancelled_subject", { + subject: `${this.attendee.language.translate("event_cancelled_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, @@ -42,8 +42,8 @@ export default class AttendeeCancelledEmail extends AttendeeScheduledEmail { protected getTextBody(): string { return ` -${this.calEvent.attendees[0].language.translate("event_request_cancelled")} -${this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees")} +${this.attendee.language.translate("event_request_cancelled")} +${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} @@ -53,14 +53,14 @@ ${this.calEvent.cancellationReason && this.getCancellationReason()} } protected getHtmlBody(): string { - const headerContent = this.calEvent.attendees[0].language.translate("event_cancelled_subject", { + const headerContent = this.attendee.language.translate("event_cancelled_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); @@ -74,8 +74,8 @@ ${this.calEvent.cancellationReason && this.getCancellationReason()}
${emailSchedulingBodyHeader("xCircle")} ${emailScheduledBodyHeaderContent( - this.calEvent.attendees[0].language.translate("event_request_cancelled"), - this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees") + this.attendee.language.translate("event_request_cancelled"), + this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()} @@ -133,7 +133,7 @@ ${this.calEvent.cancellationReason && this.getCancellationReason()} return `

-

${this.calEvent.attendees[0].language.translate("cancellation_reason")}

+

${this.attendee.language.translate("cancellation_reason")}

${this.calEvent.cancellationReason}

`; } diff --git a/lib/emails/templates/attendee-declined-email.ts b/lib/emails/templates/attendee-declined-email.ts index 32c920e6..1665e50b 100644 --- a/lib/emails/templates/attendee-declined-email.ts +++ b/lib/emails/templates/attendee-declined-email.ts @@ -24,14 +24,14 @@ export default class AttendeeDeclinedEmail extends AttendeeScheduledEmail { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, - subject: `${this.calEvent.attendees[0].language.translate("event_declined_subject", { + subject: `${this.attendee.language.translate("event_declined_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, @@ -42,8 +42,8 @@ export default class AttendeeDeclinedEmail extends AttendeeScheduledEmail { protected getTextBody(): string { return ` -${this.calEvent.attendees[0].language.translate("event_request_declined")} -${this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees")} +${this.attendee.language.translate("event_request_declined")} +${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} @@ -52,14 +52,14 @@ ${this.getAdditionalNotes()} } protected getHtmlBody(): string { - const headerContent = this.calEvent.attendees[0].language.translate("event_declined_subject", { + const headerContent = this.attendee.language.translate("event_declined_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); @@ -73,8 +73,8 @@ ${this.getAdditionalNotes()}
${emailSchedulingBodyHeader("xCircle")} ${emailScheduledBodyHeaderContent( - this.calEvent.attendees[0].language.translate("event_request_declined"), - this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees") + this.attendee.language.translate("event_request_declined"), + this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()} diff --git a/lib/emails/templates/attendee-rescheduled-email.ts b/lib/emails/templates/attendee-rescheduled-email.ts index bf5e7d54..cd50e058 100644 --- a/lib/emails/templates/attendee-rescheduled-email.ts +++ b/lib/emails/templates/attendee-rescheduled-email.ts @@ -30,14 +30,14 @@ export default class AttendeeRescheduledEmail extends AttendeeScheduledEmail { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, - subject: `${this.calEvent.attendees[0].language.translate("rescheduled_event_type_subject", { + subject: `${this.attendee.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, @@ -51,20 +51,20 @@ export default class AttendeeRescheduledEmail extends AttendeeScheduledEmail { // Guests cannot if (this.attendee === this.calEvent.attendees[0]) { return ` - ${this.calEvent.attendees[0].language.translate("event_has_been_rescheduled")} - ${this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees")} + ${this.attendee.language.translate("event_has_been_rescheduled")} + ${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getAdditionalNotes()} - ${this.calEvent.attendees[0].language.translate("need_to_reschedule_or_cancel")} + ${this.attendee.language.translate("need_to_reschedule_or_cancel")} ${getCancelLink(this.calEvent)} `.replace(/(<([^>]+)>)/gi, ""); } return ` -${this.calEvent.attendees[0].language.translate("event_has_been_rescheduled")} -${this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees")} +${this.attendee.language.translate("event_has_been_rescheduled")} +${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} @@ -73,14 +73,14 @@ ${this.getAdditionalNotes()} } protected getHtmlBody(): string { - const headerContent = this.calEvent.attendees[0].language.translate("rescheduled_event_type_subject", { + const headerContent = this.attendee.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() - )}, ${this.calEvent.attendees[0].language.translate( + )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); @@ -93,8 +93,8 @@ ${this.getAdditionalNotes()}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( - this.calEvent.attendees[0].language.translate("event_has_been_rescheduled"), - this.calEvent.attendees[0].language.translate("emailed_you_and_any_other_attendees") + this.attendee.language.translate("event_has_been_rescheduled"), + this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()} diff --git a/lib/emails/templates/attendee-scheduled-email.ts b/lib/emails/templates/attendee-scheduled-email.ts index 2ce4a0a0..494ed452 100644 --- a/lib/emails/templates/attendee-scheduled-email.ts +++ b/lib/emails/templates/attendee-scheduled-email.ts @@ -3,13 +3,13 @@ import localizedFormat from "dayjs/plugin/localizedFormat"; import timezone from "dayjs/plugin/timezone"; import toArray from "dayjs/plugin/toArray"; import utc from "dayjs/plugin/utc"; -import { createEvent, DateArray, Person } from "ics"; +import { createEvent, DateArray } from "ics"; import nodemailer from "nodemailer"; import { getCancelLink, getRichDescription } from "@lib/CalEventParser"; import { getErrorFromUnknown } from "@lib/errors"; import { getIntegrationName } from "@lib/integrations"; -import { CalendarEvent } from "@lib/integrations/calendar/interfaces/Calendar"; +import { CalendarEvent, Person } from "@lib/integrations/calendar/interfaces/Calendar"; import { serverConfig } from "@lib/serverConfig"; import {