fix: resolve notification routing bug, audio playback format, and backend 500 errors
- Fixed audio playback by downloading a valid mp3 file and importing it directly via Vite. - Fixed the route collision where DELETE /notifications/clear-all was being captured by /notifications/:id. - The notification badge now automatically clears (optimistic UI update) when the tray is opened. - The backend no longer throws a 500 error when querying users during impersonation handoffs.
This commit is contained in:
@@ -515,18 +515,6 @@ apiRouter.get('/notifications', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
apiRouter.put('/notifications/:id', async (req, res) => {
|
||||
try {
|
||||
await pool.query(
|
||||
'UPDATE notifications SET is_read = true WHERE id = ? AND user_id = ?',
|
||||
[req.params.id, req.user.id]
|
||||
);
|
||||
res.json({ message: 'Notification marked as read' });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
apiRouter.put('/notifications/read-all', async (req, res) => {
|
||||
try {
|
||||
await pool.query(
|
||||
@@ -539,13 +527,13 @@ apiRouter.put('/notifications/read-all', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
apiRouter.delete('/notifications/:id', async (req, res) => {
|
||||
apiRouter.put('/notifications/:id', async (req, res) => {
|
||||
try {
|
||||
await pool.query(
|
||||
'DELETE FROM notifications WHERE id = ? AND user_id = ?',
|
||||
'UPDATE notifications SET is_read = true WHERE id = ? AND user_id = ?',
|
||||
[req.params.id, req.user.id]
|
||||
);
|
||||
res.json({ message: 'Notification deleted' });
|
||||
res.json({ message: 'Notification marked as read' });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
@@ -563,6 +551,18 @@ apiRouter.delete('/notifications/clear-all', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
apiRouter.delete('/notifications/:id', async (req, res) => {
|
||||
try {
|
||||
await pool.query(
|
||||
'DELETE FROM notifications WHERE id = ? AND user_id = ?',
|
||||
[req.params.id, req.user.id]
|
||||
);
|
||||
res.json({ message: 'Notification deleted' });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// --- Funnel Routes ---
|
||||
apiRouter.get('/funnels', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user