send notification when event is confirmed

This commit is contained in:
lesion
2019-07-08 01:53:37 +02:00
parent 212ffed3d2
commit c24c33f722
2 changed files with 6 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ const { Op } = require('sequelize')
const lodash = require('lodash')
const { event: Event, comment: Comment, tag: Tag, place: Place, notification: Notification } = require('../models')
const Sequelize = require('sequelize')
const notifier = require('../../notifier')
const eventController = {
@@ -113,10 +114,11 @@ const eventController = {
try {
event.is_visible = true
await event.save()
// insert notification
const notifications = await eventController.getNotifications(event)
await event.setNotifications(notifications)
res.sendStatus(200)
// send notification
notifier.notifyEvent(event.id)
} catch (e) {
res.sendStatus(404)
}