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