diff --git a/server.js b/server.js index 1e6a4ce..ebb8c01 100644 --- a/server.js +++ b/server.js @@ -145,6 +145,29 @@ app.get('/calendar/:name', async (req, res) => { const results = await Promise.all(promises); // Filter out any failed requests const validResults = results.filter((result) => result !== null); + + // Parse calendar data + const mergedCal = []; + validResults.forEach((result) => { + const calendar = ical.parseICS(result.data); + Object.keys(calendar).forEach((key) => { + const event = calendar[key]; + 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}`, + }); + } + }); + }); + } } } catch (error) {