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 3db30b1 commit 3938bce
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions routes/calendar/calendar/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ module.exports = function (options) {
fullData: true
});

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
}
]);
}
if (ctx.accepts('text/calendar'))
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, {
Expand All @@ -42,21 +41,20 @@ module.exports = function (options) {
return;
}

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);
if (ctx.accepts('text/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 {
Expand Down

0 comments on commit 3938bce

Please sign in to comment.