Skip to content

Commit

Permalink
the owner of a room can't leave
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayoub Essabiry authored and Ayoub Essabiry committed Oct 12, 2023
1 parent 1c46003 commit e23bb67
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/code/src/rooms/rooms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export class RoomsService {
}

async leaveRoom(memberData: LeaveRoomDto, userId: string) {
const { ownerId } = await this.prisma.room.findUnique({
where: { id: memberData.roomId },
select: { ownerId: true },
});
if (ownerId === userId) throw new UnauthorizedException('You are the owner of this room');
return await this.prisma.roomMember.delete({
where: {
unique_user_room: {
Expand Down

0 comments on commit e23bb67

Please sign in to comment.