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

@@ -1,6 +1,6 @@
{ {
"name": "gancio", "name": "gancio",
"version": "0.9.26", "version": "0.9.27",
"description": "A shared agenda for local communities", "description": "A shared agenda for local communities",
"author": "lesion", "author": "lesion",
"scripts": { "scripts": {

View File

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