node-ical-toolkit icon indicating copy to clipboard operation
node-ical-toolkit copied to clipboard

Ignores multiple VFREEBUSY while parsing calendar response

Open dharanikumarp opened this issue 9 years ago • 3 comments

When there are more than one VFREEBUSY elements in the icalendar response, the JSON parser ignores the second VFREEBUSY entry in the calendar data

for example if the response from the caldav server is BEGIN:VCALENDAR PRODID:-//davical.org//NONSGML AWL Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VFREEBUSY DTSTAMP:20160103T041750Z DTSTART:20151227T000000Z DTEND:20160207T000000Z FREEBUSY:20160102T170000Z/20160102T210000Z FREEBUSY;FBTYPE=BUSY-TENTATIVE:20160103T113000Z/20160103T150000Z FREEBUSY:20160104T120000Z/20160104T160000Z FREEBUSY:20160104T190000Z/20160104T230000Z END:VFREEBUSY END:VCALENDAR

which has four FREEBUSY entries (with one FREEBUSY_TENTATIVE), the json conversion ignores the second and third VFREEBUSY entries. Here is the JSON response

{"VCALENDAR":[{"PRODID":"-//davical.org//NONSGML AWL Calendar//EN","VERSION":"2.0","CALSCALE":"GREGORIAN","VFREEBUSY":[{"DTSTAMP":"20160103T041750Z","DTSTART":"20151227T000000Z","DTEND":"20160207T000000Z","FREEBUSY":"20160104T190000Z/20160104T230000Z","FREEBUSY;FBTYPE=BUSY-TENTATIVE":"20160103T113000Z/20160103T150000Z"}]}]}

Looks like the first and last FREEBUSY entries are skipped in the json response.

dharanikumarp avatar Jan 03 '16 06:01 dharanikumarp

Hey, thanks for pointing out. So the issue is when we have multiple fields of same key, actually it is a map and other parse results are ignored, so eventually what could be done is that if we get multiple fields of same name then we can make it as an array of values? thoughts?

kushal-likhi avatar Jan 05 '16 08:01 kushal-likhi

Yes array of values would be the right choice particularly for the VFREEBUSY type, as the data will have multiple entries of busy periods. So have a key with VFREEBUSY and values will be a array of pairs containing start and end values.

Like VFREEBUSY: [{start:'', end:''}, {start:'', end: ''}];

This is just a suggestion, you can choose the most appropriate data type.

dharanikumarp avatar Jan 06 '16 19:01 dharanikumarp

There is one more special type VFREEBUSY:TENTATIVE in case the user has not accepted the request or user's request has not been accepted by the attendee (participant). So this could be another key with similar structure.

Like VFREEBUSYTENTATIVE: [{}, {}]

Thanks,

dharanikumarp avatar Jan 06 '16 19:01 dharanikumarp