fixed admins when owner leaves
This commit is contained in:
@@ -721,8 +721,8 @@ export class ChatService {
|
||||
const room = await this.getRoomByName(room_name);
|
||||
if(!room)
|
||||
{
|
||||
printCallerError(`ERROR in chat: room not found for ${username}`);
|
||||
return [];
|
||||
console.log("throw error: error: true, code: 'ROOM_NOT_FOUND', message: 'room_not_found'");
|
||||
throw new HttpException({ error: true, code: 'ROOM_NOT_FOUND', message: `room_not_found` }, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
if (!room.users.includes(username))
|
||||
{
|
||||
@@ -731,8 +731,8 @@ export class ChatService {
|
||||
}
|
||||
if (room.type === "direct")
|
||||
{
|
||||
console.log("throw error: error: true, code: 'LEAVE_DIRECY_FORBIDDEN', message: 'you cannot leave a direct messages conversation'");
|
||||
throw new HttpException({ error: true, code: 'LEAVE_DIRECY_FORBIDDEN', message: `you cannot leave a direct messages conversation` }, HttpStatus.FORBIDDEN);
|
||||
console.log("throw error: error: true, code: 'LEAVE_DIRECT_FORBIDDEN', message: 'you cannot leave a direct messages conversation'");
|
||||
throw new HttpException({ error: true, code: 'LEAVE_DIRECT_FORBIDDEN', message: `you cannot leave a direct messages conversation` }, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
// delete user from room
|
||||
@@ -749,6 +749,7 @@ export class ChatService {
|
||||
else if (room.users)
|
||||
{
|
||||
room.owner = room.users[0];
|
||||
room.admins = [room.users[0]];
|
||||
messages.push(`${room.owner} is now owner of this room`);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user