summaryrefslogtreecommitdiffstats
path: root/apps/dav/src
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-10-19 11:53:43 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-10-25 11:08:37 +0200
commit9b6238aabd5491c7e564e36d3e0b423d5a659847 (patch)
tree1f47c23b3a03c356e0de540b6f566e73968d5d94 /apps/dav/src
parentd231d2618de78b87cbc3916109652f0432fee607 (diff)
downloadnextcloud-server-9b6238aabd5491c7e564e36d3e0b423d5a659847.tar.gz
nextcloud-server-9b6238aabd5491c7e564e36d3e0b423d5a659847.zip
Read and write time zone ID when updating CalDAV availability
Tiny bug/limitation of #27466 Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/src')
-rw-r--r--apps/dav/src/service/CalendarService.js19
-rw-r--r--apps/dav/src/views/Availability.vue5
2 files changed, 20 insertions, 4 deletions
diff --git a/apps/dav/src/service/CalendarService.js b/apps/dav/src/service/CalendarService.js
index c187d61b86e..c530d0f10a7 100644
--- a/apps/dav/src/service/CalendarService.js
+++ b/apps/dav/src/service/CalendarService.js
@@ -64,8 +64,14 @@ export async function findScheduleInboxAvailability() {
const vcalendarComp = new ICAL.Component(parsedIcal)
const vavailabilityComp = vcalendarComp.getFirstSubcomponent('vavailability')
- const availableComps = vavailabilityComp.getAllSubcomponents('available')
+ let timezoneId
+ const timezoneComp = vcalendarComp.getFirstSubcomponent('vtimezone')
+ if (timezoneComp) {
+ timezoneId = timezoneComp.getFirstProperty('tzid').getFirstValue()
+ }
+
+ const availableComps = vavailabilityComp.getAllSubcomponents('available')
// Combine all AVAILABLE blocks into a week of slots
const slots = getEmptySlots()
availableComps.forEach((availableComp) => {
@@ -90,6 +96,7 @@ export async function findScheduleInboxAvailability() {
return {
slots,
+ timezoneId,
}
}
@@ -99,6 +106,14 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
day: dayId,
})))]
+ const vcalendarComp = new ICAL.Component('vcalendar')
+
+ // Store time zone info
+ const timezoneComp = new ICAL.Component('vtimezone')
+ timezoneComp.addPropertyWithValue('tzid', timezoneId)
+ vcalendarComp.addSubcomponent(timezoneComp)
+
+ // Store availability info
const vavailabilityComp = new ICAL.Component('vavailability')
// Deduplicate by start and end time
@@ -127,7 +142,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
const availableComp = new ICAL.Component('available')
// Define DTSTART and DTEND
- // TODO: tz? moment.tz(dateTime, timezone).toDate()
const startTimeProp = availableComp.addPropertyWithValue('dtstart', ICAL.Time.fromJSDate(start, false))
startTimeProp.setParameter('tzid', timezoneId)
const endTimeProp = availableComp.addPropertyWithValue('dtend', ICAL.Time.fromJSDate(end, false))
@@ -147,7 +161,6 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
return availableComp
}).map(vavailabilityComp.addSubcomponent.bind(vavailabilityComp))
- const vcalendarComp = new ICAL.Component('vcalendar')
vcalendarComp.addSubcomponent(vavailabilityComp)
logger.debug('New availability ical created', {
asObject: vcalendarComp,
diff --git a/apps/dav/src/views/Availability.vue b/apps/dav/src/views/Availability.vue
index 03f646028a8..c2f9cf6151c 100644
--- a/apps/dav/src/views/Availability.vue
+++ b/apps/dav/src/views/Availability.vue
@@ -121,12 +121,15 @@ export default {
},
async mounted() {
try {
- const { slots } = await findScheduleInboxAvailability()
+ const { slots, timezoneId } = await findScheduleInboxAvailability()
if (slots) {
this.daysOfTheWeek.forEach(day => {
day.slots.push(...slots[day.id])
})
}
+ if (timezoneId) {
+ this.timezone = timezoneId
+ }
console.info('availability loaded', this.daysOfTheWeek)
} catch (e) {
console.error('could not load existing availability', e)