forked from ryanmwangi/CalMerger
parse calendar data
This commit is contained in:
parent
fa2dd50beb
commit
6441714568
13
server.js
13
server.js
|
@ -41,9 +41,18 @@ app.post('/merge', async (req, res) => {
|
||||||
const validResults = results.filter((result) => result !== null);
|
const validResults = results.filter((result) => result !== null);
|
||||||
|
|
||||||
// Parse calendar data
|
// Parse calendar data
|
||||||
const cal1 = ical.parseICS(cal1Data.data);
|
|
||||||
const cal2 = ical.parseICS(cal2Data.data);
|
|
||||||
const mergedCal = [];
|
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}`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Merge calendars
|
// Merge calendars
|
||||||
Object.keys(cal1).forEach((key) => {
|
Object.keys(cal1).forEach((key) => {
|
||||||
|
|
Loading…
Reference in New Issue