forked from ryanmwangi/CalMerger
save merged calendar to file
This commit is contained in:
parent
6441714568
commit
0e2d6cac8a
1 changed files with 1 additions and 18 deletions
19
server.js
19
server.js
|
@ -54,24 +54,6 @@ app.post('/merge', async (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Merge calendars
|
|
||||||
Object.keys(cal1).forEach((key) => {
|
|
||||||
let event = cal1[key];
|
|
||||||
mergedCal.push({
|
|
||||||
start: event.start,
|
|
||||||
end: event.end,
|
|
||||||
summary: `${cal1Prefix} ${event.summary}`,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(cal2).forEach((key) => {
|
|
||||||
let event = cal2[key];
|
|
||||||
mergedCal.push({
|
|
||||||
start: event.start,
|
|
||||||
end: event.end,
|
|
||||||
summary: `${cal2Prefix} ${event.summary}`,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save merged calendar to file
|
// Save merged calendar to file
|
||||||
const filename = `merged-${Date.now()}.ics`;
|
const filename = `merged-${Date.now()}.ics`;
|
||||||
|
@ -91,6 +73,7 @@ END:VEVENT
|
||||||
icalString += `END:VCALENDAR`;
|
icalString += `END:VCALENDAR`;
|
||||||
fs.writeFileSync(filename, icalString);
|
fs.writeFileSync(filename, icalString);
|
||||||
|
|
||||||
|
|
||||||
// Generate a unique URL for the merged calendar
|
// Generate a unique URL for the merged calendar
|
||||||
const mergedCalendarUrl = `${req.protocol}://${req.get('host')}/${filename}`;
|
const mergedCalendarUrl = `${req.protocol}://${req.get('host')}/${filename}`;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue