Add ICS calendar support
All checks were successful
Build And Test / publish (push) Successful in 48s
All checks were successful
Build And Test / publish (push) Successful in 48s
This commit is contained in:
@@ -33,6 +33,8 @@ class Settings(BaseSettings):
|
||||
caldav_url: Optional[str] = Field(default=None, alias="CALDAV_URL")
|
||||
caldav_username: Optional[str] = Field(default=None, alias="CALDAV_USERNAME")
|
||||
caldav_password: Optional[SecretStr] = Field(default=None, alias="CALDAV_PASSWORD")
|
||||
ics_calendars: Optional[str] = Field(default=None, alias="ICS_CALENDARS")
|
||||
ics_calendar_timeout: int = Field(default=20, alias="ICS_CALENDAR_TIMEOUT")
|
||||
|
||||
# CardDAV Configuration
|
||||
carddav_url: Optional[str] = Field(default=None, alias="CARDDAV_URL")
|
||||
@@ -107,7 +109,7 @@ class Settings(BaseSettings):
|
||||
self.smtp_from_email,
|
||||
])
|
||||
|
||||
def is_calendar_configured(self) -> bool:
|
||||
def is_caldav_configured(self) -> bool:
|
||||
return all([
|
||||
self.enable_calendar,
|
||||
self.caldav_url,
|
||||
@@ -115,6 +117,33 @@ class Settings(BaseSettings):
|
||||
self.caldav_password,
|
||||
])
|
||||
|
||||
def is_calendar_configured(self) -> bool:
|
||||
return all([
|
||||
self.enable_calendar,
|
||||
(self.is_caldav_configured() or self.get_ics_calendars()),
|
||||
])
|
||||
|
||||
def get_ics_calendars(self) -> list[tuple[Optional[str], str]]:
|
||||
if not self.ics_calendars:
|
||||
return []
|
||||
|
||||
calendars: list[tuple[Optional[str], str]] = []
|
||||
for entry in self.ics_calendars.split(","):
|
||||
item = entry.strip()
|
||||
if not item:
|
||||
continue
|
||||
if "|" in item:
|
||||
name, url = item.split("|", 1)
|
||||
name = name.strip() or None
|
||||
url = url.strip()
|
||||
else:
|
||||
name = None
|
||||
url = item
|
||||
if url:
|
||||
calendars.append((name, url))
|
||||
|
||||
return calendars
|
||||
|
||||
def is_contacts_configured(self) -> bool:
|
||||
return all([
|
||||
self.enable_contacts,
|
||||
|
||||
Reference in New Issue
Block a user