From: Thomas Müller Date: Thu, 21 Jan 2016 15:20:52 +0000 (+0100) Subject: Reassemble behavior on shared address books with respect to uri and displayname X-Git-Tag: v9.0beta1~188^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7b678a8c1702aaf4bfdbb0df598b8a83e383484e;p=nextcloud-server.git Reassemble behavior on shared address books with respect to uri and displayname --- diff --git a/apps/dav/appinfo/database.xml b/apps/dav/appinfo/database.xml index 50c8aa7d8ca..4221e590fa5 100644 --- a/apps/dav/appinfo/database.xml +++ b/apps/dav/appinfo/database.xml @@ -655,10 +655,6 @@ CREATE TABLE calendarobjects ( true 11 - - uri - text - principaluri text @@ -685,7 +681,7 @@ CREATE TABLE calendarobjects ( principaluri - uri + resourceid type diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml index d9eefaefcf1..3a38feab59e 100644 --- a/apps/dav/appinfo/info.xml +++ b/apps/dav/appinfo/info.xml @@ -5,7 +5,7 @@ ownCloud WebDAV endpoint AGPL owncloud.org - 0.1.3 + 0.1.4 diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php index 44164e61259..28f6099b639 100644 --- a/apps/dav/lib/carddav/carddavbackend.php +++ b/apps/dav/lib/carddav/carddavbackend.php @@ -24,6 +24,7 @@ namespace OCA\DAV\CardDAV; +use Doctrine\DBAL\Connection; use OCA\DAV\Connector\Sabre\Principal; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -31,6 +32,7 @@ use Sabre\CardDAV\Backend\BackendInterface; use Sabre\CardDAV\Backend\SyncSupport; use Sabre\CardDAV\Plugin; use Sabre\DAV\Exception\BadRequest; +use Sabre\HTTP\URLUtil; use Sabre\VObject\Component\VCard; use Sabre\VObject\Reader; @@ -113,7 +115,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $principals[]= $principalUri; $query = $this->db->getQueryBuilder(); - $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.uri', 's.access']) + $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access']) ->from('dav_shares', 's') ->join('s', 'addressbooks', 'a', $query->expr()->eq('s.resourceid', 'a.id')) ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri'))) @@ -123,11 +125,14 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->execute(); while($row = $result->fetch()) { + list(, $name) = URLUtil::splitPath($row['principaluri']); + $uri = $row['uri'] . '_shared_by_' . $name; + $displayName = $row['displayname'] . "($name)"; $addressBooks[] = [ 'id' => $row['id'], - 'uri' => $row['uri'], + 'uri' => $uri, 'principaluri' => $principalUri, - '{DAV:}displayname' => $row['displayname'], + '{DAV:}displayname' => $displayName, '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', @@ -826,12 +831,10 @@ class CardDavBackend implements BackendInterface, SyncSupport { $access = $element['readOnly'] ? self::ACCESS_READ : self::ACCESS_READ_WRITE; } - $newUri = sha1($addressBook->getName() . $addressBook->getOwner()); $query = $this->db->getQueryBuilder(); $query->insert('dav_shares') ->values([ 'principaluri' => $query->createNamedParameter($parts[1]), - 'uri' => $query->createNamedParameter($newUri), 'type' => $query->createNamedParameter('addressbook'), 'access' => $query->createNamedParameter($access), 'resourceid' => $query->createNamedParameter($addressBook->getBookId()) diff --git a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml index 046c3d59dbd..37b4941b9f1 100644 --- a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml +++ b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml @@ -78,7 +78,7 @@ xmlElementMatch parent - $multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/ade1a55d408167e8ff77611c0eebe8f80579b549/] + $multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/addressbook_shared_by_user01/] exists