Merge branch 'webcal'

This commit is contained in:
Tobias Manske 2022-12-12 17:22:52 +01:00
commit 18dcb2bd43
Signed by: tobias
GPG Key ID: E83C743C1FC2F79A
3 changed files with 17 additions and 4 deletions

View File

@ -85,7 +85,7 @@ def xml_propfind_response(
if isinstance(item, storage.BaseCollection): if isinstance(item, storage.BaseCollection):
is_collection = True is_collection = True
is_leaf = item.tag in ("VADDRESSBOOK", "VCALENDAR") is_leaf = item.tag in ("VADDRESSBOOK", "VCALENDAR", "VSUBSCRIBED")
collection = item collection = item
# Some clients expect collections to end with `/` # Some clients expect collections to end with `/`
uri = pathutils.unstrip_path(item.path, True) uri = pathutils.unstrip_path(item.path, True)
@ -259,6 +259,10 @@ def xml_propfind_response(
child_element = ET.Element( child_element = ET.Element(
xmlutils.make_clark("C:calendar")) xmlutils.make_clark("C:calendar"))
element.append(child_element) element.append(child_element)
elif item.get_meta("tag") == "VSUBSCRIBED":
child_element = ET.Element(
xmlutils.make_clark("CS:subscribed"))
element.append(child_element)
child_element = ET.Element(xmlutils.make_clark("D:collection")) child_element = ET.Element(xmlutils.make_clark("D:collection"))
element.append(child_element) element.append(child_element)
elif tag == xmlutils.make_clark("RADICALE:displayname"): elif tag == xmlutils.make_clark("RADICALE:displayname"):
@ -286,6 +290,14 @@ def xml_propfind_response(
element.text, _ = collection.sync() element.text, _ = collection.sync()
else: else:
is404 = True is404 = True
elif tag == xmlutils.make_clark("CS:source"):
if is_leaf:
child_element = ET.Element(xmlutils.make_clark("D:href"))
child_element.text = item.get_meta('CS:source')
element.append(child_element)
else:
is404 = True
else: else:
human_tag = xmlutils.make_human_tag(tag) human_tag = xmlutils.make_human_tag(tag)
tag_text = collection.get_meta(human_tag) tag_text = collection.get_meta(human_tag)

View File

@ -91,7 +91,7 @@ def check_and_sanitize_items(
The ``tag`` of the collection. The ``tag`` of the collection.
""" """
if tag and tag not in ("VCALENDAR", "VADDRESSBOOK"): if tag and tag not in ("VCALENDAR", "VADDRESSBOOK", "VSUBSCRIBED"):
raise ValueError("Unsupported collection tag: %r" % tag) raise ValueError("Unsupported collection tag: %r" % tag)
if not is_collection and len(vobject_items) != 1: if not is_collection and len(vobject_items) != 1:
raise ValueError("Item contains %d components" % len(vobject_items)) raise ValueError("Item contains %d components" % len(vobject_items))
@ -230,7 +230,7 @@ def check_and_sanitize_props(props: MutableMapping[Any, Any]
raise ValueError("Value of %r must be %r not %r: %r" % ( raise ValueError("Value of %r must be %r not %r: %r" % (
k, str.__name__, type(v).__name__, v)) k, str.__name__, type(v).__name__, v))
if k == "tag": if k == "tag":
if v not in ("", "VCALENDAR", "VADDRESSBOOK"): if v not in ("", "VCALENDAR", "VADDRESSBOOK", "VSUBSCRIBED"):
raise ValueError("Unsupported collection tag: %r" % v) raise ValueError("Unsupported collection tag: %r" % v)
return props return props

View File

@ -33,7 +33,8 @@ from radicale import item, pathutils
MIMETYPES: Mapping[str, str] = { MIMETYPES: Mapping[str, str] = {
"VADDRESSBOOK": "text/vcard", "VADDRESSBOOK": "text/vcard",
"VCALENDAR": "text/calendar"} "VCALENDAR": "text/calendar",
"VSUBSCRIBED": "text/calendar"}
OBJECT_MIMETYPES: Mapping[str, str] = { OBJECT_MIMETYPES: Mapping[str, str] = {
"VCARD": "text/vcard", "VCARD": "text/vcard",