3 Commits

Author SHA1 Message Date
9e0905d49e Added default role handling #360 2023-09-24 16:43:28 +02:00
3c0719f50e Added default role to backend #360 2023-09-24 16:19:18 +02:00
77d3668a06 Set version #360 2023-09-24 16:11:56 +02:00
34 changed files with 103 additions and 26 deletions

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -12,6 +12,7 @@ from bot_data.migration.auto_role_migration import AutoRoleMigration
from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlagsMigration
from bot_data.migration.config_migration import ConfigMigration from bot_data.migration.config_migration import ConfigMigration
from bot_data.migration.db_history_migration import DBHistoryMigration from bot_data.migration.db_history_migration import DBHistoryMigration
from bot_data.migration.default_role_migration import DefaultRoleMigration
from bot_data.migration.initial_migration import InitialMigration from bot_data.migration.initial_migration import InitialMigration
from bot_data.migration.level_migration import LevelMigration from bot_data.migration.level_migration import LevelMigration
from bot_data.migration.remove_stats_migration import RemoveStatsMigration from bot_data.migration.remove_stats_migration import RemoveStatsMigration
@@ -48,3 +49,4 @@ class StartupMigrationExtension(StartupExtensionABC):
services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0 services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0
services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0 services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0 services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -0,0 +1,34 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class DefaultRoleMigration(MigrationABC):
name = "1.1.3_DefaultRoleMigration"
def __init__(self, logger: DatabaseLogger, db: DBContext):
MigrationABC.__init__(self)
self._logger = logger
self._db = db
self._cursor = db.cursor
def upgrade(self):
self._logger.debug(__name__, "Running upgrade")
self._cursor.execute(
str(
f"""
ALTER TABLE CFG_Server
ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId;
"""
)
)
def downgrade(self):
self._cursor.execute(
str(
f"""
ALTER TABLE CFG_Server DROP COLUMN DefaultRoleId;
"""
)
)

View File

@@ -26,6 +26,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
help_voice_channel_id: int, help_voice_channel_id: int,
team_channel_id: int, team_channel_id: int,
login_message_channel_id: int, login_message_channel_id: int,
default_role_id: int,
feature_flags: dict[FeatureFlagsEnum], feature_flags: dict[FeatureFlagsEnum],
server: Server, server: Server,
afk_channel_ids: List[int], afk_channel_ids: List[int],
@@ -48,6 +49,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
self._help_voice_channel_id = help_voice_channel_id self._help_voice_channel_id = help_voice_channel_id
self._team_channel_id = team_channel_id self._team_channel_id = team_channel_id
self._login_message_channel_id = login_message_channel_id self._login_message_channel_id = login_message_channel_id
self._default_role_id = default_role_id
self._feature_flags = feature_flags self._feature_flags = feature_flags
self._server = server self._server = server
self._afk_channel_ids = afk_channel_ids self._afk_channel_ids = afk_channel_ids
@@ -165,6 +167,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
def login_message_channel_id(self, value: int): def login_message_channel_id(self, value: int):
self._login_message_channel_id = value self._login_message_channel_id = value
@property
def default_role_id(self) -> int:
return self._default_role_id
@default_role_id.setter
def default_role_id(self, value: int):
self._default_role_id = value
@property @property
def feature_flags(self) -> dict[FeatureFlagsEnum]: def feature_flags(self) -> dict[FeatureFlagsEnum]:
return self._feature_flags return self._feature_flags
@@ -237,6 +247,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
`HelpVoiceChannelId`, `HelpVoiceChannelId`,
`TeamChannelId`, `TeamChannelId`,
`LoginMessageChannelId`, `LoginMessageChannelId`,
`DefaultRoleId`,
`FeatureFlags`, `FeatureFlags`,
`ServerId` `ServerId`
) VALUES ( ) VALUES (
@@ -253,6 +264,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
{self._help_voice_channel_id}, {self._help_voice_channel_id},
{self._team_channel_id}, {self._team_channel_id},
{self._login_message_channel_id}, {self._login_message_channel_id},
{self._default_role_id},
'{json.dumps(self._feature_flags)}', '{json.dumps(self._feature_flags)}',
{self._server.id} {self._server.id}
); );
@@ -277,6 +289,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
`HelpVoiceChannelId` = {self._help_voice_channel_id}, `HelpVoiceChannelId` = {self._help_voice_channel_id},
`TeamChannelId` = {self._team_channel_id}, `TeamChannelId` = {self._team_channel_id},
`LoginMessageChannelId` = {self._login_message_channel_id}, `LoginMessageChannelId` = {self._login_message_channel_id},
`DefaultRoleId` = {self._default_role_id},
`FeatureFlags` = '{json.dumps(self._feature_flags)}', `FeatureFlags` = '{json.dumps(self._feature_flags)}',
`ServerId` = {self._server.id} `ServerId` = {self._server.id}
WHERE `Id` = {self._id}; WHERE `Id` = {self._id};

