From 58dfa9d4a790fae862eda543435f07e142e5de22 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 8 Aug 2023 19:17:35 +0600 Subject: [PATCH] calendar_hot_fixes (#3571) Signed-off-by: Denis Bykhov --- plugins/calendar/src/utils.ts | 6 +++--- server-plugins/calendar-resources/src/index.ts | 17 +++-------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/plugins/calendar/src/utils.ts b/plugins/calendar/src/utils.ts index d553fcd3c6..2f5dbfb24c 100644 --- a/plugins/calendar/src/utils.ts +++ b/plugins/calendar/src/utils.ts @@ -227,21 +227,21 @@ function getReccuringEventInstances ( to: Timestamp ): ReccuringInstance[] { let res: ReccuringInstance[] = [] - for (const rule of event.rules) { + for (const rule of event.rules ?? []) { const values = generateRecurringValues(rule, event.date, from, to) for (const val of values) { const instance = getInstance(event, val) res.push(instance) } } - for (const date of event.rdate) { + for (const date of event.rdate ?? []) { if (date < from || date > to) continue const instance = getInstance(event, date) const exists = res.find((p) => p.date === instance.date) if (exists === undefined) res.push(instance) } - const excludes = new Set(event.exdate) + const excludes = new Set(event.exdate ?? []) res = res.filter((p) => !excludes.has(p.date)) res = res.filter((i) => { const override = instances.find((p) => p.originalStartTime === i.date) diff --git a/server-plugins/calendar-resources/src/index.ts b/server-plugins/calendar-resources/src/index.ts index 41cd350796..c1beeb9cea 100644 --- a/server-plugins/calendar-resources/src/index.ts +++ b/server-plugins/calendar-resources/src/index.ts @@ -113,20 +113,9 @@ async function onEventCreate (tx: Tx, control: TriggerControl): Promise { (p) => (p._id !== ev.createdBy ?? ev.modifiedBy) && ev.participants.includes(p.person) ) for (const acc of participants) { - const innerTx = control.txFactory.createTxCreateDoc(ev._class, `${acc._id}_calendar` as Ref, { - eventId: ev.eventId, - participants: ev.participants, - externalParticipants: ev.externalParticipants, - title: ev.title, - description: ev.description, - allDay: ev.allDay, - attachedTo: ev.attachedTo, - attachedToClass: ev.attachedToClass, - collection: ev.collection, - date: ev.date, - dueDate: ev.dueDate, - reminders: ev.reminders, - location: ev.location, + const { _id, _class, space, modifiedBy, modifiedOn, ...data } = ev + const innerTx = control.txFactory.createTxCreateDoc(_class, `${acc._id}_calendar` as Ref, { + ...data, access: 'reader' }) res.push(