diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-10-19 14:47:02 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-10-25 16:56:46 +0300 |
commit | a34f94df692ca7907a03cc427eb77d5e1ee07f0f (patch) | |
tree | f76e114e79ba5e9194dd2392c818c8540779d29c /apps/dav/src | |
parent | 9b6238aabd5491c7e564e36d3e0b423d5a659847 (diff) |
Get VTIMEZONE data from a time zone database lib
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/src')
-rw-r--r-- | apps/dav/src/service/CalendarService.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/dav/src/service/CalendarService.js b/apps/dav/src/service/CalendarService.js index c530d0f10a7..caac6874907 100644 --- a/apps/dav/src/service/CalendarService.js +++ b/apps/dav/src/service/CalendarService.js @@ -22,6 +22,7 @@ import { getClient } from '../dav/client' import ICAL from 'ical.js' import logger from './logger' import { parseXML } from 'webdav/dist/node/tools/dav' +import { getZoneString } from 'icalzone' import { v4 as uuidv4 } from 'uuid' export function getEmptySlots() { @@ -107,11 +108,20 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) { })))] const vcalendarComp = new ICAL.Component('vcalendar') + vcalendarComp.addPropertyWithValue('prodid', 'Nextcloud DAV app') // Store time zone info - const timezoneComp = new ICAL.Component('vtimezone') - timezoneComp.addPropertyWithValue('tzid', timezoneId) - vcalendarComp.addSubcomponent(timezoneComp) + // If possible we use the info from a time zone database + const predefinedTimezoneIcal = getZoneString(timezoneId) + if (predefinedTimezoneIcal) { + const timezoneComp = new ICAL.Component(ICAL.parse(predefinedTimezoneIcal)) + vcalendarComp.addSubcomponent(timezoneComp) + } else { + // Fall back to a simple markup + const timezoneComp = new ICAL.Component('vtimezone') + timezoneComp.addPropertyWithValue('tzid', timezoneId) + vcalendarComp.addSubcomponent(timezoneComp) + } // Store availability info const vavailabilityComp = new ICAL.Component('vavailability') |