mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
refactor(auth, files): async DB-touching methods; transactions through UnitOfWork
This commit is contained in:
@@ -77,7 +77,7 @@ export class NotificationsMcp {
|
||||
access: { group: 'notifications', mode: 'write' },
|
||||
})
|
||||
async markNotificationRead({ notificationId }: { notificationId: number }, ctx: McpContext) {
|
||||
if (this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
if (await this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
const success = await this.notifications.markRead(notificationId, ctx.userId);
|
||||
if (!success) return { content: [{ type: 'text' as const, text: 'Notification not found.' }], isError: true };
|
||||
return ok({ success: true });
|
||||
@@ -93,7 +93,7 @@ export class NotificationsMcp {
|
||||
access: { group: 'notifications', mode: 'write' },
|
||||
})
|
||||
async markNotificationUnread({ notificationId }: { notificationId: number }, ctx: McpContext) {
|
||||
if (this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
if (await this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
const success = await this.notifications.markUnread(notificationId, ctx.userId);
|
||||
if (!success) return { content: [{ type: 'text' as const, text: 'Notification not found.' }], isError: true };
|
||||
return ok({ success: true });
|
||||
@@ -107,7 +107,7 @@ export class NotificationsMcp {
|
||||
access: { group: 'notifications', mode: 'write' },
|
||||
})
|
||||
async markAllNotificationsRead(_input: Record<string, never>, ctx: McpContext) {
|
||||
if (this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
if (await this.auth.isDemoUser(ctx.userId)) return demoDenied();
|
||||
const count = await this.notifications.markAllRead(ctx.userId);
|
||||
return ok({ success: true, count });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user