added is admin
This commit is contained in:
@@ -32,6 +32,7 @@ export class ChatController {
|
||||
new_room.users = room.users;
|
||||
if (room.allowed)
|
||||
new_room.allowed = room.allowed;
|
||||
|
||||
return new_room;
|
||||
}
|
||||
|
||||
@@ -84,6 +85,40 @@ export class ChatController {
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('isadmin')
|
||||
async isAdmin(@Req() req, @Res() res): Promise<void>
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||
const fields = ["admins"];
|
||||
const room_db = await this.chatService.getRoomByName(room_name, fields);
|
||||
const is_admin = room_db.admins.includes(req.user.username);
|
||||
|
||||
res.status(HttpStatus.OK).json({ is_admin: is_admin });
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
/*
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('isadmin')
|
||||
async isAdmin(@Req() req, @Res() res): Promise<void>
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||
const fields = ["admins"];
|
||||
const room_db = await this.chatService.getRoomByName(room_name, fields);
|
||||
const is_admin = room_db.admins.includes(req.user.username);
|
||||
|
||||
res.status(HttpStatus.OK).json({ is_admin: is_admin });
|
||||
printCaller("- out ");
|
||||
}
|
||||
*/
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('current')
|
||||
|
||||
@@ -432,6 +432,8 @@ export class ChatService {
|
||||
printCaller("-- in ");
|
||||
|
||||
let room_name = await this.getCurrentRoomName(socket.username);
|
||||
|
||||
/*
|
||||
const current_room = await this.getRoomByName(room_name);
|
||||
|
||||
if (current_room.protection)
|
||||
@@ -442,6 +444,7 @@ export class ChatService {
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
socket.to(socket.room).emit('message', socket.username, message);
|
||||
await this.addMessageToRoom(room_name, socket.username, message);
|
||||
|
||||
Reference in New Issue
Block a user