sharing/bday/propfind: add mapping/handling support
This commit is contained in:
@@ -127,6 +127,10 @@ def xml_propfind_response(
|
||||
href.text = xmlutils.make_href(base_prefix, uri)
|
||||
response.append(href)
|
||||
|
||||
share_bday_automap = False
|
||||
if share and share['ShareType'] == "bday":
|
||||
share_bday_automap = True
|
||||
|
||||
if propname or allprop:
|
||||
props = []
|
||||
# Should list all properties that can be retrieved by the code below
|
||||
@@ -155,12 +159,16 @@ def xml_propfind_response(
|
||||
if is_collection:
|
||||
if is_leaf:
|
||||
props.append(xmlutils.make_clark("D:displayname"))
|
||||
props.append(xmlutils.make_clark("D:sync-token"))
|
||||
if collection.tag == "VCALENDAR":
|
||||
if share_bday_automap:
|
||||
# bday share has no sync-token support
|
||||
pass
|
||||
else:
|
||||
props.append(xmlutils.make_clark("D:sync-token"))
|
||||
if collection.tag == "VCALENDAR" or share_bday_automap:
|
||||
props.append(xmlutils.make_clark("CS:getctag"))
|
||||
props.append(
|
||||
xmlutils.make_clark("C:supported-calendar-component-set"))
|
||||
if collection.tag == "VADDRESSBOOK":
|
||||
if collection.tag == "VADDRESSBOOK" and not share_bday_automap:
|
||||
props.append(xmlutils.make_clark("CS:getctag"))
|
||||
props.append(
|
||||
xmlutils.make_clark("CR:supported-address-data"))
|
||||
@@ -205,6 +213,8 @@ def xml_propfind_response(
|
||||
if share:
|
||||
# backmap
|
||||
child_element.text = child_element.text.replace(share['PathMapped'], share['PathOrToken'])
|
||||
if share_bday_automap:
|
||||
child_element.text = child_element.text.rstrip(".vcf") + ".ics"
|
||||
element.append(child_element)
|
||||
elif tag == xmlutils.make_clark("C:supported-calendar-component-set"):
|
||||
human_tag = xmlutils.make_human_tag(tag)
|
||||
@@ -214,6 +224,9 @@ def xml_propfind_response(
|
||||
components = components_text.split(",")
|
||||
else:
|
||||
components = ["VTODO", "VEVENT", "VJOURNAL"]
|
||||
if share_bday_automap:
|
||||
# enforce VEVENT-only
|
||||
components = ["VEVENT"]
|
||||
for component in components:
|
||||
comp = ET.Element(xmlutils.make_clark("C:comp"))
|
||||
comp.set("name", component)
|
||||
@@ -221,7 +234,7 @@ def xml_propfind_response(
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("CR:supported-address-data"):
|
||||
if is_collection and is_leaf and collection.tag == "VADDRESSBOOK":
|
||||
if is_collection and is_leaf and collection.tag == "VADDRESSBOOK" and not share_bday_automap:
|
||||
# Advertise supported vCard versions per RFC 6352 section 6.2.2
|
||||
# vCard 4.0 requires vobject >= 1.0.0
|
||||
versions: Sequence[str] = (("4.0", "3.0")
|
||||
@@ -243,6 +256,8 @@ def xml_propfind_response(
|
||||
if share:
|
||||
# backmap
|
||||
child_element.text = child_element.text.replace(share['Owner'], share['User'])
|
||||
if share_bday_automap:
|
||||
child_element.text = child_element.text.rstrip(".vcf") + ".ics"
|
||||
element.append(child_element)
|
||||
else:
|
||||
element.append(ET.Element(
|
||||
@@ -254,7 +269,8 @@ def xml_propfind_response(
|
||||
if "P" in share['Permissions']:
|
||||
privileges.append("D:write-properties")
|
||||
if "w" in share['Permissions']:
|
||||
privileges.append("D:write-content")
|
||||
if not share_bday_automap:
|
||||
privileges.append("D:write-content")
|
||||
elif write:
|
||||
privileges.append("D:all")
|
||||
privileges.append("D:write")
|
||||
@@ -272,10 +288,10 @@ def xml_propfind_response(
|
||||
"D:principal-property-search"]
|
||||
if is_collection and is_leaf:
|
||||
reports.append("D:sync-collection")
|
||||
if collection.tag == "VADDRESSBOOK":
|
||||
if collection.tag == "VADDRESSBOOK" and not share_bday_automap:
|
||||
reports.append("CR:addressbook-multiget")
|
||||
reports.append("CR:addressbook-query")
|
||||
elif collection.tag == "VCALENDAR":
|
||||
elif collection.tag == "VCALENDAR" or share_bday_automap:
|
||||
reports.append("C:calendar-multiget")
|
||||
reports.append("C:calendar-query")
|
||||
for human_tag in reports:
|
||||
@@ -306,6 +322,9 @@ def xml_propfind_response(
|
||||
if is_leaf:
|
||||
element.text = xmlutils.MIMETYPES[
|
||||
collection.tag]
|
||||
if share_bday_automap:
|
||||
# overwrite
|
||||
element.text = xmlutils.MIMETYPES["VCALENDAR"]
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("D:resourcetype"):
|
||||
@@ -314,11 +333,11 @@ def xml_propfind_response(
|
||||
xmlutils.make_clark("D:principal"))
|
||||
element.append(child_element)
|
||||
if is_leaf:
|
||||
if collection.tag == "VADDRESSBOOK":
|
||||
if collection.tag == "VADDRESSBOOK" and not share_bday_automap:
|
||||
child_element = ET.Element(
|
||||
xmlutils.make_clark("CR:addressbook"))
|
||||
element.append(child_element)
|
||||
elif collection.tag == "VCALENDAR":
|
||||
elif collection.tag == "VCALENDAR" or share_bday_automap:
|
||||
child_element = ET.Element(
|
||||
xmlutils.make_clark("C:calendar"))
|
||||
element.append(child_element)
|
||||
@@ -335,6 +354,8 @@ def xml_propfind_response(
|
||||
displayname = share['Properties']["D:displayname"]
|
||||
if displayname is not None:
|
||||
element.text = displayname
|
||||
if share_bday_automap:
|
||||
element.text += " (BDAY)"
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("RADICALE:getcontentcount"):
|
||||
@@ -351,6 +372,8 @@ def xml_propfind_response(
|
||||
displayname = collection.path
|
||||
if displayname is not None:
|
||||
element.text = displayname
|
||||
if share_bday_automap:
|
||||
element.text += " (BDAY)"
|
||||
else:
|
||||
is404 = True
|
||||
elif tag == xmlutils.make_clark("CS:getctag"):
|
||||
|
||||
Reference in New Issue
Block a user