import {createEvent} from "ics"; import dayjs, {Dayjs} from "dayjs"; import EventMail from "./EventMail"; export default class EventOrganizerMail extends EventMail { /** * Returns the instance's event as an iCal event in string representation. * @protected */ protected getiCalEventAsString(): string { const icsEvent = createEvent({ start: dayjs(this.calEvent.startTime).utc().toArray().slice(0, 6), startInputType: 'utc', productId: 'calendso/ics', title: `${this.calEvent.type} with ${this.calEvent.attendees[0].name}`, description: this.calEvent.description + this.stripHtml(this.getAdditionalBody()) + this.stripHtml(this.getAdditionalFooter()), duration: {minutes: dayjs(this.calEvent.endTime).diff(dayjs(this.calEvent.startTime), 'minute')}, organizer: {name: this.calEvent.organizer.name, email: this.calEvent.organizer.email}, attendees: this.calEvent.attendees.map((attendee: any) => ({name: attendee.name, email: attendee.email})), status: "CONFIRMED", }); if (icsEvent.error) { throw icsEvent.error; } return icsEvent.value; } /** * Returns the email text as HTML representation. * * @protected */ protected getHtmlRepresentation(): string { return `