Skip to content

Commit

Permalink
fix: conditional XML or ICS response
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jul 18, 2024
1 parent 2078c6b commit f4e55c6
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions routes/calendar/calendar/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ module.exports = function (options) {
fullData: true
});

// 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
}
]);
if (ctx.accepts('xml')) {
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
}
]);
}

return options.data.buildICS(ctx, events, calendar);
}

const event = await options.data.getEvent(ctx, {
Expand All @@ -39,18 +42,21 @@ module.exports = function (options) {
return;
}

// 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
}
]);
if (ctx.accepts('xml')) {
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 options.data.buildICS(ctx, event, calendar);
};

return {
Expand Down

0 comments on commit f4e55c6

Please sign in to comment.