mirror of
https://github.com/Discreetly/server.git
synced 2026-01-09 12:37:58 -05:00
refactor(rooms) adding idc checks for adding admins to rooms
This commit is contained in:
@@ -288,6 +288,22 @@ router.post(
|
||||
const { roomId } = req.params;
|
||||
const { idc } = req.body as { idc: string };
|
||||
try {
|
||||
const admins = await prisma.rooms.findFirst({
|
||||
where: {
|
||||
roomId: roomId
|
||||
},
|
||||
select: {
|
||||
adminIdentities: true
|
||||
}
|
||||
}) as { adminIdentities: string[] };
|
||||
if (!admins) {
|
||||
res.status(400).json({ error: 'Room not found' });
|
||||
return;
|
||||
}
|
||||
if (admins.adminIdentities.includes(idc)) {
|
||||
res.status(400).json({ error: 'Admin already in room' });
|
||||
return;
|
||||
}
|
||||
await prisma.rooms.update({
|
||||
where: {
|
||||
roomId: roomId
|
||||
|
||||
@@ -338,7 +338,7 @@ router.post('/setpassword/:id', limiter, asyncHandler(async (req: Request, res:
|
||||
res.status(500).send('Error finding room');
|
||||
})
|
||||
} else {
|
||||
res.status(401).json({ success: false, message: 'Unauthorized ' });
|
||||
res.status(401).json({ success: false, message: 'Unauthorized' });
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user