View File

@@ -17,6 +17,7 @@ class ServerConfigHistory(HistoryTableABC):
help_voice_channel_id: int, help_voice_channel_id: int,
team_channel_id: int, team_channel_id: int,
login_message_channel_id: int, login_message_channel_id: int,
default_role_id: int,
feature_flags: dict[str], feature_flags: dict[str],
server_id: int, server_id: int,
deleted: bool, deleted: bool,
@@ -40,6 +41,7 @@ class ServerConfigHistory(HistoryTableABC):
self._help_voice_channel_id = help_voice_channel_id self._help_voice_channel_id = help_voice_channel_id
self._team_channel_id = team_channel_id self._team_channel_id = team_channel_id
self._login_message_channel_id = login_message_channel_id self._login_message_channel_id = login_message_channel_id
self._default_role_id = default_role_id
self._feature_flags = feature_flags self._feature_flags = feature_flags
self._server_id = server_id self._server_id = server_id
@@ -99,6 +101,10 @@ class ServerConfigHistory(HistoryTableABC):
def login_message_channel_id(self) -> int: def login_message_channel_id(self) -> int:
return self._login_message_channel_id return self._login_message_channel_id
@property
def default_role_id(self) -> int:
return self._default_role_id
@property @property
def feature_flags(self) -> dict[str]: def feature_flags(self) -> dict[str]:
return self._feature_flags return self._feature_flags

View File

@@ -64,12 +64,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
result[11], result[11],
result[12], result[12],
result[13], result[13],
json.loads(result[14]), result[14],
self._servers.get_server_by_id(result[15]), json.loads(result[15]),
self._get_afk_channel_ids(result[15]), self._servers.get_server_by_id(result[16]),
self._get_team_role_ids(result[15]), self._get_afk_channel_ids(result[16]),
result[16], self._get_team_role_ids(result[16]),
result[17], result[17],
result[18],
id=result[0], id=result[0],
) )

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -13,6 +13,7 @@ type ServerConfig implements TableWithHistoryQuery {
helpVoiceChannelId: String helpVoiceChannelId: String
teamChannelId: String teamChannelId: String
loginMessageChannelId: String loginMessageChannelId: String
defaultRoleId: String
featureFlagCount: Int featureFlagCount: Int
featureFlags: [FeatureFlag] featureFlags: [FeatureFlag]
@@ -43,6 +44,7 @@ type ServerConfigHistory implements HistoryTableQuery {
helpVoiceChannelId: String helpVoiceChannelId: String
teamChannelId: String teamChannelId: String
loginMessageChannelId: String loginMessageChannelId: String
defaultRoleId: String
featureFlagCount: Int featureFlagCount: Int
featureFlags: [FeatureFlag] featureFlags: [FeatureFlag]
@@ -91,6 +93,7 @@ input ServerConfigInput {
helpVoiceChannelId: String helpVoiceChannelId: String
teamChannelId: String teamChannelId: String
loginMessageChannelId: String loginMessageChannelId: String
defaultRoleId: String
featureFlags: [FeatureFlagInput] featureFlags: [FeatureFlagInput]
afkChannelIds: [String] afkChannelIds: [String]

View File

@@ -89,6 +89,9 @@ class ServerConfigMutation(QueryABC):
if "loginMessageChannelId" in input if "loginMessageChannelId" in input
else server_config.login_message_channel_id 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 = ( server_config.feature_flags = (
dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]])) dict(zip([x["key"] for x in input["featureFlags"]], [x["value"] for x in input["featureFlags"]]))
if "featureFlags" in input if "featureFlags" in input

View File

@@ -24,6 +24,7 @@ class ServerConfigQuery(DataQueryWithHistoryABC):
self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id) self.set_field("helpVoiceChannelId", lambda config, *_: config.help_voice_channel_id)
self.set_field("teamChannelId", lambda config, *_: config.team_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("loginMessageChannelId", lambda config, *_: config.login_message_channel_id)
self.set_field("defaultRoleId", lambda config, *_: config.default_role_id)
self.add_collection( self.add_collection(
"featureFlag", "featureFlag",
lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]), lambda config, *_: List(any, [{"key": x, "value": config.feature_flags[x]} for x in config.feature_flags]),

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "", "Author": "",
"AuthorEmail": "", "AuthorEmail": "",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "2" "Micro": "3"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@@ -1,6 +1,6 @@
{ {
"name": "kdb-web", "name": "kdb-web",
"version": "1.1.1", "version": "1.1.dev360",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"update-version": "ts-node update-version.ts", "update-version": "ts-node update-version.ts",
@@ -51,4 +51,4 @@
"tslib": "^2.4.1", "tslib": "^2.4.1",
"typescript": "~4.9.5" "typescript": "~4.9.5"
} }
} }

