From 9e0905d49e66dadd7ac4bf8240f967968d0bddf5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 24 Sep 2023 16:43:16 +0200 Subject: [PATCH] Added default role handling #360 --- kdb-bot/src/bot_data/migration/default_role_migration.py | 2 +- kdb-bot/src/bot_data/model/server_config.py | 3 +++ .../bot_data/service/server_config_repository_service.py | 8 ++++---- kdb-bot/src/bot_graphql/graphql/serverConfig.gql | 2 ++ .../src/bot_graphql/mutations/server_config_mutation.py | 3 +++ kdb-web/package.json | 4 ++-- kdb-web/src/app/models/config/server-config.model.ts | 1 + kdb-web/src/app/models/graphql/mutations.model.ts | 2 ++ kdb-web/src/app/models/graphql/queries.model.ts | 1 + .../server/config/components/config/config.component.html | 8 ++++++++ .../server/config/components/config/config.component.ts | 1 + kdb-web/src/assets/i18n/de.json | 1 + kdb-web/src/assets/version.json | 2 +- 13 files changed, 30 insertions(+), 8 deletions(-) diff --git a/kdb-bot/src/bot_data/migration/default_role_migration.py b/kdb-bot/src/bot_data/migration/default_role_migration.py index eaa5c41e..24fd4940 100644 --- a/kdb-bot/src/bot_data/migration/default_role_migration.py +++ b/kdb-bot/src/bot_data/migration/default_role_migration.py @@ -4,7 +4,7 @@ from bot_data.db_context import DBContext class DefaultRoleMigration(MigrationABC): - name = "1.1.3_ConfigMigration" + name = "1.1.3_DefaultRoleMigration" def __init__(self, logger: DatabaseLogger, db: DBContext): MigrationABC.__init__(self) diff --git a/kdb-bot/src/bot_data/model/server_config.py b/kdb-bot/src/bot_data/model/server_config.py index 4b0e7f83..87064e66 100644 --- a/kdb-bot/src/bot_data/model/server_config.py +++ b/kdb-bot/src/bot_data/model/server_config.py @@ -247,6 +247,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `HelpVoiceChannelId`, `TeamChannelId`, `LoginMessageChannelId`, + `DefaultRoleId`, `FeatureFlags`, `ServerId` ) VALUES ( @@ -263,6 +264,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): {self._help_voice_channel_id}, {self._team_channel_id}, {self._login_message_channel_id}, + {self._default_role_id}, '{json.dumps(self._feature_flags)}', {self._server.id} ); @@ -287,6 +289,7 @@ class ServerConfig(TableABC, ConfigurationModelABC): `HelpVoiceChannelId` = {self._help_voice_channel_id}, `TeamChannelId` = {self._team_channel_id}, `LoginMessageChannelId` = {self._login_message_channel_id}, + `DefaultRoleId` = {self._default_role_id}, `FeatureFlags` = '{json.dumps(self._feature_flags)}', `ServerId` = {self._server.id} WHERE `Id` = {self._id}; diff --git a/kdb-bot/src/bot_data/service/server_config_repository_service.py b/kdb-bot/src/bot_data/service/server_config_repository_service.py index 689a6289..0e03a87e 100644 --- a/kdb-bot/src/bot_data/service/server_config_repository_service.py +++ b/kdb-bot/src/bot_data/service/server_config_repository_service.py @@ -67,10 +67,10 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC): result[14], json.loads(result[15]), self._servers.get_server_by_id(result[16]), - self._get_afk_channel_ids(result[17]), - self._get_team_role_ids(result[18]), - result[19], - result[20], + self._get_afk_channel_ids(result[16]), + self._get_team_role_ids(result[16]), + result[17], + result[18], id=result[0], ) diff --git a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql index 1b14c6ee..2b834a48 100644 --- a/kdb-bot/src/bot_graphql/graphql/serverConfig.gql +++ b/kdb-bot/src/bot_graphql/graphql/serverConfig.gql @@ -44,6 +44,7 @@ type ServerConfigHistory implements HistoryTableQuery { helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String + defaultRoleId: String featureFlagCount: Int featureFlags: [FeatureFlag] @@ -92,6 +93,7 @@ input ServerConfigInput { helpVoiceChannelId: String teamChannelId: String loginMessageChannelId: String + defaultRoleId: String 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 4a56d9f0..a555e092 100644 --- a/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/server_config_mutation.py @@ -89,6 +89,9 @@ class ServerConfigMutation(QueryABC): if "loginMessageChannelId" in input else server_config.login_message_channel_id ) + server_config.default_role_id = ( + input["defaultRoleId"] if "defaultRoleId" in input else server_config.default_role_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 diff --git a/kdb-web/package.json b/kdb-web/package.json index 8906104a..9fb3e4a3 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "1.1.1", + "version": "1.1.dev360", "scripts": { "ng": "ng", "update-version": "ts-node update-version.ts", @@ -51,4 +51,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/kdb-web/src/app/models/config/server-config.model.ts b/kdb-web/src/app/models/config/server-config.model.ts index c2b1d1c8..3d17b8d2 100644 --- a/kdb-web/src/app/models/config/server-config.model.ts +++ b/kdb-web/src/app/models/config/server-config.model.ts @@ -16,6 +16,7 @@ export interface ServerConfig extends DataWithHistory { helpVoiceChannelId?: string; teamChannelId?: string; loginMessageChannelId?: string; + defaultRoleId?: string; featureFlags: FeatureFlag[]; afkChannelIds: string[]; moderatorRoleIds: string[]; diff --git a/kdb-web/src/app/models/graphql/mutations.model.ts b/kdb-web/src/app/models/graphql/mutations.model.ts index 20263626..6fc27fc0 100644 --- a/kdb-web/src/app/models/graphql/mutations.model.ts +++ b/kdb-web/src/app/models/graphql/mutations.model.ts @@ -211,6 +211,7 @@ export class Mutations { $helpVoiceChannelId: String, $teamChannelId: String, $loginMessageChannelId: String, + $defaultRoleId: String, $featureFlags: [FeatureFlagInput], $afkChannelIds: [String], $moderatorRoleIds: [String], @@ -232,6 +233,7 @@ export class Mutations { helpVoiceChannelId: $helpVoiceChannelId, teamChannelId: $teamChannelId, loginMessageChannelId: $loginMessageChannelId, + defaultRoleId: $defaultRoleId, featureFlags: $featureFlags, afkChannelIds: $afkChannelIds, moderatorRoleIds: $moderatorRoleIds, diff --git a/kdb-web/src/app/models/graphql/queries.model.ts b/kdb-web/src/app/models/graphql/queries.model.ts index bd83b01d..1014ec79 100644 --- a/kdb-web/src/app/models/graphql/queries.model.ts +++ b/kdb-web/src/app/models/graphql/queries.model.ts @@ -424,6 +424,7 @@ export class Queries { helpVoiceChannelId teamChannelId loginMessageChannelId + defaultRoleId featureFlags { key value diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html index 89b1372e..70d5a5df 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.html +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.html @@ -114,6 +114,14 @@ +
+
+
{{'view.server.config.bot.login_message_channel_id' | translate}}:
+ +
+
+
diff --git a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts index 70855220..ed82b024 100644 --- a/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts +++ b/kdb-web/src/app/modules/view/server/config/components/config/config.component.ts @@ -118,6 +118,7 @@ export class ConfigComponent implements OnInit { helpVoiceChannelId: this.config.helpVoiceChannelId, teamChannelId: this.config.teamChannelId, loginMessageChannelId: this.config.loginMessageChannelId, + defaultRoleId: this.config.defaultRoleId, featureFlags: this.config.featureFlags, afkChannelIds: this.config.afkChannelIds, moderatorRoleIds: this.config.moderatorRoleIds, diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index cd900f90..797f9147 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -415,6 +415,7 @@ "header": "Bot Konfiguration", "help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung", "login_message_channel_id": "Kanal für die Nachricht vom Bot nach Start", + "default_role_id": "Standardrolle des Servers", "max_message_xp_per_hour": "Maximale XP pro Stunde durch Nachrichten", "max_voice_state_hours": "Maximale Stunden für eine ontime nach Bot neustart", "message_delete_timer": "Zeit bis zum löschen einer Botnachricht in sekunden", diff --git a/kdb-web/src/assets/version.json b/kdb-web/src/assets/version.json index 17952632..5412d011 100644 --- a/kdb-web/src/assets/version.json +++ b/kdb-web/src/assets/version.json @@ -2,6 +2,6 @@ "WebVersion": { "Major": "1", "Minor": "1", - "Micro": "1" + "Micro": "dev360" } } \ No newline at end of file