From 0099ae9da89142e4335ff1d61859892182c11800 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 4 Aug 2020 19:11:54 +0100 Subject: [PATCH] Move max_users check to room super classes Fixes bug where users would see a ghost room once the room fills up --- houdini/data/room.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/houdini/data/room.py b/houdini/data/room.py index dd92e12..c4e3e44 100644 --- a/houdini/data/room.py +++ b/houdini/data/room.py @@ -26,9 +26,6 @@ class RoomMixin: self.waddles = {} async def add_penguin(self, p): - if len(self.penguins_by_id) >= self.max_users and not p.moderator: - return await p.send_error(210) - if p.room: await p.room.remove_penguin(p) self.penguins_by_id[p.id] = p @@ -129,6 +126,9 @@ class Room(db.Model, RoomMixin): self.blackhole_penguins = {} async def add_penguin(self, p): + if len(self.penguins_by_id) >= self.max_users and not p.moderator: + return await p.send_error(210) + if self.blackhole and p.is_vanilla_client: self.blackhole_penguins[p.id] = p.room p.room = self @@ -183,6 +183,9 @@ class PenguinIglooRoom(db.Model, RoomMixin): return self.penguin_id + PenguinIglooRoom.internal_id async def add_penguin(self, p): + if len(self.penguins_by_id) >= self.max_users and not p.moderator: + return await p.send_error(210) + await RoomMixin.add_penguin(self, p) await p.send_xt('jr', self.external_id, await self.get_string(f=stealth_mod_filter(p.id)))