resolve issues with new features
This commit is contained in:
@@ -113,6 +113,33 @@ class NotificationService {
|
||||
}
|
||||
}
|
||||
|
||||
/** Marks all unread notifications of a given quell_typ as read for a user. */
|
||||
async dismissByType(userId: string, quellTyp: string): Promise<void> {
|
||||
try {
|
||||
await pool.query(
|
||||
`UPDATE notifications SET gelesen = TRUE, gelesen_am = NOW()
|
||||
WHERE user_id = $1 AND quell_typ = $2 AND gelesen = FALSE`,
|
||||
[userId, quellTyp]
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error('NotificationService.dismissByType failed', { error, userId, quellTyp });
|
||||
throw new Error('Notifications konnten nicht als gelesen markiert werden');
|
||||
}
|
||||
}
|
||||
|
||||
/** Deletes all read notifications for a user. */
|
||||
async deleteAllRead(userId: string): Promise<void> {
|
||||
try {
|
||||
await pool.query(
|
||||
`DELETE FROM notifications WHERE user_id = $1 AND gelesen = TRUE`,
|
||||
[userId]
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error('NotificationService.deleteAllRead failed', { error, userId });
|
||||
throw new Error('Gelesene Notifications konnten nicht gelöscht werden');
|
||||
}
|
||||
}
|
||||
|
||||
/** Deletes read notifications older than 90 days for all users. */
|
||||
async deleteOldRead(): Promise<void> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user