diff options
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index a8907f631cd..eb94885d177 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -611,6 +611,19 @@ class CardDavBackend implements BackendInterface, SyncSupport { $etag = md5($cardData); $uid = $this->getUID($cardData); + $q = $this->db->getQueryBuilder(); + $q->select('uid') + ->from('cards') + ->where($q->expr()->eq('addressbookid', $q->createNamedParameter($addressBookId))) + ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid))) + ->setMaxResults(1); + $result = $q->execute(); + $count = (bool) $result->fetchColumn(); + $result->closeCursor(); + if ($count) { + throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.'); + } + $query = $this->db->getQueryBuilder(); $query->insert('cards') ->values([ |