feat: mark read endpoint
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
This commit is contained in:
parent
c0bc31714e
commit
071262a85a
1 changed files with 28 additions and 18 deletions
|
|
@ -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: {
|
||||||
|
id: body ? { in: body.id } : undefined,
|
||||||
|
OR: !body
|
||||||
|
? [
|
||||||
|
{ receiverId: req.user.sub },
|
||||||
|
req.user.roles.length > 0
|
||||||
|
? {
|
||||||
|
groupReceiver: { some: { name: { in: req.user.roles } } },
|
||||||
|
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||||
|
}
|
||||||
|
: {},
|
||||||
|
]
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// this.setStatus(HttpStatus.CREATED);
|
await prisma.$transaction(
|
||||||
|
record.map((v) =>
|
||||||
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented");
|
prisma.notification.update({
|
||||||
}
|
where: { id: v.id },
|
||||||
|
data: {
|
||||||
@Put("{notificationId}")
|
readByUser: { connect: { id: req.user.sub } },
|
||||||
@Security("keycloak")
|
},
|
||||||
async updateNotification(
|
}),
|
||||||
@Request() req: RequestWithUser,
|
),
|
||||||
@Path() notificationId: string,
|
);
|
||||||
@Body() body: NotificationUpdate,
|
|
||||||
) {
|
|
||||||
// TODO: implement
|
|
||||||
|
|
||||||
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{notificationId}")
|
@Delete("{notificationId}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue