feat: mark read endpoint
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s

This commit is contained in:
Methapon2001 2025-03-05 15:17:23 +07:00
parent c0bc31714e
commit 071262a85a

View file

@ -99,26 +99,36 @@ export class NotificationController extends Controller {
return record; return record;
} }
@Post() @Post("notification/mark-read")
@Security("keycloak") @Security("keycloak")
async createNotification(@Request() req: RequestWithUser, @Body() body: NotificationCreate) { async markRead(@Request() req: RequestWithUser, @Body() body?: { id: string[] }) {
// TODO: implement const record = await prisma.notification.findMany({
where: {
// this.setStatus(HttpStatus.CREATED); id: body ? { in: body.id } : undefined,
OR: !body
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented"); ? [
{ receiverId: req.user.sub },
req.user.roles.length > 0
? {
groupReceiver: { some: { name: { in: req.user.roles } } },
registeredBranch: { OR: permissionCondCompany(req.user) },
} }
: {},
]
: undefined,
},
});
@Put("{notificationId}") await prisma.$transaction(
@Security("keycloak") record.map((v) =>
async updateNotification( prisma.notification.update({
@Request() req: RequestWithUser, where: { id: v.id },
@Path() notificationId: string, data: {
@Body() body: NotificationUpdate, readByUser: { connect: { id: req.user.sub } },
) { },
// TODO: implement }),
),
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented"); );
} }
@Delete("{notificationId}") @Delete("{notificationId}")