aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-24 19:27:44 +0000
committerMario <mario@mariovavti.com>2021-03-24 19:27:44 +0000
commit44593a3c8d21a744772a267d57bd4ed26127629f (patch)
treee59dfca694c9f4835de5721084a7601a50046c22
parent3d4ad94dccd3f3b0ee7b77408ca1c293b30fd922 (diff)
downloadvolse-hubzilla-44593a3c8d21a744772a267d57bd4ed26127629f.tar.gz
volse-hubzilla-44593a3c8d21a744772a267d57bd4ed26127629f.tar.bz2
volse-hubzilla-44593a3c8d21a744772a267d57bd4ed26127629f.zip
cdav: fix regression - sync code was messing with caldav/carddav discovery
-rw-r--r--Zotlabs/Module/Cdav.php45
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);