mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
do not use end time when not used, fix #233
This commit is contained in:
parent
9d17770c3d
commit
a36c8c29cb
2 changed files with 12 additions and 5 deletions
|
@ -81,14 +81,13 @@ const exportController = {
|
|||
ics (_req, res, events, alarms = []) {
|
||||
const settings = res.locals.settings
|
||||
const eventsMap = events.map(e => {
|
||||
|
||||
const tmpStart = moment.unix(e.start_datetime)
|
||||
const tmpEnd = moment.unix(e.end_datetime)
|
||||
const start = tmpStart.utc(true).format('YYYY-M-D-H-m').split('-').map(Number)
|
||||
const end = tmpEnd.utc(true).format('YYYY-M-D-H-m').split('-').map(Number)
|
||||
return {
|
||||
|
||||
const ret = {
|
||||
uid: `${e.id}@${settings.hostname}`,
|
||||
start,
|
||||
end,
|
||||
title: `[${settings.title}] ${e.title}`,
|
||||
description: htmlToText(e.description),
|
||||
htmlContent: e.description,
|
||||
|
@ -98,6 +97,14 @@ const exportController = {
|
|||
categories: e.tags.map(t => t.tag),
|
||||
alarms
|
||||
}
|
||||
|
||||
if (e.end_datetime) {
|
||||
const tmpEnd = moment.unix(e.end_datetime)
|
||||
const end = tmpEnd.utc(true).format('YYYY-M-D-H-m').split('-').map(Number)
|
||||
ret.end = end
|
||||
}
|
||||
|
||||
return ret
|
||||
})
|
||||
res.type('text/calendar; charset=UTF-8')
|
||||
ics.createEvents(eventsMap, (err, value) => {
|
||||
|
|
|
@ -69,7 +69,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||
url: `${config.baseurl}/event/${this.slug || this.id}`,
|
||||
type: 'Event',
|
||||
startTime: dayjs.unix(this.start_datetime).tz().locale(locale).format(),
|
||||
endTime: this.end_datetime ? dayjs.unix(this.end_datetime).tz().locale(locale).format() : null,
|
||||
...( this.end_datetime ? { endTime : dayjs.unix(this.end_datetime).tz().locale(locale).format() } : {} ),
|
||||
location: {
|
||||
name: this.place.name,
|
||||
address: this.place.address,
|
||||
|
|
Loading…
Reference in a new issue