Fix availability free-busy data pull, location change and status in CALDAV | new branch (attempt#2)#3958
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
alishaz-polymath
left a comment
There was a problem hiding this comment.
Added Self review
| if (object.data == null) return; | ||
|
|
||
| const jcalData = ICAL.parse(object.data); | ||
| const jcalData = ICAL.parse(sanitizeCalendarObject(object)); |
There was a problem hiding this comment.
Depending on the CalDAV service provider, the object.data may or may not have \r or \r\n as the EOL. ICAL.parse expects it to have '\r\n' to work as expected. Also, the object.data received from the fetchCalendarObjects function is at times faulty in placing the EOL, which is why we need to make sure that it doesn't break the structure of expected input for ICAL.parse, hence the need for sanitization.
| const vevent = vcalendar.getFirstSubcomponent("vevent"); | ||
|
|
||
| // if event status is free or transparent, return | ||
| if (vevent?.getFirstPropertyValue("transp") === "TRANSPARENT") return; |
There was a problem hiding this comment.
If an event is added as a Free event, meaning we should allow booking over it, this is how we identify the free state and ignore any further processing
| .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, "="); |
There was a problem hiding this comment.
We make sure the ICAL.parse works with the output of this return. Currently, this seems to be fixing all potential invalid breakpoints but this can be revisited and improved if there are other edge cases we might have missed here.
| .replaceAll("\r\n", "\r") | ||
| .replaceAll("\r", "\r\n") |
There was a problem hiding this comment.
The reason we're going from \r\n to \r and then back from \r to \r\n here is because some of the CalDAV services return the EOL as \r while others as \r\n and the ICAL.parse expects it to have \r\n as EOL, so this just ensures all the returned Calendar objects have \r\n as EOL.
There was a problem hiding this comment.
Just a nitpick replaceAll is not supported on browsers. And it is generally deprecated.
What does this PR do?
ICALstringreturned in the calendar objects by TSDAV'sfetchCalendarObjectsand the expected input fromICAL.parse()Fixes #3589 #2988 #2236 #1588
Environment: Staging(main branch)
Type of change