فهرست منبع

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

ZiB 4 ماه پیش
والد
کامیت
058cd146e0
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  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)