admin messages and not in direct
This commit is contained in:
@@ -95,6 +95,12 @@ export class ChatController {
|
|||||||
const current_room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
const current_room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||||
await this.chatService.setAdmin(req.user.username, username, current_room_name);
|
await this.chatService.setAdmin(req.user.username, username, current_room_name);
|
||||||
|
|
||||||
|
let message = `${username} is now admin`;
|
||||||
|
await this.chatService.addMessageToRoom(current_room_name, "SERVER", message);
|
||||||
|
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
let server = this.chatGateway.server;
|
||||||
|
await server.in(socket.room).emit('message', "SERVER", message);
|
||||||
|
|
||||||
res.status(HttpStatus.OK).json({ message: `${username} is now admin in room ${current_room_name}` });
|
res.status(HttpStatus.OK).json({ message: `${username} is now admin in room ${current_room_name}` });
|
||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,6 +280,11 @@ export class ChatService {
|
|||||||
printCaller("-- in ");
|
printCaller("-- in ");
|
||||||
|
|
||||||
const room_db = await this.getRoomByName(room_name);
|
const room_db = await this.getRoomByName(room_name);
|
||||||
|
if (room_db.type === "direct")
|
||||||
|
{
|
||||||
|
printCaller(`throw error: error: true, code: 'NO_DIRECT_ADMIN', message: 'there are no admins in direct messages'`);
|
||||||
|
throw new HttpException({ error: true, code: 'NO_DIRECT_ADMIN', message: `there are no admins in direct messages` }, HttpStatus.UNAUTHORIZED);
|
||||||
|
}
|
||||||
if (!room_db.admins.includes(current_username))
|
if (!room_db.admins.includes(current_username))
|
||||||
{
|
{
|
||||||
printCaller(`throw error: error: true, code: 'NOT_ADMIN', message: 'you cannot set someone else as admin, since you are not admin yourself'`);
|
printCaller(`throw error: error: true, code: 'NOT_ADMIN', message: 'you cannot set someone else as admin, since you are not admin yourself'`);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
lines_width: "1px",
|
lines_width: "1px",
|
||||||
lines_color: "rgb(30, 30, 30)",
|
lines_color: "rgb(30, 30, 30)",
|
||||||
lines_light_color: "rgb(90, 90, 90)",
|
lines_light_color: "rgb(70, 70, 70)",
|
||||||
bg_color: "bisque",
|
bg_color: "bisque",
|
||||||
bg_light_color: "bisque",
|
bg_light_color: "bisque",
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@
|
|||||||
{
|
{
|
||||||
to_print("in make_user_admin");
|
to_print("in make_user_admin");
|
||||||
response = await make_admin($settings_user);
|
response = await make_admin($settings_user);
|
||||||
|
|
||||||
//show errors
|
//show errors
|
||||||
if (response.status >= 300 || response.error)
|
if (response.status >= 300 || response.error)
|
||||||
show_error = response.error;
|
show_error = response.error;
|
||||||
|
layout.set("room");
|
||||||
}
|
}
|
||||||
async function ban_mute_user()
|
async function ban_mute_user()
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
game invitation
|
game invitation
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{#if back === "room_set"}
|
{#if back === "room_set" && $current_room.type !== "direct"}
|
||||||
<Button on:click={make_user_admin}>
|
<Button on:click={make_user_admin}>
|
||||||
make admin
|
make admin
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user