parse calendar data
This commit is contained in:
parent
9b297aa0fd
commit
3438ae9396
16
server.js
16
server.js
|
@ -116,6 +116,22 @@ async function updateMergedCalendar(){
|
||||||
const results = await Promise.all(promises);
|
const results = await Promise.all(promises);
|
||||||
// Filter out any failed requests
|
// Filter out any failed requests
|
||||||
const validResults = results.filter((result) => result !== null);
|
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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue