forked from ryanmwangi/CalMerger
include overide feature in post request
This commit is contained in:
parent
ecdb3c8c79
commit
df9276c8a9
23
server.js
23
server.js
|
@ -28,6 +28,7 @@ app.post('/merge', async (req, res) => {
|
||||||
return {
|
return {
|
||||||
data: response.data,
|
data: response.data,
|
||||||
prefix: calendar.prefix,
|
prefix: calendar.prefix,
|
||||||
|
override: calendar.override,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -46,11 +47,19 @@ app.post('/merge', async (req, res) => {
|
||||||
const calendar = ical.parseICS(result.data);
|
const calendar = ical.parseICS(result.data);
|
||||||
Object.keys(calendar).forEach((key) => {
|
Object.keys(calendar).forEach((key) => {
|
||||||
const event = calendar[key];
|
const event = calendar[key];
|
||||||
mergedCal.push({
|
if (result.override) {
|
||||||
start: event.start,
|
mergedCal.push({
|
||||||
end: event.end,
|
start: event.start,
|
||||||
summary: `${result.prefix} ${event.summary}`,
|
end: event.end,
|
||||||
});
|
summary: result.prefix,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mergedCal.push({
|
||||||
|
start: event.start,
|
||||||
|
end: event.end,
|
||||||
|
summary: `${result.prefix} ${event.summary}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,10 +70,10 @@ app.post('/merge', async (req, res) => {
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
CALSCALE:GREGORIAN
|
CALSCALE:GREGORIAN
|
||||||
METHOD:PUBLISH
|
METHOD:PUBLISH
|
||||||
BEGIN:VEVENT
|
|
||||||
`;
|
`;
|
||||||
mergedCal.forEach((event) => {
|
mergedCal.forEach((event) => {
|
||||||
icalString += `DTSTART:${event.start}
|
icalString += `BEGIN:VEVENT
|
||||||
|
DTSTART:${event.start}
|
||||||
DTEND:${event.end}
|
DTEND:${event.end}
|
||||||
SUMMARY:${event.summary}
|
SUMMARY:${event.summary}
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
|
|
Loading…
Reference in New Issue