aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-10-27 11:54:57 +0200
committerMorris Jobke <hey@morrisjobke.de>2018-11-01 15:00:49 +0100
commit9afff2fb20ec2c00cc958639342add7b19a00e78 (patch)
treef62f179c2cdbae88987173e051dbc4dfdb7317b9 /apps/dav
parent06b3ade9ee3ee1c384cc5061a63fcc5e3c405721 (diff)
downloadnextcloud-server-9afff2fb20ec2c00cc958639342add7b19a00e78.tar.gz
nextcloud-server-9afff2fb20ec2c00cc958639342add7b19a00e78.zip
Properly set uid and create and update
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index a2d3b03147b..a9d65f2f0f9 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -494,7 +494,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*/
function getCards($addressBookId) {
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
->from('cards')
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
@@ -525,7 +525,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*/
function getCard($addressBookId, $cardUri) {
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
->from('cards')
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
@@ -563,7 +563,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$cards = [];
$query = $this->db->getQueryBuilder();
- $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata'])
+ $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
->from('cards')
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
@@ -609,6 +609,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*/
function createCard($addressBookId, $cardUri, $cardData) {
$etag = md5($cardData);
+ $uid = $this->getUID($cardData);
$query = $this->db->getQueryBuilder();
$query->insert('cards')
@@ -619,6 +620,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'addressbookid' => $query->createNamedParameter($addressBookId),
'size' => $query->createNamedParameter(strlen($cardData)),
'etag' => $query->createNamedParameter($etag),
+ 'uid' => $query->createNamedParameter($uid),
])
->execute();
@@ -661,6 +663,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*/
function updateCard($addressBookId, $cardUri, $cardData) {
+ $uid = $this->getUID($cardData);
$etag = md5($cardData);
$query = $this->db->getQueryBuilder();
$query->update('cards')
@@ -668,6 +671,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
->set('lastmodified', $query->createNamedParameter(time()))
->set('size', $query->createNamedParameter(strlen($cardData)))
->set('etag', $query->createNamedParameter($etag))
+ ->set('uid', $query->createNamedParameter($uid))
->where($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
->execute();
@@ -1125,4 +1129,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
}
}
+
+ private function getUID($cardData) {
+ $vCard = Reader::read($cardData);
+ $uid = $vCard->UID->getValue();
+ return $uid;
+ }
}