fix recurrent events
This commit is contained in:
@@ -6,6 +6,7 @@ const { event: Event, comment: Comment, tag: Tag, place: Place, user: User, noti
|
|||||||
const Sequelize = require('sequelize')
|
const Sequelize = require('sequelize')
|
||||||
const notifier = require('../../notifier')
|
const notifier = require('../../notifier')
|
||||||
const federation = require('../../federation/helpers')
|
const federation = require('../../federation/helpers')
|
||||||
|
const debug = require('debug')('controller:event')
|
||||||
|
|
||||||
const eventController = {
|
const eventController = {
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ const eventController = {
|
|||||||
// build singular events from a recurrent pattern
|
// build singular events from a recurrent pattern
|
||||||
function createEventsFromRecurrent (e, dueTo = null) {
|
function createEventsFromRecurrent (e, dueTo = null) {
|
||||||
const events = []
|
const events = []
|
||||||
const recurrent = JSON.parse(e.recurrent)
|
const recurrent = e.recurrent
|
||||||
if (!recurrent.frequency) { return false }
|
if (!recurrent.frequency) { return false }
|
||||||
|
|
||||||
let cursor = moment(start).startOf('week')
|
let cursor = moment(start).startOf('week')
|
||||||
@@ -284,8 +285,8 @@ const eventController = {
|
|||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
let allEvents = events.filter(e => !e.recurrent)
|
let allEvents = events.filter(e => !e.recurrent || e.recurrent.length === 0)
|
||||||
events.filter(e => e.recurrent).forEach(e => {
|
events.filter(e => e.recurrent && e.recurrent.length).forEach(e => {
|
||||||
const events = createEventsFromRecurrent(e, end)
|
const events = createEventsFromRecurrent(e, end)
|
||||||
if (events) { allEvents = allEvents.concat(events) }
|
if (events) { allEvents = allEvents.concat(events) }
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user