Add check for vCard uid
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
cba3883410
commit
b6d8c5ff2f
|
@ -611,6 +611,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$etag = md5($cardData);
|
$etag = md5($cardData);
|
||||||
$uid = $this->getUID($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 = $this->db->getQueryBuilder();
|
||||||
$query->insert('cards')
|
$query->insert('cards')
|
||||||
->values([
|
->values([
|
||||||
|
|
Loading…
Reference in New Issue