sharing/report,propfind: change from type bday to conversion
This commit is contained in:
@@ -73,11 +73,11 @@ def xml_propfind(base_prefix: str, path: str,
|
|||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/PROPFIND/xml_propfind: shares=%r", shares)
|
logger.debug("TRACE/PROPFIND/xml_propfind: shares=%r", shares)
|
||||||
|
|
||||||
for item, permission, sharetype in allowed_items:
|
for item, permission, conversion in allowed_items:
|
||||||
write = permission == "w"
|
write = permission == "w"
|
||||||
multistatus.append(xml_propfind_response(
|
multistatus.append(xml_propfind_response(
|
||||||
base_prefix, path, item, props, user, encoding, write=write,
|
base_prefix, path, item, props, user, encoding, write=write,
|
||||||
allprop=allprop, propname=propname, max_resource_size=max_resource_size, shares=shares, sharetype=sharetype))
|
allprop=allprop, propname=propname, max_resource_size=max_resource_size, shares=shares, conversion=conversion))
|
||||||
|
|
||||||
return multistatus
|
return multistatus
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ def xml_propfind(base_prefix: str, path: str,
|
|||||||
def xml_propfind_response(
|
def xml_propfind_response(
|
||||||
base_prefix: str, path: str, item: types.CollectionOrItem,
|
base_prefix: str, path: str, item: types.CollectionOrItem,
|
||||||
props: Sequence[str], user: str, encoding: str, max_resource_size: int, write: bool = False,
|
props: Sequence[str], user: str, encoding: str, max_resource_size: int, write: bool = False,
|
||||||
propname: bool = False, allprop: bool = False, shares: dict = {}, sharetype: Union[str, None] = None) -> ET.Element:
|
propname: bool = False, allprop: bool = False, shares: dict = {}, conversion: Union[str, None] = None) -> ET.Element:
|
||||||
"""Build and return a PROPFIND response."""
|
"""Build and return a PROPFIND response."""
|
||||||
if propname and allprop or (props and (propname or allprop)):
|
if propname and allprop or (props and (propname or allprop)):
|
||||||
raise ValueError("Only use one of props, propname and allprops")
|
raise ValueError("Only use one of props, propname and allprops")
|
||||||
@@ -109,7 +109,7 @@ def xml_propfind_response(
|
|||||||
# lookup share
|
# lookup share
|
||||||
share = None
|
share = None
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/PROPFIND/xml_propfind: sharetype=%r item.path=%r", sharetype, uri)
|
logger.debug("TRACE/PROPFIND/xml_propfind: conversion=%r item.path=%r", conversion, uri)
|
||||||
for entry in shares:
|
for entry in shares:
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/PROPFIND/xml_propfind: check entry=%r", entry)
|
logger.debug("TRACE/PROPFIND/xml_propfind: check entry=%r", entry)
|
||||||
@@ -117,7 +117,7 @@ def xml_propfind_response(
|
|||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/PROPFIND/xml_propfind: PathMapped=%r uri=%r", shares[entry]['PathMapped'], uri)
|
logger.debug("TRACE/PROPFIND/xml_propfind: PathMapped=%r uri=%r", shares[entry]['PathMapped'], uri)
|
||||||
if uri.startswith(shares[entry]['PathMapped']):
|
if uri.startswith(shares[entry]['PathMapped']):
|
||||||
if sharetype is not None and shares[entry]['ShareType'] == sharetype:
|
if conversion is not None and shares[entry]['Conversion'] == conversion:
|
||||||
share = shares[entry]
|
share = shares[entry]
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/PROPFIND/xml_propfind: found share=%r", share)
|
logger.debug("TRACE/PROPFIND/xml_propfind: found share=%r", share)
|
||||||
@@ -549,7 +549,7 @@ class ApplicationPartPropfind(ApplicationBase):
|
|||||||
if share['Conversion'] == "bday" and not isinstance(item, storage.BaseCollection):
|
if share['Conversion'] == "bday" and not isinstance(item, storage.BaseCollection):
|
||||||
if not item.convert_vcf_to_ics():
|
if not item.convert_vcf_to_ics():
|
||||||
continue
|
continue
|
||||||
allowed_items.append((item, permission, share['ShareType']))
|
allowed_items.append((item, permission, share['Conversion']))
|
||||||
else:
|
else:
|
||||||
allowed_items.append((item, permission, None))
|
allowed_items.append((item, permission, None))
|
||||||
if self._sharing._enabled:
|
if self._sharing._enabled:
|
||||||
@@ -577,7 +577,7 @@ class ApplicationPartPropfind(ApplicationBase):
|
|||||||
c_items_iter = iter(self._storage.discover(c_path, "0"))
|
c_items_iter = iter(self._storage.discover(c_path, "0"))
|
||||||
c_allowed_items = list(self._collect_allowed_items(c_items_iter, c_user))
|
c_allowed_items = list(self._collect_allowed_items(c_items_iter, c_user))
|
||||||
for item, permission in c_allowed_items:
|
for item, permission in c_allowed_items:
|
||||||
allowed_items.append((item, permission, share['ShareType']))
|
allowed_items.append((item, permission, share['Conversion']))
|
||||||
shares[c_share] = share
|
shares[c_share] = share
|
||||||
|
|
||||||
headers = {"DAV": httputils.DAV_HEADERS,
|
headers = {"DAV": httputils.DAV_HEADERS,
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|||||||
logger.debug("TRACE/REPORT/xml_report: base_prefix=%r path=%r", base_prefix, path)
|
logger.debug("TRACE/REPORT/xml_report: base_prefix=%r path=%r", base_prefix, path)
|
||||||
|
|
||||||
share_bday_automap = False
|
share_bday_automap = False
|
||||||
if share and share['ShareType'] == "bday":
|
if share and share['Conversion'] == "bday":
|
||||||
share_bday_automap = True
|
share_bday_automap = True
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
logger.debug("TRACE/REPORT/xml_report(1): share=%r", share)
|
logger.debug("TRACE/REPORT/xml_report(1): share=%r", share)
|
||||||
@@ -263,7 +263,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|||||||
collection_tag = collection.tag
|
collection_tag = collection.tag
|
||||||
# !!! Don't access storage after this !!!
|
# !!! Don't access storage after this !!!
|
||||||
unlock_storage_fn()
|
unlock_storage_fn()
|
||||||
if share and share['ShareType'] == "bday":
|
if share and share['Conversion'] == "bday":
|
||||||
collection_tag = "VCALENDAR"
|
collection_tag = "VCALENDAR"
|
||||||
# autoconvert
|
# autoconvert
|
||||||
retrieved_items_vcf_to_ics = []
|
retrieved_items_vcf_to_ics = []
|
||||||
@@ -740,7 +740,7 @@ def xml_item_response(base_prefix: str, href: str,
|
|||||||
logger.debug("TRACE/REPORT/xml_item_response: found=%s share=%r", found_item, share)
|
logger.debug("TRACE/REPORT/xml_item_response: found=%s share=%r", found_item, share)
|
||||||
|
|
||||||
share_bday_automap = False
|
share_bday_automap = False
|
||||||
if share and share['ShareType'] == "bday":
|
if share and share['Conversion'] == "bday":
|
||||||
share_bday_automap = True
|
share_bday_automap = True
|
||||||
|
|
||||||
href_element = ET.Element(xmlutils.make_clark("D:href"))
|
href_element = ET.Element(xmlutils.make_clark("D:href"))
|
||||||
@@ -793,7 +793,7 @@ def retrieve_items(
|
|||||||
if share:
|
if share:
|
||||||
# map back to owner
|
# map back to owner
|
||||||
hreference = hreference.replace(share['PathOrToken'], share['PathMapped'])
|
hreference = hreference.replace(share['PathOrToken'], share['PathMapped'])
|
||||||
if share['ShareType'] == "bday":
|
if share['Conversion'] == "bday":
|
||||||
if not hreference.endswith('/'):
|
if not hreference.endswith('/'):
|
||||||
hreference = hreference.rstrip(".ics") + ".vcf"
|
hreference = hreference.rstrip(".ics") + ".vcf"
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user