|
|
@@ -1210,25 +1210,28 @@ async def hermes_standalone_sender_fn(
|
|
|
"""
|
|
|
|
|
|
chatto_config: ChattoConfiguration = ChattoConfiguration(pconfig=pconfig)
|
|
|
-
|
|
|
- # Create a temporary client for standalone sending
|
|
|
- client: ChattoClient
|
|
|
|
|
|
- if not chatto_config.base_url.value or (not (chatto_config.login.value or not chatto_config.password.value) or not chatto_config.token.value):
|
|
|
+ # Create a temporary client for standalone sending — we need a base URL plus
|
|
|
+ # either a token or a full login/password pair.
|
|
|
+ has_credentials = bool(
|
|
|
+ chatto_config.token.value
|
|
|
+ or (chatto_config.login.value and chatto_config.password.value)
|
|
|
+ )
|
|
|
+ if not chatto_config.base_url.value or not has_credentials:
|
|
|
return SendResult(success=False, error="Chatto: base URL or credentials missing")
|
|
|
-
|
|
|
- try:
|
|
|
+
|
|
|
+ client: ChattoClient
|
|
|
+ try:
|
|
|
if chatto_config.token.value:
|
|
|
client = ChattoClient(base_url=chatto_config.base_url.value, token=chatto_config.token.value)
|
|
|
else:
|
|
|
- if chatto_config.login.value and chatto_config.password.value:
|
|
|
- client = await ChattoClient.login(
|
|
|
- base_url=chatto_config.base_url.value, login=chatto_config.login.value, password=chatto_config.password.value,
|
|
|
- )
|
|
|
- except (Exception, ValueError) as exc:
|
|
|
+ client = await ChattoClient.login(
|
|
|
+ base_url=chatto_config.base_url.value,
|
|
|
+ login=chatto_config.login.value,
|
|
|
+ password=chatto_config.password.value,
|
|
|
+ )
|
|
|
+ except Exception as exc:
|
|
|
return SendResult(success=False, error=f"Chatto login failed: {exc}")
|
|
|
- finally:
|
|
|
- logger.debug("Chatto standalone client: {client}")
|
|
|
|
|
|
try:
|
|
|
kwargs: Dict[str, Any] = {}
|
|
|
@@ -1245,7 +1248,9 @@ async def hermes_standalone_sender_fn(
|
|
|
try:
|
|
|
await client.close()
|
|
|
except Exception as exc:
|
|
|
- logger.error("Chatto standalone: error closing short-lived client. Perhaps already closed. {exc}")
|
|
|
+ logger.error(
|
|
|
+ "Chatto standalone: error closing short-lived client (perhaps already closed): %s", exc,
|
|
|
+ )
|
|
|
|
|
|
|
|
|
def hermes_validate_config(config: PlatformConfig) -> bool:
|