You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The frontend uses [email protected] for real-time communication. In-app notifications (asset transferred to you, work order assigned, maintenance due) must arrive instantly without page refresh. The WebSocket gateway was previously implemented and then deleted in commit be0be8c — it needs to be rebuilt.
Overview
The frontend uses
[email protected]for real-time communication. In-app notifications (asset transferred to you, work order assigned, maintenance due) must arrive instantly without page refresh. The WebSocket gateway was previously implemented and then deleted in commitbe0be8c— it needs to be rebuilt.Context
package.jsonhas@nestjs/[email protected],@nestjs/[email protected], and[email protected]user:{userId}so notifications can be sent to specific usersAcceptance Criteria
NotificationsGatewaywith@WebSocketGateway({ cors: true, namespace: '/notifications' })handleConnection: extract JWT fromclient.handshake.auth.token, verify withJwtService, join roomuser:{userId}, disconnect unauthenticated clientsNotificationsService.sendToUser(userId, type, payload)— emits to the user's room:this.server.to(user:${userId}).emit('notification', { type, payload, timestamp })ASSET_TRANSFERRED,WORK_ORDER_ASSIGNED,MAINTENANCE_DUE,BOOKING_CONFIRMED,CHECKOUT_OVERDUE,WARRANTY_EXPIRINGNotificationentity to persist all sent notifications:id,userId,type,title,body,payload(JSON),isRead,createdAtGET /notifications— current user's notification history, unread firstPATCH /notifications/:id/readandPATCH /notifications/read-all