From 34af1f9dcd8febef6a9d7654a7f8e8ffb5a3b603 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 5 Mar 2025 10:49:08 +0700 Subject: [PATCH] feat: read by user --- src/controllers/00-notification-controller.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/00-notification-controller.ts b/src/controllers/00-notification-controller.ts index c0c463c..0e27847 100644 --- a/src/controllers/00-notification-controller.ts +++ b/src/controllers/00-notification-controller.ts @@ -67,7 +67,14 @@ export class NotificationController extends Controller { @Get("{notificationId}") @Security("keycloak") async getNotification(@Request() req: RequestWithUser, @Path() notificationId: string) { - const record = await prisma.notification.findFirst({ where: { id: notificationId } }); + const record = await prisma.notification.update({ + where: { id: notificationId }, + data: { + readByUser: { + connect: { id: req.user.sub }, + }, + }, + }); if (!record) throw notFoundError("Notification");