From 521a063fcaea6cb2d05fa7041d3db17455d28ab7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 9 Feb 2024 08:27:36 +0100 Subject: [PATCH] Fixed technician check when not on the server /2 --- bot/src/bot_api/transformer/auth_user_transformer.py | 2 ++ bot/src/bot_core/abc/permission_service_abc.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/bot/src/bot_api/transformer/auth_user_transformer.py b/bot/src/bot_api/transformer/auth_user_transformer.py index dd82c202..5188aee9 100644 --- a/bot/src/bot_api/transformer/auth_user_transformer.py +++ b/bot/src/bot_api/transformer/auth_user_transformer.py @@ -36,6 +36,8 @@ class AuthUserTransformer(TransformerABC): def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) member = guild.get_member(user.discord_id) + if member is None: + return permissions.is_member_technician_by_id(user.discord_id) return permissions.is_member_technician(member) @staticmethod diff --git a/bot/src/bot_core/abc/permission_service_abc.py b/bot/src/bot_core/abc/permission_service_abc.py index fd13a219..3af5658e 100644 --- a/bot/src/bot_core/abc/permission_service_abc.py +++ b/bot/src/bot_core/abc/permission_service_abc.py @@ -19,3 +19,7 @@ class PermissionServiceABC(ABC): @abstractmethod def is_member_technician(self, member: discord.Member) -> bool: pass + + @abstractmethod + def is_member_technician_by_id(self, member_id: int) -> bool: + pass