diff --git a/kdb-bot/src/bot_api/api_module.py b/kdb-bot/src/bot_api/api_module.py index 78a94c57..b4c1735a 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/kdb-bot/src/bot_api/api_module.py @@ -11,12 +11,11 @@ from flask import Flask from bot_api.abc.auth_service_abc import AuthServiceABC 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.gui_controller import GuiController -from bot_api.controller.auth_controller import AuthController from bot_api.event.bot_api_on_ready_event import BotApiOnReadyEvent -from bot_api.mail.mail_thread import MailThread from bot_api.service.auth_service import AuthService from bot_api.service.discord_service import DiscordService from bot_core.abc.module_abc import ModuleABC @@ -38,7 +37,6 @@ class ApiModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_singleton(EMailClientABC, EMailClient) - services.add_singleton(MailThread) services.add_singleton(ApiThread) services.add_singleton(Flask, Api) diff --git a/kdb-bot/src/bot_api/mail/__init__.py b/kdb-bot/src/bot_api/mail/__init__.py deleted file mode 100644 index 11d03f7b..00000000 --- a/kdb-bot/src/bot_api/mail/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -bot Keksdose bot -~~~~~~~~~~~~~~~~~~~ - -Discord bot for the Keksdose discord Server - -:copyright: (c) 2022 sh-edraft.de -:license: MIT, see LICENSE for more details. - -""" - -__title__ = 'bot_api.mail' -__author__ = 'Sven Heidemann' -__license__ = 'MIT' -__copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '0.3.dev70' - -from collections import namedtuple - - -# imports - -VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='3', micro='dev70') diff --git a/kdb-bot/src/bot_api/mail/mail_thread.py b/kdb-bot/src/bot_api/mail/mail_thread.py deleted file mode 100644 index c6ae4c0b..00000000 --- a/kdb-bot/src/bot_api/mail/mail_thread.py +++ /dev/null @@ -1,23 +0,0 @@ -import threading -from typing import Optional - -from cpl_core.mailing import EMailClientABC, EMail - - -class MailThread(threading.Thread): - - def __init__(self, mailer: EMailClientABC): - threading.Thread.__init__(self, daemon=True) - - self._mailer = mailer - self._mail: Optional[EMail] = None - - def send_mail(self, mail: EMail): - self._mail = mail - self.start() - - def run(self) -> None: - if self._mailer is None: - return - - self._mailer.send_mail(self._mail) diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/kdb-bot/src/bot_api/service/auth_service.py index f6556c9b..4c9fcaf1 100644 --- a/kdb-bot/src/bot_api/service/auth_service.py +++ b/kdb-bot/src/bot_api/service/auth_service.py @@ -3,12 +3,13 @@ import re import textwrap import uuid from datetime import datetime, timedelta, timezone +from threading import Thread from typing import Optional import jwt from cpl_core.database.context import DatabaseContextABC from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.mailing import EMail +from cpl_core.mailing import EMail, EMailClientABC from cpl_core.utils import CredentialManager from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List @@ -22,7 +23,6 @@ from bot_api.exception.service_error_code_enum import ServiceErrorCode from bot_api.exception.service_exception import ServiceException from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria from bot_api.logging.api_logger import ApiLogger -from bot_api.mail.mail_thread import MailThread from bot_api.model.auth_user_dto import AuthUserDTO from bot_api.model.auth_user_filtered_result_dto import AuthUserFilteredResultDTO from bot_api.model.email_string_dto import EMailStringDTO @@ -37,7 +37,6 @@ from bot_data.abc.user_repository_abc import UserRepositoryABC from bot_data.model.auth_role_enum import AuthRoleEnum from bot_data.model.auth_user import AuthUser from bot_data.model.auth_user_users_relation import AuthUserUsersRelation -from bot_data.model.user import User _email_regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' @@ -53,7 +52,8 @@ class AuthService(AuthServiceABC): auth_users: AuthUserRepositoryABC, users: UserRepositoryABC, servers: ServerRepositoryABC, - mailer: MailThread, + # mailer: MailThread, + mailer: EMailClientABC, t: TranslatePipe, auth_settings: AuthenticationSettings, frontend_settings: FrontendSettings, @@ -152,6 +152,7 @@ class AuthService(AuthServiceABC): if not url.endswith('/'): url = f'{url}/' + self._mailer.connect() mail = EMail() mail.add_header('Mime-Version: 1.0') mail.add_header('Content-Type: text/plain; charset=utf-8') @@ -161,7 +162,9 @@ class AuthService(AuthServiceABC): mail.body = textwrap.dedent(f"""{message} {self._t.transform('api.mail.automatic_mail').format(self._environment.application_name, self._environment.environment_name, self._environment.host_name)} """) - self._mailer.send_mail(mail) + + thr = Thread(target=self._mailer.send_mail, args=[mail]) + thr.start() def _send_confirmation_id_to_user(self, user: AuthUser): url = self._frontend_settings.url diff --git a/kdb-web/package.json b/kdb-web/package.json index 3e8cf3d9..3e87f4ec 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,54 +1,54 @@ { - "name": "kdb-web", - "version": "0.3.dev70", - "scripts": { - "ng": "ng", - "update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts", - "prestart": "npm run update-version", - "start": "ng serve", - "prebuild": "npm run update-version", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test", - "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION .", - "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t kdb-web/kdb-web:$VERSION .", - "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t kdb-web/kdb-web:$VERSION ." - }, - "private": true, - "dependencies": { - "@angular/animations": "^14.0.0", - "@angular/common": "^14.0.0", - "@angular/compiler": "^14.0.0", - "@angular/core": "^14.0.0", - "@angular/forms": "^14.0.0", - "@angular/platform-browser": "^14.0.0", - "@angular/platform-browser-dynamic": "^14.0.0", - "@angular/router": "^14.0.0", - "@auth0/angular-jwt": "^5.1.0", - "@microsoft/signalr": "^6.0.9", - "@ngx-translate/core": "^14.0.0", - "@ngx-translate/http-loader": "^7.0.0", - "@types/socket.io-client": "^3.0.0", - "primeicons": "^6.0.1", - "primeng": "^14.1.2", - "rxjs": "~7.5.0", - "socket.io-client": "^4.5.3", - "tslib": "^2.3.0", - "zone.js": "~0.11.4" - }, - "devDependencies": { - "@angular-devkit/build-angular": "^14.0.0", - "@angular/cli": "~14.0.0", - "@angular/compiler-cli": "^14.0.0", - "@types/jasmine": "~4.0.0", - "@types/node": "^18.8.3", - "jasmine-core": "~4.1.0", - "karma": "~6.3.0", - "karma-chrome-launcher": "~3.1.0", - "karma-coverage": "~2.2.0", - "karma-jasmine": "~5.0.0", - "karma-jasmine-html-reporter": "~1.7.0", - "ts-node": "~8.3.0", - "typescript": "~4.7.2" - } -} + "name": "kdb-web", + "version": "0.3.dev70", + "scripts": { + "ng": "ng", + "update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts", + "prestart": "npm run update-version", + "start": "ng serve", + "prebuild": "npm run update-version", + "build": "ng build", + "watch": "ng build --watch --configuration development", + "test": "ng test", + "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION .", + "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t kdb-web/kdb-web:$VERSION .", + "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t kdb-web/kdb-web:$VERSION ." + }, + "private": true, + "dependencies": { + "@angular/animations": "^14.0.0", + "@angular/common": "^14.0.0", + "@angular/compiler": "^14.0.0", + "@angular/core": "^14.0.0", + "@angular/forms": "^14.0.0", + "@angular/platform-browser": "^14.0.0", + "@angular/platform-browser-dynamic": "^14.0.0", + "@angular/router": "^14.0.0", + "@auth0/angular-jwt": "^5.1.0", + "@microsoft/signalr": "^6.0.9", + "@ngx-translate/core": "^14.0.0", + "@ngx-translate/http-loader": "^7.0.0", + "@types/socket.io-client": "^3.0.0", + "primeicons": "^6.0.1", + "primeng": "^14.1.2", + "rxjs": "~7.5.0", + "socket.io-client": "^4.5.3", + "tslib": "^2.3.0", + "zone.js": "~0.11.4" + }, + "devDependencies": { + "@angular-devkit/build-angular": "^14.0.0", + "@angular/cli": "~14.0.0", + "@angular/compiler-cli": "^14.0.0", + "@types/jasmine": "~4.0.0", + "@types/node": "^18.8.3", + "jasmine-core": "~4.1.0", + "karma": "~6.3.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage": "~2.2.0", + "karma-jasmine": "~5.0.0", + "karma-jasmine-html-reporter": "~1.7.0", + "ts-node": "~8.3.0", + "typescript": "~4.7.2" + } +} \ No newline at end of file diff --git a/kdb-web/src/environments/environment.ts b/kdb-web/src/environments/environment.ts index beaecd40..1b1a28e3 100644 --- a/kdb-web/src/environments/environment.ts +++ b/kdb-web/src/environments/environment.ts @@ -4,7 +4,7 @@ export const environment = { production: false, - apiURL: "https://kdb_web_prod_1", + apiURL: "http://localhost:5000", }; /*