Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix settings #44

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Config: # noqa: WPS431

@validator("BOT_CREDENTIALS", pre=True)
@classmethod
def parse_bot_credentials(cls, raw_credentials: Any) -> list[BotAccountWithSecret]:
def parse_bot_credentials(cls, raw_credentials: str) -> list[BotAccountWithSecret]:
"""Parse bot credentials separated by comma.

Each entry must be separated by "@" or "|".
Expand All @@ -40,10 +40,16 @@ def _build_credentials_from_string(
credentials_str = credentials_str.replace("|", "@")
assert credentials_str.count("@") == 2, "Have you forgot to add `bot_id`?"

host, secret_key, bot_id = [
cts_url, secret_key, bot_id = [
str_value.strip() for str_value in credentials_str.split("@")
]
return BotAccountWithSecret(id=UUID(bot_id), host=host, secret_key=secret_key)

if "://" not in cts_url:
cts_url = f"https://{cts_url}"

return BotAccountWithSecret(
id=UUID(bot_id), cts_url=cts_url, secret_key=secret_key
)


settings = AppSettings()
Loading