From 79837afdfb40903ea4d2cd4f2e8cf1a7199a940c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 9 Feb 2023 14:32:18 +0100 Subject: [PATCH] Removed server route #162-2 --- kdb-bot/src/bot_api/api_module.py | 2 - .../bot_api/controller/discord/__init__.py | 26 ------- .../controller/discord/server_controller.py | 67 ------------------- 3 files changed, 95 deletions(-) delete mode 100644 kdb-bot/src/bot_api/controller/discord/__init__.py delete mode 100644 kdb-bot/src/bot_api/controller/discord/server_controller.py diff --git a/kdb-bot/src/bot_api/api_module.py b/kdb-bot/src/bot_api/api_module.py index 21097b40..8c3d6b3b 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/kdb-bot/src/bot_api/api_module.py @@ -13,7 +13,6 @@ from bot_api.api import Api from bot_api.api_thread import ApiThread from bot_api.controller.auth_controller import AuthController from bot_api.controller.auth_discord_controller import AuthDiscordController -from bot_api.controller.discord.server_controller import ServerController from bot_api.controller.grahpql_controller import GraphQLController from bot_api.controller.gui_controller import GuiController from bot_api.event.bot_api_on_ready_event import BotApiOnReadyEvent @@ -46,7 +45,6 @@ class ApiModule(ModuleABC): services.add_transient(AuthDiscordController) services.add_transient(GuiController) services.add_transient(DiscordService) - services.add_transient(ServerController) services.add_transient(GraphQLController) # cpl-discord diff --git a/kdb-bot/src/bot_api/controller/discord/__init__.py b/kdb-bot/src/bot_api/controller/discord/__init__.py deleted file mode 100644 index 8d647bc4..00000000 --- a/kdb-bot/src/bot_api/controller/discord/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bot Keksdose bot -~~~~~~~~~~~~~~~~~~~ - -Discord bot for the Keksdose discord Server - -:copyright: (c) 2022 - 2023 sh-edraft.de -:license: MIT, see LICENSE for more details. - -""" - -__title__ = "bot_api.controller.discord" -__author__ = "Sven Heidemann" -__license__ = "MIT" -__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de" -__version__ = "0.3.1" - -from collections import namedtuple - - -# imports: - -VersionInfo = namedtuple("VersionInfo", "major minor micro") -version_info = VersionInfo(major="0", minor="3", micro="1") diff --git a/kdb-bot/src/bot_api/controller/discord/server_controller.py b/kdb-bot/src/bot_api/controller/discord/server_controller.py deleted file mode 100644 index a9f0efe1..00000000 --- a/kdb-bot/src/bot_api/controller/discord/server_controller.py +++ /dev/null @@ -1,67 +0,0 @@ -from cpl_core.configuration import ConfigurationABC -from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.mailing import EMailClientABC, EMailClientSettings -from cpl_translation import TranslatePipe -from flask import Response, jsonify, request - -from bot_api.api import Api -from bot_api.filter.discord.server_select_criteria import ServerSelectCriteria -from bot_api.json_processor import JSONProcessor -from bot_api.logging.api_logger import ApiLogger -from bot_api.route.route import Route -from bot_api.service.discord_service import DiscordService -from bot_data.model.auth_role_enum import AuthRoleEnum - - -class ServerController: - BasePath = f"/api/discord/server" - - def __init__( - self, - config: ConfigurationABC, - env: ApplicationEnvironmentABC, - logger: ApiLogger, - t: TranslatePipe, - api: Api, - mail_settings: EMailClientSettings, - mailer: EMailClientABC, - discord_service: DiscordService, - ): - self._config = config - self._env = env - self._logger = logger - self._t = t - self._api = api - self._mail_settings = mail_settings - self._mailer = mailer - self._discord_service = discord_service - - @Route.get(f"{BasePath}/get/servers") - @Route.authorize(role=AuthRoleEnum.admin) - async def get_all_servers(self) -> Response: - result = await self._discord_service.get_all_servers() - result = result.select(lambda x: x.to_dict()).to_list() - return jsonify(result) - - @Route.get(f"{BasePath}/get/servers-by-user") - @Route.authorize - async def get_all_servers_by_user(self) -> Response: - result = await self._discord_service.get_all_servers_by_user() - result = result.select(lambda x: x.to_dict()).to_list() - return jsonify(result) - - @Route.post(f"{BasePath}/get/filtered") - @Route.authorize - async def get_filtered_servers(self) -> Response: - dto: ServerSelectCriteria = JSONProcessor.process( - ServerSelectCriteria, request.get_json(force=True, silent=True) - ) - result = await self._discord_service.get_filtered_servers_async(dto) - result.result = result.result.select(lambda x: x.to_dict()).to_list() - return jsonify(result.to_dict()) - - @Route.get(f"{BasePath}/get/") - @Route.authorize - async def get_server_by_id(self, id: int) -> Response: - result = await self._discord_service.get_server_by_id_async(id).to_list() - return jsonify(result.to_dict())