diff options
author | Georg Ehrke <developer@georgehrke.com> | 2017-11-01 22:00:53 +0100 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2017-11-06 14:25:08 +0100 |
commit | 4df08f296b6242f9df7b1fc729801b7bd221be25 (patch) | |
tree | 0a949a966aebf9c7c364f6a1c690a871bff24e2b /apps/dav/lib/CalDAV/CalDavBackend.php | |
parent | db48575d326f807b641c4769c5c283207611cf67 (diff) | |
download | nextcloud-server-4df08f296b6242f9df7b1fc729801b7bd221be25.tar.gz nextcloud-server-4df08f296b6242f9df7b1fc729801b7bd221be25.zip |
ensure uid for calendar objects is unique
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib/CalDAV/CalDavBackend.php')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 2c34f6d6d31..4947d401560 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -957,6 +957,20 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription function createCalendarObject($calendarId, $objectUri, $calendarData) { $extraData = $this->getDenormalizedData($calendarData); + $q = $this->db->getQueryBuilder(); + $q->select($q->createFunction('COUNT(*)')) + ->from('calendarobjects') + ->where($q->expr()->eq('calendarid', $q->createNamedParameter($calendarId))) + ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($extraData['uid']))); + + $result = $q->execute(); + $count = (int) $result->fetchColumn(); + $result->closeCursor(); + + if ($count !== 0) { + throw new \Sabre\DAV\Exception\BadRequest('Calendar object with uid already exists in this calendar collection.'); + } + $query = $this->db->getQueryBuilder(); $query->insert('calendarobjects') ->values([ |