diff options
author | Raphael Kabo <mail@raphaelkabo.com> | 2019-09-30 13:57:28 +0100 |
---|---|---|
committer | Raphael Kabo <mail@raphaelkabo.com> | 2019-09-30 13:57:28 +0100 |
commit | 40ade71e0019bbb59710a2e2e5d74197c47cb1b0 (patch) | |
tree | e3d6cacdaa694ede107389054261a78841652514 /routes.js | |
parent | eddfe0389047ac1df5a8194d36c3bde1fcc05866 (diff) |
Fixes to iCal parser
Diffstat (limited to 'routes.js')
-rwxr-xr-x | routes.js | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -505,9 +505,18 @@ router.post('/importevent', (req, res) => { if (req.files && Object.keys(req.files).length != 0) { importediCalObject = ical.parseICS(req.files.icsImportControl.data.toString('utf8')); for (var key in importediCalObject) { - importedEventData = importediCalObject[key]; + importedEventData = importediCalObject[key]; } - creatorEmail = importedEventData.organizer.val.replace("MAILTO:", "") + console.log(importedEventData) + let creatorEmail; + if (req.body.creatorEmail) { + creatorEmail = req.body.creatorEmail + } else if (importedEventData.organizer) { + creatorEmail = importedEventData.organizer.val.replace("MAILTO:", ""); + } else { + res.status(500).send("Please supply an email address on the previous page."); + } + const event = new Event({ id: eventID, type: 'public', @@ -515,12 +524,12 @@ router.post('/importevent', (req, res) => { location: importedEventData.location, start: importedEventData.start, end: importedEventData.end, - timezone: importedEventData.start.tz, + timezone: typeof importedEventData.start.tz != 'undefined' ? importedEventData.start.tz : "Etc/UTC", description: importedEventData.description, image: '', creatorEmail: creatorEmail, url: '', - hostName: importedEventData.organizer.params.CN, + hostName: importedEventData.organizer ? importedEventData.organizer.params.CN : "", viewPassword: '', editPassword: '', editToken: editToken, |