Files
asan-service/server/WebSocket/controllers/GPS_EventsController.js
T
2024-09-28 23:00:10 +03:30

19 lines
473 B
JavaScript

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)
}
}