From 401de2484b15a3d8ce06eaefea637656cc5c0dc0 Mon Sep 17 00:00:00 2001 From: Alexander PapaTutuWawa Date: Mon, 21 Apr 2025 18:06:21 +0200 Subject: [PATCH] Fix minor bugs --- src/xmpp_api/api/routers/v1/bot.py | 8 ++------ src/xmpp_api/config/config.py | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/xmpp_api/api/routers/v1/bot.py b/src/xmpp_api/api/routers/v1/bot.py index 1800378..fb6d6e3 100644 --- a/src/xmpp_api/api/routers/v1/bot.py +++ b/src/xmpp_api/api/routers/v1/bot.py @@ -98,12 +98,8 @@ async def post_create_bot_jid( # Query the JID for its type allowed_jid_type: JIDType if creation_request.type is None: - jid_type = await component.get_entity_type(parsed_jid) - if jid_type is None: - raise HTTPException( - status_code=500, - detail=f"Failed to query entity at {creation_request.jid}", - ) + # Assume that it is a direct-type bot if we cannot query anything + jid_type = await component.get_entity_type(parsed_jid) or "account" match jid_type: case "account": diff --git a/src/xmpp_api/config/config.py b/src/xmpp_api/config/config.py index 3f9b347..66354fb 100644 --- a/src/xmpp_api/config/config.py +++ b/src/xmpp_api/config/config.py @@ -1,5 +1,5 @@ import os -from typing import Annotated, Any, Self, cast +from typing import Annotated, Any, Generator, Self, cast import logging from pydantic import BaseModel, Field, model_validator @@ -86,7 +86,7 @@ class _Config(BaseModel): component: _ComponentConfig -def load_config() -> _Config: +def load_config() -> Generator[_Config]: """ Load the application config """ @@ -111,7 +111,7 @@ def load_config() -> _Config: with open(config.database.uri_file, "r", encoding="utf8") as f: config.database.uri_plain = f.read().strip().replace("\n", "") - return config + yield config ConfigDep = Annotated[_Config, Depends(load_config)]