From 8ac8cd21ec86cffe94bde9c31fbae43e53ddf6e9 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Sat, 4 Apr 2026 15:34:58 +0000 Subject: [PATCH] fix: allow self-promotion to first admin in room Users can now add themselves as the first admin without existing admin permission. This enables /start in DMs to work correctly. --- core/services.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/services.py b/core/services.py index 62e86c9..3bd7aa7 100644 --- a/core/services.py +++ b/core/services.py @@ -35,11 +35,15 @@ class BountyService: def add_admin( self, room_id: int, admin_user_id: int, requesting_user_id: int ) -> None: - """Add an admin to a room. Requires admin permission.""" - if not self.is_admin(room_id, requesting_user_id): - raise PermissionError("Only admins can add admins.") - + """Add an admin to a room. Requires admin permission, or self-promotion if first admin.""" room_data = self._storage.load(room_id) + has_no_admins = room_data is None or not room_data.admin_user_ids + is_self_promotion = requesting_user_id == admin_user_id + + if not self.is_admin(room_id, requesting_user_id): + if not (has_no_admins and is_self_promotion): + raise PermissionError("Only admins can add admins.") + if room_data is None: room_data = RoomData( room_id=room_id, bounties=[], next_id=1, admin_user_ids=[]