From c90ede69dda80a22fbce2e33457a8f2eb696c0a5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 27 Sep 2023 13:02:57 +0200 Subject: [PATCH] Check feature active in user joined game server mutation --- .../mutations/user_joined_game_server_mutation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py index 957b3a86..9225299d 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_joined_game_server_mutation.py @@ -9,6 +9,8 @@ from cpl_discord.service import DiscordBotServiceABC from flask import request from bot_api.configuration.authentication_settings import AuthenticationSettings +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC @@ -77,6 +79,11 @@ class UserJoinedGameServerMutation(QueryABC): def resolve_user_joined(self, *_, input: dict): game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"]) user = game_ident.user + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + raise Exception("Feature not activated") + self._can_user_mutate_data(user.server, UserRoleEnum.admin) active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id) @@ -98,6 +105,11 @@ class UserJoinedGameServerMutation(QueryABC): if game_ident is None: return user = game_ident.user + + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}") + if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server): + raise Exception("Feature not activated") + self._can_user_mutate_data(user.server, UserRoleEnum.admin) active = self._user_joined_game_servers.find_active_user_joined_game_server_by_user_id(user.id)