From d95dc5bbf7cbd7e49772a827257f3fc17154e3b4 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:44:22 -0500 Subject: [PATCH] fix: fixed XML response for sync --- routes/calendar/calendar/get.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/routes/calendar/calendar/get.js b/routes/calendar/calendar/get.js index 46d67e5..7046e55 100644 --- a/routes/calendar/calendar/get.js +++ b/routes/calendar/calendar/get.js @@ -1,5 +1,6 @@ const { setMissingMethod } = require('../../../common/response'); const winston = require('../../../common/winston'); +const { response, status } = require('../../../common/x-build'); module.exports = function (options) { const log = winston({ ...options, label: 'calendar/get' }); @@ -13,7 +14,16 @@ module.exports = function (options) { fullData: true }); - return options.data.buildICS(ctx, events, calendar); + // return options.data.buildICS(ctx, events, calendar); + const ics = await options.data.buildICS(ctx, events, calendar); + return response(ctx.url, status[200], [ + { + 'D:getetag': options.data.getETag(ctx, calendar) + }, + { + 'CAL:calendar-data': ics + } + ]); } const event = await options.data.getEvent(ctx, { @@ -29,7 +39,18 @@ module.exports = function (options) { return; } - return options.data.buildICS(ctx, event, calendar); + // return options.data.buildICS(ctx, event, calendar); + const ics = await options.data.buildICS(ctx, event, calendar); + return response(ctx.url, status[200], [ + { + // TODO: should E-Tag here be of calendar or event? + // 'D:getetag': options.data.getETag(ctx, calendar) + 'D:getetag': options.data.getETag(ctx, calendar) + }, + { + 'CAL:calendar-data': ics + } + ]); }; return {