diff options
author | Mario <mario@mariovavti.com> | 2021-03-24 19:27:44 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-24 19:41:20 +0000 |
commit | 14186f5c1811765133f0d1c04568f87e56aab9c4 (patch) | |
tree | 099f457fb97945916a875130c72dc761cdf14f71 | |
parent | 4964a32c55e05e86242ec430eb89d018f2b9639f (diff) | |
download | volse-hubzilla-14186f5c1811765133f0d1c04568f87e56aab9c4.tar.gz volse-hubzilla-14186f5c1811765133f0d1c04568f87e56aab9c4.tar.bz2 volse-hubzilla-14186f5c1811765133f0d1c04568f87e56aab9c4.zip |
cdav: fix regression - sync code was messing with caldav/carddav discovery
-rw-r--r-- | Zotlabs/Module/Cdav.php | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index a6cab8639..a7d2b1169 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -151,15 +151,15 @@ class Cdav extends Controller { if($channel['channel_timezone']) $auth->setTimezone($channel['channel_timezone']); $auth->observer = $channel['channel_hash']; - } - else - $channel = channelx_by_nick(argv(2)); - $principalUri = 'principals/' . $channel['channel_address']; - if(! cdav_principal($principalUri)) { - $this->activate($pdo, $channel); - if(! cdav_principal($principalUri)) - return; + $principalUri = 'principals/' . $channel['channel_address']; + if(! cdav_principal($principalUri)) { + $this->activate($pdo, $channel); + if(! cdav_principal($principalUri)) { + return; + } + } + } // Track CDAV updates from remote clients @@ -168,6 +168,8 @@ class Cdav extends Controller { if($httpmethod === 'PUT' || $httpmethod === 'DELETE') { + $channel = channelx_by_nick(argv(2)); + $principalUri = 'principals/' . $channel['channel_address']; $httpuri = $_SERVER['REQUEST_URI']; logger("debug: method: " . $httpmethod, LOGGER_DEBUG); @@ -181,8 +183,9 @@ class Cdav extends Controller { $sync = 'calendar'; $cdavtable = 'calendarinstances'; } - else + else { $sync = false; + } if($sync) { @@ -194,11 +197,10 @@ class Cdav extends Controller { if($x = get_cdav_id($principalUri, argv(3), $cdavtable)) { $cdavdata = $this->get_cdav_data($x['id'], $cdavtable); - $etag = (isset($_SERVER['HTTP_IF_MATCH']) ? $_SERVER['HTTP_IF_MATCH'] : false); // delete - if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag) + if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag) { Libsync::build_sync_packet($channel['channel_id'], [ $sync => [ 'action' => 'delete_card', @@ -206,18 +208,18 @@ class Cdav extends Controller { 'carduri' => $uri ] ]); + } else { - if($etag) { + if($etag && $cdavdata['etag'] !== $etag) { // update - if($cdavdata['etag'] !== $etag) - Libsync::build_sync_packet($channel['channel_id'], [ - $sync => [ - 'action' => 'update_card', - 'uri' => $cdavdata['uri'], - 'carduri' => $uri, - 'card' => $httpbody - ] - ]); + Libsync::build_sync_packet($channel['channel_id'], [ + $sync => [ + 'action' => 'update_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri, + 'card' => $httpbody + ] + ]); } else { // new @@ -235,7 +237,6 @@ class Cdav extends Controller { } } - $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo); $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); |