Extracted utils to own files for better readability Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Calendar } from "../Calendars/CalendarTypes";
|
||||
import { VObjectProperty } from "../Calendars/types/CalendarData";
|
||||
import { userAttendee } from "../User/models/attendee";
|
||||
import { userOrganiser } from "../User/userDataTypes";
|
||||
|
||||
@@ -27,6 +28,7 @@ export interface CalendarEvent {
|
||||
repetition?: RepetitionObject;
|
||||
alarm?: AlarmObject;
|
||||
exdates?: string[];
|
||||
passthroughProps?: VObjectProperty[];
|
||||
}
|
||||
|
||||
export interface RepetitionObject {
|
||||
|
||||
@@ -121,5 +121,16 @@ export function makeVevent(
|
||||
});
|
||||
}
|
||||
|
||||
if (event.passthroughProps?.length) {
|
||||
const existingKeys = new Set(
|
||||
(vevent[1] as unknown[]).map((p) => (p as [string])[0].toLowerCase())
|
||||
);
|
||||
for (const prop of event.passthroughProps) {
|
||||
if (!existingKeys.has(prop[0].toLowerCase())) {
|
||||
vevent[1].push(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vevent;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,30 @@ import {
|
||||
import { userAttendee } from "../../User/models/attendee";
|
||||
import { createAttendee } from "../../User/models/attendee.mapper";
|
||||
import { AlarmObject, CalendarEvent } from "../EventsTypes";
|
||||
import { inferTimezoneFromValue } from "./inferTimezoneFromValue";
|
||||
import { buildDelegatedEventURL } from "./buildDelegatedEventURL";
|
||||
import { formatDateToICal } from "./formatDateToICal";
|
||||
import { inferTimezoneFromValue } from "./inferTimezoneFromValue";
|
||||
|
||||
const KNOWN_PROPS = new Set([
|
||||
"uid",
|
||||
"transp",
|
||||
"dtstart",
|
||||
"dtend",
|
||||
"class",
|
||||
"x-openpaas-videoconference",
|
||||
"summary",
|
||||
"description",
|
||||
"location",
|
||||
"organizer",
|
||||
"attendee",
|
||||
"dtstamp",
|
||||
"sequence",
|
||||
"recurrence-id",
|
||||
"exdate",
|
||||
"status",
|
||||
"duration",
|
||||
"rrule",
|
||||
]);
|
||||
|
||||
export function parseCalendarEvent(
|
||||
data: VObjectProperty[],
|
||||
@@ -211,6 +232,9 @@ export function parseCalendarEvent(
|
||||
event.end = endISO;
|
||||
}
|
||||
}
|
||||
event.passthroughProps = data.filter(
|
||||
([key]) => !KNOWN_PROPS.has(key.toLowerCase())
|
||||
);
|
||||
|
||||
return event as CalendarEvent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user