Explorar o código

health: load caldav credentials from config; skip check when backend is not caldav

ZiB hai 4 meses
pai
achega
058cd146e0
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      room_cal/_health.py

+ 6 - 1
room_cal/_health.py

@@ -40,7 +40,12 @@ def get_cached() -> tuple[dict | None, bool]:
 
 async def caldav_checks(calendar_name: str = DEFAULT_CALENDAR_NAME) -> tuple[HealthResult, HealthResult]:
   """Open one CalDAV connection and run both the connection and calendar-exists checks."""
-  cal = Calendar(calendar_name)
+  from room_cal._utils import get_config
+  cfg = get_config()
+  if cfg.store.active != 'caldav':
+    return HealthResult(ok=True), HealthResult(ok=True)
+  cal_cfg = cfg.store.caldav
+  cal = Calendar(calendar_name, url=cal_cfg.url, username=cal_cfg.username, password=cal_cfg.password)
   try:
     async with await cal._client() as client:
       conn = HealthResult(ok=True)