mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
fix: remote events removal
This commit is contained in:
parent
a7f7fe3ecf
commit
742ed44534
2 changed files with 6 additions and 3 deletions
|
@ -11,7 +11,7 @@ const Col = helpers.col
|
|||
const notifier = require('../../notifier')
|
||||
const { htmlToText } = require('html-to-text')
|
||||
|
||||
const { Event, Resource, Tag, Place, Notification, APUser, Collection } = require('../models/models')
|
||||
const { Event, Resource, Tag, Place, Notification, APUser, Collection, EventNotification } = require('../models/models')
|
||||
|
||||
|
||||
const exportController = require('./export')
|
||||
|
@ -586,6 +586,7 @@ const eventController = {
|
|||
try {
|
||||
// remove related resources
|
||||
await Resource.destroy({ where: { eventId: event.id }})
|
||||
await EventNotification.destroy({ where: { eventId: event.id }})
|
||||
|
||||
// and finally remove the event
|
||||
await event.destroy()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { Event, Resource } = require('../api/models/models')
|
||||
const { Event, Resource, EventNotification } = require('../api/models/models')
|
||||
const { Op } = require('sequelize')
|
||||
const { DateTime } = require('luxon')
|
||||
const log = require('../log')
|
||||
|
@ -9,13 +9,15 @@ module.exports = {
|
|||
const events = await Event.findAll({ where: {
|
||||
start_datetime: { [Op.lt]: now },
|
||||
apUserApId: { [Op.ne]: null }
|
||||
}})
|
||||
}, raw: true })
|
||||
|
||||
if (!events.length) { return }
|
||||
|
||||
log.info(`Remove ${events.length} past federated events and related resources`)
|
||||
await Resource.destroy({ where: { eventId: events.map(e => e.id) }})
|
||||
|
||||
await EventNotification.destroy({ where: { eventId: events.map(e => e.id) }})
|
||||
|
||||
await Event.destroy({
|
||||
where: {
|
||||
start_datetime: { [Op.lt]: now },
|
||||
|
|
Loading…
Reference in a new issue