bridges: resolve Nextcloud tasks to VTODO-capable lists
Task operations used the same calendar resolver as events, so a request that named (or defaulted to) an event-only calendar like "personal" put a VTODO into a collection that rejects it. Read each collection's CalDAV supported-calendar-component-set, expose it as `components` on /calendars, and add GET /tasklists (VTODO-capable calendars, minus Nextcloud Deck boards). _resolve_calendar is now component-aware: task routes only target a VTODO-capable list and reject an event-only calendar with a clear 400; with no name they try default_task_calendar, then default_calendar when it also accepts VTODO, then the sole user task list. Add the default_task_calendar config (top-level nextcloud_default_task_calendar fallback) and document the routes in the bridge catalog.
This commit is contained in:
1 parent
228886f7cd
commit
0005d8f7ee
6 files changed
+231
-20
No files matched your search
@@ -57,6 +57,23 @@ def _int(value, default=None):
|
||||
return default
|
||||
|
||||
|
||||
def _component_set(prop) -> list[str]:
|
||||
"""The component types a calendar accepts (`VEVENT`/`VTODO`/`VJOURNAL`).
|
||||
|
||||
Parsed from the CalDAV `supported-calendar-component-set` property. An empty
|
||||
list means the server did not advertise it (unknown), not "accepts nothing".
|
||||
"""
|
||||
node = prop.find(f"{{{CALDAV}}}supported-calendar-component-set")
|
||||
if node is None:
|
||||
return []
|
||||
names = []
|
||||
for comp in node.findall(f"{{{CALDAV}}}comp"):
|
||||
name = (comp.get("name") or "").strip().upper()
|
||||
if name:
|
||||
names.append(name)
|
||||
return names
|
||||
|
||||
|
||||
def _norm_path(path) -> str:
|
||||
"""A user-facing DAV path: always leading `/`, no trailing slash (root `/`)."""
|
||||
text = "/" + str(path or "").strip("/")
|
||||
@@ -457,6 +474,7 @@ _CALENDAR_PROPFIND = (
|
||||
'<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav" '
|
||||
'xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">'
|
||||
"<d:prop><d:resourcetype/><d:displayname/><c:calendar-description/>"
|
||||
"<c:supported-calendar-component-set/>"
|
||||
"<c:getctag/><oc:getctag/><nc:calendar-color/><oc:calendar-color/></d:prop>"
|
||||
"</d:propfind>"
|
||||
).encode("utf-8")
|
||||
@@ -860,6 +878,7 @@ class NextcloudClient:
|
||||
ctag = _text(prop.find(f"{{{CALDAV}}}getctag")) or _text(
|
||||
prop.find(f"{{{OC}}}getctag")
|
||||
)
|
||||
components = _component_set(prop)
|
||||
calendars.append(
|
||||
{
|
||||
"name": name,
|
||||
@@ -867,6 +886,7 @@ class NextcloudClient:
|
||||
"description": _text(prop.find(f"{{{CALDAV}}}calendar-description")),
|
||||
"color": color,
|
||||
"ctag": ctag,
|
||||
"components": components,
|
||||
}
|
||||
)
|
||||
calendars.sort(key=lambda calendar: calendar["name"].lower())
|
||||
|
||||
Reference in new issue
Block a user