From a34f94df692ca7907a03cc427eb77d5e1ee07f0f Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 19 Oct 2021 13:47:02 +0200 Subject: Get VTIMEZONE data from a time zone database lib Signed-off-by: Christoph Wurst --- apps/dav/src/service/CalendarService.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'apps/dav/src') 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') -- cgit v1.2.3