resolve issues with new features
This commit is contained in:
@@ -67,6 +67,34 @@ class NotificationController {
|
||||
res.status(500).json({ success: false, message: 'Notifications konnten nicht aktualisiert werden' });
|
||||
}
|
||||
}
|
||||
/** POST /api/notifications/dismiss-by-type — marks all unread notifications of a given type as read. */
|
||||
async dismissByType(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const { quellTyp } = req.body;
|
||||
if (!quellTyp || typeof quellTyp !== 'string') {
|
||||
res.status(400).json({ success: false, message: 'quellTyp ist erforderlich' });
|
||||
return;
|
||||
}
|
||||
const userId = req.user!.id;
|
||||
await notificationService.dismissByType(userId, quellTyp);
|
||||
res.status(200).json({ success: true, message: 'Notifications als gelesen markiert' });
|
||||
} catch (error) {
|
||||
logger.error('NotificationController.dismissByType error', { error });
|
||||
res.status(500).json({ success: false, message: 'Notifications konnten nicht aktualisiert werden' });
|
||||
}
|
||||
}
|
||||
|
||||
/** DELETE /api/notifications/read — deletes all read notifications for the authenticated user. */
|
||||
async deleteAllRead(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const userId = req.user!.id;
|
||||
await notificationService.deleteAllRead(userId);
|
||||
res.status(200).json({ success: true, message: 'Gelesene Notifications gelöscht' });
|
||||
} catch (error) {
|
||||
logger.error('NotificationController.deleteAllRead error', { error });
|
||||
res.status(500).json({ success: false, message: 'Gelesene Notifications konnten nicht gelöscht werden' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new NotificationController();
|
||||
|
||||
Reference in New Issue
Block a user