From 3438ae9396d7443ada998a5c0d54e8662932e2aa Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 3 Oct 2024 01:10:27 +0300 Subject: [PATCH] parse calendar data --- server.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server.js b/server.js index 9cab04e..6f59640 100644 --- a/server.js +++ b/server.js @@ -116,6 +116,22 @@ async function updateMergedCalendar(){ 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]; + mergedCal.push({ + start: event.start, + end: event.end, + summary: `${result.prefix} ${event.summary}`, + }); + }); + }); + + } catch (error) { console.error(error); }