From 2182c021b97b62439de688bdda56651db0167b41 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 2 Oct 2023 08:01:17 +0200 Subject: [PATCH] Added highest role setting to gql #391 --- kdb-bot/src/bot_graphql/graphql/serverConfig.gql | 3 +++ kdb-bot/src/bot_graphql/mutations/server_config_mutation.py | 5 +++++ kdb-bot/src/bot_graphql/queries/server_config_query.py | 3 +++ 3 files changed, 11 insertions(+) diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql index 2b834a48..7683194c 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql @@ -14,6 +14,7 @@ type ServerConfig implements TableWithHistoryQuery { teamChannelId: String loginMessageChannelId: String defaultRoleId: String + shortRoleNameOnlySetHighestRole: Boolean featureFlagCount: Int featureFlags: [FeatureFlag] @@ -45,6 +46,7 @@ type ServerConfigHistory implements HistoryTableQuery { teamChannelId: String loginMessageChannelId: String defaultRoleId: String + shortRoleNameOnlySetHighestRole: Boolean featureFlagCount: Int featureFlags: [FeatureFlag] @@ -94,6 +96,7 @@ input ServerConfigInput { teamChannelId: String loginMessageChannelId: String defaultRoleId: String + shortRoleNameOnlySetHighestRole: Boolean featureFlags: [FeatureFlagInput] afkChannelIds: [String] diff --git a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py index a555e092..35ea4896 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -92,6 +92,11 @@ class ServerConfigMutation(QueryABC): server_config.default_role_id = ( input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_id ) + server_config.default_role_id = ( + input["shortRoleNameOnlySetHighestRole"] + if "shortRoleNameOnlySetHighestRole" in input + else server_config.short_role_name_only_set_highest_role + ) server_config.feature_flags = ( dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) if "featureFlags" in input diff --git a/kdb-bot/src/bot_graphql/queries/server_config_query.py b/kdb-bot/src/bot_graphql/queries/server_config_query.py index 6a068ffe..5e580eca 100644 --- a/kdb-bot/src/bot_graphql/queries/server_config_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_config_query.py @@ -25,6 +25,9 @@ class ServerConfigQuery(DataQueryWithHistoryABC): self.set_field("teamChannelId", lambda config, *_: config.team_channel_id) self.set_field("loginMessageChannelId", lambda config, *_: config.login_message_channel_id) self.set_field("defaultRoleId", lambda config, *_: config.default_role_id) + self.set_field( + "shortRoleNameOnlySetHighestRole", lambda config, *_: config.short_role_name_only_set_highest_role + ) self.add_collection( "featureFlag", lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]),