resolve issues with new features
This commit is contained in:
@@ -189,7 +189,7 @@ async function getPageById(id: number): Promise<BookStackPageDetail> {
|
||||
html: page.html ?? '',
|
||||
created_at: page.created_at,
|
||||
updated_at: page.updated_at,
|
||||
url: `${bookstack.url}/books/${page.book_slug || page.book_id}/page/${page.slug}`,
|
||||
url: `${bookstack.url}/books/${page.book?.slug || page.book_slug || page.book_id}/page/${page.slug}`,
|
||||
book: page.book,
|
||||
createdBy: page.created_by,
|
||||
updatedBy: page.updated_by,
|
||||
|
||||
@@ -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