Notif system

This commit is contained in:
Mr Swift
2024-09-28 23:00:10 +03:30
parent 8f63b82236
commit b1f792f493
8 changed files with 130 additions and 0 deletions
@@ -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)
}
}