Added maybeUid to CalEventParser

pull/375/head
nicolas 2021-07-25 19:15:31 +02:00
parent 65fd733751
commit 2b38638d84
4 changed files with 11 additions and 7 deletions

View File

@ -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));
}
/**

View File

@ -515,8 +515,8 @@ const createEvent = async (
noMail = false,
maybeUid: string = null
): Promise<EventResult> => {
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;

View File

@ -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;
}

View File

@ -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<EventResult> => {
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(