Fix availability free-busy data pull, location change and status in CALDAV | new branch (attempt#2) (#3958)
parent
1b541ff214
commit
7f94ce0605
|
@ -17,6 +17,7 @@ import {
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
|
import sanitizeCalendarObject from "@calcom/lib/sanitizeCalendarObject";
|
||||||
import type {
|
import type {
|
||||||
Calendar,
|
Calendar,
|
||||||
CalendarEvent,
|
CalendarEvent,
|
||||||
|
@ -177,7 +178,6 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventsToUpdate = events.filter((e) => e.uid === uid);
|
const eventsToUpdate = events.filter((e) => e.uid === uid);
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
eventsToUpdate.map((e) => {
|
eventsToUpdate.map((e) => {
|
||||||
return updateCalendarObject({
|
return updateCalendarObject({
|
||||||
|
@ -251,9 +251,13 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
objects.forEach((object) => {
|
objects.forEach((object) => {
|
||||||
if (object.data == null) return;
|
if (object.data == null) return;
|
||||||
|
|
||||||
const jcalData = ICAL.parse(object.data);
|
const jcalData = ICAL.parse(sanitizeCalendarObject(object));
|
||||||
const vcalendar = new ICAL.Component(jcalData);
|
const vcalendar = new ICAL.Component(jcalData);
|
||||||
const vevent = vcalendar.getFirstSubcomponent("vevent");
|
const vevent = vcalendar.getFirstSubcomponent("vevent");
|
||||||
|
|
||||||
|
// if event status is free or transparent, return
|
||||||
|
if (vevent?.getFirstPropertyValue("transp") === "TRANSPARENT") return;
|
||||||
|
|
||||||
const event = new ICAL.Event(vevent);
|
const event = new ICAL.Event(vevent);
|
||||||
const vtimezone = vcalendar.getFirstSubcomponent("vtimezone");
|
const vtimezone = vcalendar.getFirstSubcomponent("vtimezone");
|
||||||
|
|
||||||
|
@ -266,7 +270,6 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
|
|
||||||
const start = dayjs(dateFrom);
|
const start = dayjs(dateFrom);
|
||||||
const end = dayjs(dateTo);
|
const end = dayjs(dateTo);
|
||||||
|
|
||||||
const iterator = event.iterator();
|
const iterator = event.iterator();
|
||||||
let current;
|
let current;
|
||||||
let currentEvent;
|
let currentEvent;
|
||||||
|
@ -379,7 +382,7 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
const events = objects
|
const events = objects
|
||||||
.filter((e) => !!e.data)
|
.filter((e) => !!e.data)
|
||||||
.map((object) => {
|
.map((object) => {
|
||||||
const jcalData = ICAL.parse(object.data);
|
const jcalData = ICAL.parse(sanitizeCalendarObject(object));
|
||||||
|
|
||||||
const vcalendar = new ICAL.Component(jcalData);
|
const vcalendar = new ICAL.Component(jcalData);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { DAVObject } from "tsdav";
|
||||||
|
|
||||||
|
export const sanitizeCalendarObject = (obj: DAVObject) => {
|
||||||
|
return obj.data
|
||||||
|
.replaceAll("\r\n", "\r")
|
||||||
|
.replaceAll("\r", "\r\n")
|
||||||
|
.replaceAll(/(: \r\n|:\r\n|\r\n:|\r\n :)/gm, ":")
|
||||||
|
.replaceAll(/(; \r\n|;\r\n|\r\n;|\r\n ;)/gm, ";")
|
||||||
|
.replaceAll(/(= \r\n|=\r\n|\r\n=|\r\n =)/gm, "=");
|
||||||
|
};
|
||||||
|
|
||||||
|
export default sanitizeCalendarObject;
|
Loading…
Reference in New Issue