resolve issues with new features

This commit is contained in:
Matthias Hochmeister
2026-03-12 16:42:21 +01:00
parent 5aa309b97a
commit 68586b01dc
19 changed files with 526 additions and 109 deletions

View File

@@ -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,

View File

@@ -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 {