feat(calendar): list external read-only (subscribed) calendars

list_calendars only kept PROPFIND responses whose resourcetype was
<c:calendar>, so external subscriptions (webcal/ICS feeds) — exposed by
Nextcloud as <cs:subscribed> collections — were silently dropped and never
appeared in nc_calendar_list_calendars (issue #830).

- Construct the calendar DAV client with `X-NC-CalDAV-Webcal-Caching: On` so
  Nextcloud exposes subscriptions as queryable CachedSubscription calendars,
  making their events readable through the existing event/search tools (the
  same mechanism Evolution/KDE desktop clients use).
- In list_calendars, override that header to "Off" so subscriptions are
  returned as cs:subscribed collections with their cs:source href, then parse
  responses whose resourcetype is c:calendar OR cs:subscribed. Subscriptions
  are reported with read_only=True and their source feed URL; their color is
  read from the Apple iCal namespace as a fallback.
- Send the custom PROPFIND markup via `body=` instead of `props=`: under
  caldav 3.x `props=` expects a list of property names and discards a raw XML
  string, producing an empty <prop/>. This also restores display_name,
  description and color which were previously falling back to defaults.
- Add `read_only` and `source` fields to the Calendar model.

Adds unit tests for subscription parsing, the body/header wiring, and the
webcal-caching header; extends the integration test to assert the new fields.
This commit is contained in:
Janis Jansons
2026-06-02 18:58:16 +03:00
parent 7e4b83dc94
commit 921c521628
5 changed files with 257 additions and 49 deletions
+5 -2
View File
@@ -20,7 +20,7 @@
The server provides comprehensive calendar integration through CalDAV, enabling you to:
- List all available calendars
- List all available calendars, including external read-only subscriptions
- Create, read, update, and delete calendar events
- Handle recurring events with RRULE support
- Manage event reminders and notifications
@@ -31,7 +31,10 @@ The server provides comprehensive calendar integration through CalDAV, enabling
**Usage Examples:**
```python
# List available calendars
# List available calendars. External subscriptions (webcal/ICS feeds) are
# included and reported with read_only=True and a `source` URL pointing at the
# upstream feed. Their events are readable through the normal event tools, but
# attempts to modify them will be rejected by Nextcloud.
calendars = await nc_calendar_list_calendars()
# Create a simple event