View File

@@ -16,6 +16,7 @@ export interface ServerConfig extends DataWithHistory {
helpVoiceChannelId?: string; helpVoiceChannelId?: string;
teamChannelId?: string; teamChannelId?: string;
loginMessageChannelId?: string; loginMessageChannelId?: string;
defaultRoleId?: string;
featureFlags: FeatureFlag[]; featureFlags: FeatureFlag[];
afkChannelIds: string[]; afkChannelIds: string[];
moderatorRoleIds: string[]; moderatorRoleIds: string[];

View File

@@ -211,6 +211,7 @@ export class Mutations {
$helpVoiceChannelId: String, $helpVoiceChannelId: String,
$teamChannelId: String, $teamChannelId: String,
$loginMessageChannelId: String, $loginMessageChannelId: String,
$defaultRoleId: String,
$featureFlags: [FeatureFlagInput], $featureFlags: [FeatureFlagInput],
$afkChannelIds: [String], $afkChannelIds: [String],
$moderatorRoleIds: [String], $moderatorRoleIds: [String],
@@ -232,6 +233,7 @@ export class Mutations {
helpVoiceChannelId: $helpVoiceChannelId, helpVoiceChannelId: $helpVoiceChannelId,
teamChannelId: $teamChannelId, teamChannelId: $teamChannelId,
loginMessageChannelId: $loginMessageChannelId, loginMessageChannelId: $loginMessageChannelId,
defaultRoleId: $defaultRoleId,
featureFlags: $featureFlags, featureFlags: $featureFlags,
afkChannelIds: $afkChannelIds, afkChannelIds: $afkChannelIds,
moderatorRoleIds: $moderatorRoleIds, moderatorRoleIds: $moderatorRoleIds,

View File

@@ -424,6 +424,7 @@ export class Queries {
helpVoiceChannelId helpVoiceChannelId
teamChannelId teamChannelId
loginMessageChannelId loginMessageChannelId
defaultRoleId
featureFlags { featureFlags {
key key
value value

View File

@@ -114,6 +114,14 @@
</div> </div>
</div> </div>
<div class="content-row">
<div class="content-column">
<div class="content-data-name">{{'view.server.config.bot.login_message_channel_id' | translate}}:</div>
<p-dropdown class="content-data-value" [options]="roles ?? []" optionLabel="name" optionValue="id" [(ngModel)]="config.defaultRoleId"
placeholder="{{'view.server.config.bot.default_role_id' | translate}}"></p-dropdown>
</div>
</div>
<div class="content-divider"></div> <div class="content-divider"></div>
<app-config-list [options]="voiceChannels" optionLabel="name" optionValue="id" translationKey="view.server.config.bot.afk_channels" <app-config-list [options]="voiceChannels" optionLabel="name" optionValue="id" translationKey="view.server.config.bot.afk_channels"
[(data)]="config.afkChannelIds"></app-config-list> [(data)]="config.afkChannelIds"></app-config-list>

View File

@@ -118,6 +118,7 @@ export class ConfigComponent implements OnInit {
helpVoiceChannelId: this.config.helpVoiceChannelId, helpVoiceChannelId: this.config.helpVoiceChannelId,
teamChannelId: this.config.teamChannelId, teamChannelId: this.config.teamChannelId,
loginMessageChannelId: this.config.loginMessageChannelId, loginMessageChannelId: this.config.loginMessageChannelId,
defaultRoleId: this.config.defaultRoleId,
featureFlags: this.config.featureFlags, featureFlags: this.config.featureFlags,
afkChannelIds: this.config.afkChannelIds, afkChannelIds: this.config.afkChannelIds,
moderatorRoleIds: this.config.moderatorRoleIds, moderatorRoleIds: this.config.moderatorRoleIds,

View File

@@ -415,6 +415,7 @@
"header": "Bot Konfiguration", "header": "Bot Konfiguration",
"help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung", "help_voice_channel_id": "Sprachkanal für Hilfsbenachrichtung",
"login_message_channel_id": "Kanal für die Nachricht vom Bot nach Start", "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_message_xp_per_hour": "Maximale XP pro Stunde durch Nachrichten",
"max_voice_state_hours": "Maximale Stunden für eine ontime nach Bot neustart", "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", "message_delete_timer": "Zeit bis zum löschen einer Botnachricht in sekunden",

View File

@@ -2,6 +2,6 @@
"WebVersion": { "WebVersion": {
"Major": "1", "Major": "1",
"Minor": "1", "Minor": "1",
"Micro": "1" "Micro": "dev360"
} }
} }