Notif system
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const Notification = require('../../models/GPS.Notif')
|
||||
|
||||
|
||||
module.exports.notifyGPS = async (type, gps_id) => {
|
||||
try {
|
||||
const io = global._io
|
||||
const gps = io.of('/gps')
|
||||
const data = { type }
|
||||
|
||||
if (type === 'updateGPSInbox') {
|
||||
const gpsInbox = await Notification.find({ userID:gps_id, seen: false }).sort({updated_at: -1})
|
||||
data.gpsInbox = gpsInbox
|
||||
}
|
||||
|
||||
gps.to(gps_id.toString()).emit(`GPS:notify`, data)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user