Activity #3529
Updated by Thara S Pillai over 1 year ago
upon a new user add, update emit notifications tables app.post('/add-user', async (req, res) => { from backend. // Emit to privileged users const io = req.app.get('io'); // 1. Insert user await addUserToDB(req.body); // 2. Create a notification entry await createNotification({ io.emit('new_user_notification', { type: 'new_user', message: 'A new `New user ${name} has been added.', joined.`, created_at: timestamp: new Date(), status: 'unread', for_role: 'admin' Date() }); // 3. Notify connected clients io.emit('new_user_notification'); res.send({ success: true }); });