Skip to content

Commit 3c10d42

Browse files
committed
Added support for webcal-subscriptions
1 parent 6ae831a commit 3c10d42

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

radicale/app/propfind.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def xml_propfind_response(
8585

8686
if isinstance(item, storage.BaseCollection):
8787
is_collection = True
88-
is_leaf = item.tag in ("VADDRESSBOOK", "VCALENDAR")
88+
is_leaf = item.tag in ("VADDRESSBOOK", "VCALENDAR", "VSUBSCRIBED")
8989
collection = item
9090
# Some clients expect collections to end with `/`
9191
uri = pathutils.unstrip_path(item.path, True)
@@ -259,6 +259,10 @@ def xml_propfind_response(
259259
child_element = ET.Element(
260260
xmlutils.make_clark("C:calendar"))
261261
element.append(child_element)
262+
elif item.get_meta("tag") == "VSUBSCRIBED":
263+
child_element = ET.Element(
264+
xmlutils.make_clark("CS:subscribed"))
265+
element.append(child_element)
262266
child_element = ET.Element(xmlutils.make_clark("D:collection"))
263267
element.append(child_element)
264268
elif tag == xmlutils.make_clark("RADICALE:displayname"):
@@ -286,6 +290,13 @@ def xml_propfind_response(
286290
element.text, _ = collection.sync()
287291
else:
288292
is404 = True
293+
elif tag == xmlutils.make_clark("CS:source"):
294+
if is_leaf:
295+
child_element = ET.Element(xmlutils.make_clark("D:href"))
296+
child_element.text = item.get_meta('CS:source')
297+
element.append(child_element)
298+
else:
299+
is404 = True
289300
else:
290301
human_tag = xmlutils.make_human_tag(tag)
291302
tag_text = collection.get_meta(human_tag)

radicale/item/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def check_and_sanitize_items(
9191
The ``tag`` of the collection.
9292
9393
"""
94-
if tag and tag not in ("VCALENDAR", "VADDRESSBOOK"):
94+
if tag and tag not in ("VCALENDAR", "VADDRESSBOOK", "VSUBSCRIBED"):
9595
raise ValueError("Unsupported collection tag: %r" % tag)
9696
if not is_collection and len(vobject_items) != 1:
9797
raise ValueError("Item contains %d components" % len(vobject_items))
@@ -230,7 +230,7 @@ def check_and_sanitize_props(props: MutableMapping[Any, Any]
230230
raise ValueError("Value of %r must be %r not %r: %r" % (
231231
k, str.__name__, type(v).__name__, v))
232232
if k == "tag":
233-
if v not in ("", "VCALENDAR", "VADDRESSBOOK"):
233+
if v not in ("", "VCALENDAR", "VADDRESSBOOK", "VSUBSCRIBED"):
234234
raise ValueError("Unsupported collection tag: %r" % v)
235235
return props
236236

radicale/xmlutils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
MIMETYPES: Mapping[str, str] = {
3535
"VADDRESSBOOK": "text/vcard",
36-
"VCALENDAR": "text/calendar"}
36+
"VCALENDAR": "text/calendar",
37+
"VSUBSCRIBED": "text/calendar"}
3738

3839
OBJECT_MIMETYPES: Mapping[str, str] = {
3940
"VCARD": "text/vcard",

0 commit comments

Comments
 (0)