Z-Push with Synology DSM 6.2
-
Hi, I’ve set up Z-Push on a Raspberry Pi to talk to my Synology NAS running DSM 6.2. I can get all my emails just fine but neither contacts or calendar. I’ve done copious debug output in carddav.php and I believe what is happening is that discoverAddressbooks is failing to return my address book.
Based on the output from curl:<?xml version="1.0" encoding="utf-8"?> <multistatus xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:CR="urn:ietf:params:xml:ns:carddav" xmlns:ns3="http://inf-it.com/ns/ab/"> <response> <href>/carddav/donald/</href> <propstat> <prop> <principal-collection-set> <href>/carddav/</href> </principal-collection-set> <current-user-principal> <href>/carddav/donald/</href> </current-user-principal> <current-user-privilege-set> <privilege> <read/> </privilege> <privilege> <all/> </privilege> <privilege> <write/> </privilege> <privilege> <write-properties/> </privilege> <privilege> <write-content/> </privilege> </current-user-privilege-set> <supported-report-set> <supported-report> <report> <expand-property/> </report> </supported-report> <supported-report> <report> <principal-search-property-set/> </report> </supported-report> <supported-report> <report> <principal-property-search/> </report> </supported-report> </supported-report-set> <resourcetype> <principal/> <collection/> </resourcetype> <owner> <href>/carddav/donald/</href> </owner> <C:calendar-user-address-set> <href>/carddav/donald/</href> </C:calendar-user-address-set> <principal-URL> <href>/carddav/donald/</href> </principal-URL> <CR:addressbook-home-set> <href>/carddav/donald/</href> </CR:addressbook-home-set> <C:calendar-home-set> <href>/carddav/donald/</href> </C:calendar-home-set> </prop> <status>HTTP/1.1 200 OK</status> </propstat> </response> <response> <href>/carddav/donald/8468987e-691a-4b68-8836-a092dcd405f0/</href> <propstat> <prop> <principal-collection-set> <href>/carddav/</href> </principal-collection-set> <current-user-principal> <href>/carddav/donald/</href> </current-user-principal> <current-user-privilege-set> <privilege> <read/> </privilege> <privilege> <all/> </privilege> <privilege> <write/> </privilege> <privilege> <write-properties/> </privilege> <privilege> <write-content/> </privilege> </current-user-privilege-set> <supported-report-set> <supported-report> <report> <expand-property/> </report> </supported-report> <supported-report> <report> <principal-search-property-set/> </report> </supported-report> <supported-report> <report> <principal-property-search/> </report> </supported-report> <supported-report> <report> <sync-collection/> </report> </supported-report> <supported-report> <report> <CR:addressbook-multiget/> </report> </supported-report> <supported-report> <report> <CR:addressbook-query/> </report> </supported-report> </supported-report-set> <resourcetype> <CR:addressbook/> <collection/> </resourcetype> <owner> <href>/carddav/donald/</href> </owner> <getetag>"1_4657"</getetag> <getlastmodified>Tue, 22 Dec 2020 17:15:51 GMT</getlastmodified> <getcontenttype>text/vcard</getcontenttype> <getcontentlength>823</getcontentlength> <displayname>My Contacts</displayname> <sync-token>http://radicale.org/ns/sync/1_4657</sync-token> <CR:addressbook-description/> <ns3:addressbook-color/> </prop> <status>HTTP/1.1 200 OK</status> </propstat> </response> <response> <href>/carddav/donald/217887c5-2e6f-431b-a838-1f209159b5c4/</href> <propstat> <prop> <principal-collection-set> <href>/carddav/</href> </principal-collection-set> <current-user-principal> <href>/carddav/donald/</href> </current-user-principal> <current-user-privilege-set> <privilege> <read/> </privilege> <privilege> <all/> </privilege> <privilege> <write/> </privilege> <privilege> <write-properties/> </privilege> <privilege> <write-content/> </privilege> </current-user-privilege-set> <supported-report-set> <supported-report> <report> <expand-property/> </report> </supported-report> <supported-report> <report> <principal-search-property-set/> </report> </supported-report> <supported-report> <report> <principal-property-search/> </report> </supported-report> <supported-report> <report> <sync-collection/> </report> </supported-report> <supported-report> <report> <CR:addressbook-multiget/> </report> </supported-report> <supported-report> <report> <CR:addressbook-query/> </report> </supported-report> </supported-report-set> <resourcetype> <CR:addressbook/> <collection/> </resourcetype> <owner> <href>/carddav/donald/</href> </owner> <getetag>"16_0"</getetag> <getlastmodified>Thu, 18 Mar 2021 17:51:10 GMT</getlastmodified> <getcontenttype>text/vcard</getcontenttype> <getcontentlength>0</getcontentlength> <displayname>GAB</displayname> <sync-token>http://radicale.org/ns/sync/16_0</sync-token> <CR:addressbook-description/> <ns3:addressbook-color/> </prop> <status>HTTP/1.1 200 OK</status> </propstat> </response> </multistatus>
I’ve configured these values in config.php
define('CARDDAV_PATH', '/carddav/%u/'); define('CARDDAV_DEFAULT_PATH', '/carddav/%u/');
The addressbook is 8468987e-691a-4b68-8836-a092dcd405f0 but I never seem to enter the loop
foreach ($xml->addressbook_element as $response) {
Does anyone know if I’ve mis-configured the default path? It seems right based on the output from curl.
If not, then any other hints appreciated thank you.
Donald -
@dwp Replying to myself. It turns out that the generic code doesn’t handle the XML returned by Synology.
xml = SimpleXMLElement Object ( [element] => SimpleXMLElement Object ( [id] => 8468987e-691a-4b68-8836-a092dcd405f0 [etag] => 1_4728 [last_modified] => Tue, 22 Dec 2020 17:15:51 GMT ) )
I have therefore modified the function discoverAddressbooks() with
foreach ($xml->element as $response) { $this->addressbooks[] = sprintf("%s%s/",$this->default_url,$response->id);
and am now syncing contacts. Sorry the code isn’t something that can be patched back into the mainline.
If anyone wants to also have calendars working then the config line should be
define('CALDAV_PATH', '/caldav.php/%u/');
-
So the include/z_caldav.php code does not work to determine the calendars on the Synology either. I made the following changes, which I think should work generically, to fix the problem:
628,631c628,630 < // not sure why this is here but doesn't seem to work and doesn't find principal/skip it < // if ( !isset($calendar_urls[$href]) ) { < // continue; < // } --- > if ( !isset($calendar_urls[$href]) ) { > continue; > } 634d632 < $flag = true; 647,649d644 < case 'DAV::principal': < $flag = false; < break; 652,655c647,648 < if ( $flag == true) { < $calendar->id = rtrim(str_replace($this->calendar_home_set[0], "", $calendar->url), "/"); < $calendars[] = $calendar; < } --- > $calendar->id = rtrim(str_replace($this->calendar_home_set[0], "", $calendar->url), "/"); > $calendars[] = $calendar;
-
Hey Can you show the complete modified files?
I want to use z-Push with DSM 7 and contacts and calendar.