From df9276c8a9a333bc148c972ef9d61e8e5557369a Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Fri, 4 Oct 2024 16:08:39 +0300 Subject: [PATCH] include overide feature in post request --- server.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 8d85381..647de56 100644 --- a/server.js +++ b/server.js @@ -28,6 +28,7 @@ app.post('/merge', async (req, res) => { return { data: response.data, prefix: calendar.prefix, + override: calendar.override, }; }) .catch((error) => { @@ -46,11 +47,19 @@ app.post('/merge', async (req, res) => { const calendar = ical.parseICS(result.data); Object.keys(calendar).forEach((key) => { const event = calendar[key]; - mergedCal.push({ - start: event.start, - end: event.end, - summary: `${result.prefix} ${event.summary}`, - }); + if (result.override) { + mergedCal.push({ + start: event.start, + end: event.end, + summary: result.prefix, + }); + } else { + mergedCal.push({ + start: event.start, + end: event.end, + summary: `${result.prefix} ${event.summary}`, + }); + } }); }); @@ -61,10 +70,10 @@ app.post('/merge', async (req, res) => { VERSION:2.0 CALSCALE:GREGORIAN METHOD:PUBLISH -BEGIN:VEVENT `; mergedCal.forEach((event) => { - icalString += `DTSTART:${event.start} + icalString += `BEGIN:VEVENT +DTSTART:${event.start} DTEND:${event.end} SUMMARY:${event.summary} END:VEVENT