Fix minor bugs

This commit is contained in:
PapaTutuWawa 2025-04-21 18:06:21 +02:00
parent d35a077730
commit 401de2484b
2 changed files with 5 additions and 9 deletions

View File

@ -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":

View File

@ -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)]