fix: setUnackedFavs als Prop, user-notify beim Favoriten-Tab, Admin-Badge in Liste
This commit is contained in:
@@ -503,6 +503,12 @@ router.get('/favorites/all', authenticate, requireAdmin, (req, res) => {
|
||||
res.json(favs);
|
||||
});
|
||||
|
||||
// POST /favorites/user-notify – User hat quittierte Favoriten gesehen
|
||||
router.post('/favorites/user-notify', authenticate, (req, res) => {
|
||||
db.prepare('UPDATE movie_favorites SET user_notified=1 WHERE user_id=? AND acknowledged=1 AND user_notified=0').run(req.user.id);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// GET /favorites/unacked – unquittierte Zählung (Admin: neue Favoriten; User: quittierte aber unbestätigte)
|
||||
router.get('/favorites/unacked', authenticate, (req, res) => {
|
||||
const isAdmin = req.user.role === 'admin';
|
||||
@@ -511,7 +517,7 @@ router.get('/favorites/unacked', authenticate, (req, res) => {
|
||||
res.json({ count: count.n, isAdmin: true });
|
||||
} else {
|
||||
// User: Favoriten die vom Admin quittiert wurden aber User noch nicht gesehen hat
|
||||
const count = db.prepare('SELECT COUNT(*) as n FROM movie_favorites WHERE user_id=? AND acknowledged=1').get(req.user.id);
|
||||
const count = db.prepare('SELECT COUNT(*) as n FROM movie_favorites WHERE user_id=? AND acknowledged=1 AND user_notified=0').get(req.user.id);
|
||||
res.json({ count: count.n, isAdmin: false });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user