forked from sh-edraft.de/sh_discord_bot
Made api async #70
This commit is contained in:
parent
aab3d62365
commit
e8c491a478
@ -47,6 +47,7 @@ class Application(DiscordBotApplicationABC):
|
||||
self._api.start()
|
||||
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.api_only):
|
||||
self._api.join()
|
||||
return
|
||||
|
||||
self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}')
|
||||
|
@ -14,7 +14,7 @@ class ApiThread(threading.Thread):
|
||||
api: Api,
|
||||
feature_flags: FeatureFlagsSettings
|
||||
):
|
||||
threading.Thread.__init__(self, daemon=not feature_flags.get_flag(FeatureFlagsEnum.api_only))
|
||||
threading.Thread.__init__(self, daemon=True)
|
||||
|
||||
self._logger = logger
|
||||
self._api = api
|
||||
|
@ -17,7 +17,7 @@
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core==2022.10.0.post6",
|
||||
"Flask==2.2.2",
|
||||
"Flask[async]==2.2.2",
|
||||
"Flask-Classful==0.14.2"
|
||||
],
|
||||
"DevDependencies": [
|
||||
|
@ -33,13 +33,13 @@ class ApiController:
|
||||
self._mailer = mailer
|
||||
|
||||
@Route.route('/api/api-version')
|
||||
def api_version(self):
|
||||
async def api_version(self):
|
||||
import bot_api
|
||||
version = bot_api.version_info
|
||||
return VersionDTO(version.major, version.minor, version.micro).to_dict()
|
||||
|
||||
@Route.route('/api/settings')
|
||||
def settings(self):
|
||||
async def settings(self):
|
||||
# TODO: Authentication
|
||||
import bot_api
|
||||
version = bot_api.version_info
|
||||
@ -60,7 +60,7 @@ class ApiController:
|
||||
).to_dict()
|
||||
|
||||
@Route.route('/api/send-test-mail/<email>')
|
||||
def send_test_mail(self, email: str):
|
||||
async def send_test_mail(self, email: str):
|
||||
# TODO: Authentication
|
||||
mail = EMail()
|
||||
mail.add_header('Mime-Version: 1.0')
|
||||
|
Loading…
Reference in New Issue
Block a user