Code: Select all
response: Dict[str, Any] | None = None
try:
response = self.client.post("url/", data=payload)
if not response or not response.get("ok"):
logger.warning(
"[MessageService sync_chat] " +
"Server responded without confirmation (ok=False) for chat '%s'",
chat.chat_id
)
return {"status": SyncStatus.NOT_CONFIRMED}
self._mark_messages_as_synced(messages)
logger.info(
"[MessageService sync_chat] " +
"Synced %d messages for chat '%s'",
len(incoming_messages), chat.chat_id
)
return {'response': response, 'status': SyncStatus.SUCCESS}
except Exception as e:
logger.warning(
"[MessageService sync_chat] " + "Skipping chat '%s' due to error: %s\nResponse: %s",
chat.chat_id, str(e)
)
return {"status": SyncStatus.ERROR, "reason": str(e)}
< /code>
Und irgendwie habe ich in diesem Try-Except-Block einen Fehler erhalten: < /p>
WARNING [MessageService sync_chat] Skipping chat '7925606@c.us' due to error:
cannot access local variable 'response' where it is not associated with a value