mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-09 18:33:14 +02:00
refactor(api_endpoints): improve sqlite_handler retrieval logic
- Updated the logic for retrieving the sqlite_handler in APIEndpoints to use a safer approach with getattr, ensuring compatibility with the daemon_instance. - Adjusted test case to include an additional parameter in the sqlite.companion_push_message assertion for consistency.
This commit is contained in:
@@ -3551,8 +3551,13 @@ class APIEndpoints:
|
||||
"settings": comp_settings,
|
||||
}
|
||||
sqlite_handler = None
|
||||
if self.repeater_handler and self.repeater_handler.storage:
|
||||
sqlite_handler = self.repeater_handler.storage.sqlite_handler
|
||||
repeater_handler = (
|
||||
getattr(self.daemon_instance, "repeater_handler", None)
|
||||
if self.daemon_instance
|
||||
else None
|
||||
)
|
||||
if repeater_handler and getattr(repeater_handler, "storage", None):
|
||||
sqlite_handler = repeater_handler.storage.sqlite_handler
|
||||
if sqlite_handler and identity_key:
|
||||
try:
|
||||
validate_companion_config_capacity(
|
||||
@@ -3786,8 +3791,13 @@ class APIEndpoints:
|
||||
return self._error(str(e))
|
||||
|
||||
sqlite_handler = None
|
||||
if self.repeater_handler and self.repeater_handler.storage:
|
||||
sqlite_handler = self.repeater_handler.storage.sqlite_handler
|
||||
repeater_handler = (
|
||||
getattr(self.daemon_instance, "repeater_handler", None)
|
||||
if self.daemon_instance
|
||||
else None
|
||||
)
|
||||
if repeater_handler and getattr(repeater_handler, "storage", None):
|
||||
sqlite_handler = repeater_handler.storage.sqlite_handler
|
||||
if sqlite_handler and identity.get("identity_key"):
|
||||
try:
|
||||
validate_companion_config_capacity(
|
||||
|
||||
Reference in New Issue
Block a user