@@ -5,6 +5,9 @@ const permission = require('../utils/permission')
55const helper = require ( '../utils/paginate' )
66const notificationHelper = require ( '../utils/notif-helper' )
77const settingsHelper = require ( '../utils/settingHelpers' )
8+ const activityTracker = require ( '../utils/activity-helper' )
9+ const collectionTypes = require ( '../utils/collections' )
10+
811const notification = {
912 heading : '' ,
1013 content : '' ,
@@ -22,6 +25,7 @@ module.exports = {
2225 notification . content = `${ event . eventName } is added!`
2326 notification . tag = 'New!'
2427 notificationHelper . addToNotificationForAll ( req , res , notification , next )
28+ activityTracker . addToRedis ( req , res , next , collectionTypes . EVENT , event . _id )
2529 res . status ( HttpStatus . CREATED ) . json ( { event : event } )
2630 } catch ( error ) {
2731 res . status ( HttpStatus . BAD_REQUEST ) . json ( { error : error } )
@@ -53,6 +57,7 @@ module.exports = {
5357 notification . content = `${ event . eventName } is updated!`
5458 notification . tag = 'Update'
5559 notificationHelper . addToNotificationForAll ( req , res , notification , next )
60+ activityTracker . addToRedis ( req , res , next , collectionTypes . EVENT , event . _id )
5661 res . status ( HttpStatus . OK ) . json ( { event : event } )
5762 } catch ( error ) {
5863 HANDLER . handleError ( res , error )
@@ -163,7 +168,11 @@ module.exports = {
163168 notification . content = `Event ${ deleteEvent . eventName } is deleted!`
164169 notification . tag = 'Deleted'
165170 notificationHelper . addToNotificationForAll ( req , res , notification , next )
166- return res . status ( HttpStatus . OK ) . json ( { deleteEvent : deleteEvent , message : 'Deleted the event' } )
171+ activityTracker . addToRedis ( req , res , next , collectionTypes . EVENT , deleteEvent . _id )
172+ return res . status ( HttpStatus . OK ) . json ( {
173+ deleteEvent : deleteEvent ,
174+ message : 'Deleted the event'
175+ } )
167176 }
168177 return res . status ( HttpStatus . BAD_REQUEST ) . json ( { msg : 'Not permitted!' } )
169178 } catch ( error ) {
0 commit comments