Skip to content

Commit 9abf9c8

Browse files
wrvsrxWhyNotHugo
authored andcommitted
Add an option to use vCard 4.0
Fix pimutils#503
1 parent 0f0e5b9 commit 9abf9c8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

vdirsyncer/storage/dav.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,21 @@ class CardDAVStorage(DAVStorage):
894894
item_mimetype = "text/vcard"
895895
discovery_class = CardDiscover
896896

897-
get_multi_template = """<?xml version="1.0" encoding="utf-8" ?>
897+
def __init__(self, *args, use_vcard_4=False, **kwargs):
898+
self.use_vcard_4 = use_vcard_4
899+
super().__init__(*args, **kwargs)
900+
901+
@property
902+
def get_multi_template(self):
903+
ct = 'Content-Type="text/vcard" version="4.0"' if self.use_vcard_4 else ""
904+
return f"""<?xml version="1.0" encoding="utf-8" ?>
898905
<C:addressbook-multiget xmlns="DAV:"
899906
xmlns:C="urn:ietf:params:xml:ns:carddav">
900907
<prop>
901908
<getetag/>
902-
<C:address-data/>
909+
<C:address-data {ct}/>
903910
</prop>
904-
{hrefs}
911+
{{hrefs}}
905912
</C:addressbook-multiget>"""
906913

907914
get_multi_data_query = "{urn:ietf:params:xml:ns:carddav}address-data"

0 commit comments

Comments
 (0)