Skip to content

Commit

Permalink
config routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Cosentino committed Dec 15, 2023
1 parent 09b3737 commit 96c15f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions api/routers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def post_config(self, config_schema: ConfigSchema) -> BaseResponse:

# validate the config with pydantic
try:
_ = ConfigYAMLSchema(**config_schema.config.dict())
_ = ConfigYAMLSchema(**config_schema.config.model_dump())
except ValidationError as exc:
for error in exc.errors():
logger.error(error)
Expand All @@ -262,7 +262,7 @@ async def post_config(self, config_schema: ConfigSchema) -> BaseResponse:

with open(config_file_name, "w", encoding="utf-8") as new_config_file:
yaml.dump(
config_schema.config.dict(),
config_schema.config.model_dump(),
new_config_file,
allow_unicode=False,
encoding="utf-8",
Expand Down
10 changes: 5 additions & 5 deletions bridge/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import yaml

# from pydantic import RootModel # pylint: disable=import-error
from pydantic import SecretStr # pylint: disable=import-error
# from pydantic import SecretStr # pylint: disable=import-error
from pydantic import BaseModel, StrictInt, model_validator, validator

_instances: Dict[str, "Config"] = {}
Expand Down Expand Up @@ -226,7 +226,7 @@ class TelegramConfig(BaseModel): # pylint: disable=too-few-public-methods
"""Telegram config."""

phone: str
password: SecretStr
password: str
api_id: StrictInt
api_hash: str
log_unhandled_dialogs: bool = False
Expand All @@ -237,9 +237,9 @@ class TelegramConfig(BaseModel): # pylint: disable=too-few-public-methods
class Config:
"""Telegram config."""

json_encoders = {
SecretStr: lambda val: val.get_secret_value(),
}
# json_encoders = {
# SecretStr: lambda val: val.get_secret_value(),
# }

@validator("api_hash")
def api_hash_alphanumeric(cls, val):
Expand Down

0 comments on commit 96c15f2

Please sign in to comment.