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