Added feature flags to server config #334
This commit is contained in:
@@ -40,4 +40,5 @@ type Query {
|
||||
technicianConfig: TechnicianConfig
|
||||
|
||||
guilds(filter: GuildFilter): [Guild]
|
||||
possibleFeatureFlags: [String]
|
||||
}
|
@@ -13,6 +13,7 @@ type ServerConfig implements TableWithHistoryQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
||||
@@ -41,6 +42,7 @@ type ServerConfigHistory implements HistoryTableQuery {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlags: [FeatureFlag]
|
||||
|
||||
serverId: ID
|
||||
|
||||
@@ -87,6 +89,7 @@ input ServerConfigInput {
|
||||
helpVoiceChannelId: String
|
||||
teamChannelId: String
|
||||
loginMessageChannelId: String
|
||||
featureFlags: [FeatureFlagInput]
|
||||
|
||||
afkChannelIds: [String]
|
||||
moderatorRoleIds: [String]
|
||||
|
@@ -82,6 +82,11 @@ class ServerConfigMutation(QueryABC):
|
||||
if "loginMessageChannelId" in input
|
||||
else server_config.login_message_channel_id
|
||||
)
|
||||
server_config.feature_flags = (
|
||||
dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]]))
|
||||
if "featureFlags" in input
|
||||
else server_config.feature_flags
|
||||
)
|
||||
server_config.afk_channel_ids = (
|
||||
List(int).extend([int(x) for x in input["afkChannelIds"]])
|
||||
if "afkChannelIds" in input
|
||||
|
@@ -23,6 +23,10 @@ class ServerConfigQuery(DataQueryWithHistoryABC):
|
||||
self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id)
|
||||
self.set_field("teamChannelId", lambda config, *_: config.team_channel_id)
|
||||
self.set_field("loginMessageChannelId", lambda config, *_: config.login_message_channel_id)
|
||||
self.set_field(
|
||||
"featureFlags",
|
||||
lambda config, *_: [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags],
|
||||
)
|
||||
self.set_field("afkChannelIds", lambda config, *_: config.afk_channel_ids)
|
||||
self.set_field(
|
||||
"moderatorRoleIds",
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||
@@ -75,6 +76,7 @@ class Query(QueryABC):
|
||||
self.set_field("guilds", self._resolve_guilds)
|
||||
self.set_field("achievementAttributes", lambda x, *_: achievement_service.get_attributes())
|
||||
self.set_field("achievementOperators", lambda x, *_: achievement_service.get_operators())
|
||||
self.set_field("possibleFeatureFlags", lambda x, *_: [e.value for e in FeatureFlagsEnum])
|
||||
|
||||
def _resolve_guilds(self, *_, filter=None):
|
||||
if filter is None or "id" not in filter:
|
||||
|
Reference in New Issue
Block a user