forked from ryanmwangi/CalMerger
parse calendar data in calendar/:name endpoint with ICAL
This commit is contained in:
parent
c78b0501ea
commit
c264c6b842
11
server.js
11
server.js
|
@ -175,6 +175,17 @@ app.get('/calendar/:name', async (req, res) => {
|
|||
|
||||
// Parse calendar data
|
||||
validResults.forEach((result) => {
|
||||
const parsed = ICAL.parse(result.data);
|
||||
const component = new ICAL.Component(parsed);
|
||||
const events = component.getAllSubcomponents('vevent');
|
||||
|
||||
events.forEach((event) => {
|
||||
const vevent = new ICAL.Event(event);
|
||||
const start = vevent.startDate.toJSDate();
|
||||
const end = vevent.endDate.toJSDate();
|
||||
const summary = result.override ? result.prefix : `${result.prefix} ${vevent.summary}`;
|
||||
});
|
||||
|
||||
const parsedCalendar = ical.parseICS(result.data);
|
||||
Object.keys(parsedCalendar).forEach((key) => {
|
||||
const event = parsedCalendar[key];
|
||||
|
|
Loading…
Reference in New Issue