diff --git a/lib/CalEventParser.ts b/lib/CalEventParser.ts index 69724ccc8f..7829280453 100644 --- a/lib/CalEventParser.ts +++ b/lib/CalEventParser.ts @@ -6,10 +6,12 @@ import { stripHtml } from "./emails/helpers"; const translator = short(); export default class CalEventParser { - calEvent: CalendarEvent; + protected calEvent: CalendarEvent; + protected maybeUid: string; - constructor(calEvent: CalendarEvent) { + constructor(calEvent: CalendarEvent, maybeUid: string = null) { this.calEvent = calEvent; + this.maybeUid = maybeUid; } /** @@ -30,7 +32,7 @@ export default class CalEventParser { * Returns a unique identifier for the given calendar event. */ public getUid(): string { - return translator.fromUUID(uuidv5(JSON.stringify(this.calEvent), uuidv5.URL)); + return this.maybeUid ?? translator.fromUUID(uuidv5(JSON.stringify(this.calEvent), uuidv5.URL)); } /** diff --git a/lib/calendarClient.ts b/lib/calendarClient.ts index 6d59ff7adc..7102a535bd 100644 --- a/lib/calendarClient.ts +++ b/lib/calendarClient.ts @@ -515,8 +515,8 @@ const createEvent = async ( noMail = false, maybeUid: string = null ): Promise => { - const parser: CalEventParser = new CalEventParser(calEvent); - const uid: string = maybeUid ?? parser.getUid(); + const parser: CalEventParser = new CalEventParser(calEvent, maybeUid); + const uid: string = parser.getUid(); const richEvent: CalendarEvent = parser.asRichEvent(); let success = true; diff --git a/lib/emails/EventMail.ts b/lib/emails/EventMail.ts index 1c9253fc27..b3728872e6 100644 --- a/lib/emails/EventMail.ts +++ b/lib/emails/EventMail.ts @@ -39,7 +39,7 @@ export default abstract class EventMail { constructor(calEvent: CalendarEvent, uid: string, additionInformation: AdditionInformation = null) { this.calEvent = calEvent; this.uid = uid; - this.parser = new CalEventParser(calEvent); + this.parser = new CalEventParser(calEvent, uid); this.additionInformation = additionInformation; } diff --git a/lib/videoClient.ts b/lib/videoClient.ts index 1f4e3d3d20..755c0cda20 100644 --- a/lib/videoClient.ts +++ b/lib/videoClient.ts @@ -10,6 +10,7 @@ import { EventResult } from "@lib/events/EventManager"; import logger from "@lib/logger"; import { AdditionInformation, EntryPoint } from "@lib/emails/EventMail"; import { getIntegrationName } from "@lib/emails/helpers"; +import CalEventParser from "@lib/CalEventParser"; const log = logger.getChildLogger({ prefix: ["[lib] videoClient"] }); @@ -206,7 +207,8 @@ const createMeeting = async ( calEvent: CalendarEvent, maybeUid: string = null ): Promise => { - const uid: string = maybeUid ?? translator.fromUUID(uuidv5(JSON.stringify(calEvent), uuidv5.URL)); + const parser: CalEventParser = new CalEventParser(calEvent, maybeUid); + const uid: string = parser.getUid(); if (!credential) { throw new Error(