[fix] do not add reminders in full ics export
This commit is contained in:
@@ -104,7 +104,11 @@ const eventController = {
|
|||||||
if (format === 'json') {
|
if (format === 'json') {
|
||||||
res.json(event)
|
res.json(event)
|
||||||
} else if (format === 'ics') {
|
} else if (format === 'ics') {
|
||||||
exportController.ics(req, res, [event])
|
// last arg is alarms/reminder, ref: https://github.com/adamgibbons/ics#attributes (alarms)
|
||||||
|
exportController.ics(req, res, [event], [{
|
||||||
|
action: 'display',
|
||||||
|
trigger: { hours: 1, before: true }
|
||||||
|
}])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.sendStatus(404)
|
res.sendStatus(404)
|
||||||
|
|||||||
@@ -48,7 +48,12 @@ const exportController = {
|
|||||||
res.render('feed/rss.pug', { events, settings: req.settings, moment })
|
res.render('feed/rss.pug', { events, settings: req.settings, moment })
|
||||||
},
|
},
|
||||||
|
|
||||||
ics (req, res, events) {
|
/**
|
||||||
|
* send an ics of specified events (optionally with reminders)
|
||||||
|
* @param {*} events array of events from sequelize
|
||||||
|
* @param {*} alarms https://github.com/adamgibbons/ics#attributes (alarms)
|
||||||
|
*/
|
||||||
|
ics (req, res, events, alarms = []) {
|
||||||
const eventsMap = events.map(e => {
|
const eventsMap = events.map(e => {
|
||||||
const tmpStart = moment.unix(e.start_datetime)
|
const tmpStart = moment.unix(e.start_datetime)
|
||||||
const tmpEnd = moment.unix(e.end_datetime)
|
const tmpEnd = moment.unix(e.end_datetime)
|
||||||
@@ -63,15 +68,12 @@ const exportController = {
|
|||||||
description: e.description,
|
description: e.description,
|
||||||
location: `${e.place.name} - ${e.place.address}`,
|
location: `${e.place.name} - ${e.place.address}`,
|
||||||
url: `${req.settings.baseurl}/event/${e.id}`,
|
url: `${req.settings.baseurl}/event/${e.id}`,
|
||||||
alarms: [{
|
alarms
|
||||||
action: 'display',
|
|
||||||
trigger: { hours: 1, before: true }
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
res.type('text/calendar; charset=UTF-8')
|
res.type('text/calendar; charset=UTF-8')
|
||||||
const { error, value } = ics.createEvents(eventsMap)
|
const ret = ics.createEvents(eventsMap)
|
||||||
res.send(value)
|
res.send(ret.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user