Skip to content

Commit

Permalink
Merge pull request #27310 from nextcloud/enhancement/caldav-trashbin-…
Browse files Browse the repository at this point in the history
…objects-calendar-id

Expose calendar-uri as property of deleted caldav events
  • Loading branch information
ChristophWurst authored May 31, 2021
2 parents b908db7 + 4629621 commit 4fc002a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ public function getDeletedCalendarObjects(int $deletedBefore): array {
public function getDeletedCalendarObjectsByPrincipal(string $principalUri): array {
$query = $this->db->getQueryBuilder();
$query->select(['co.id', 'co.uri', 'co.lastmodified', 'co.etag', 'co.calendarid', 'co.size', 'co.componenttype', 'co.classification', 'co.deleted_at'])
->selectAlias('c.uri', 'calendaruri')
->from('calendarobjects', 'co')
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
Expand All @@ -1111,10 +1112,11 @@ public function getDeletedCalendarObjectsByPrincipal(string $principalUri): arra
while ($row = $stmt->fetch()) {
$result[] = [
'id' => $row['id'],
'uri' => $row['uri'],
'uri' => $row['co.uri'],
'lastmodified' => $row['lastmodified'],
'etag' => '"' . $row['etag'] . '"',
'calendarid' => $row['calendarid'],
'calendaruri' => $row['calendaruri'],
'size' => (int)$row['size'],
'component' => strtolower($row['componenttype']),
'classification' => (int)$row['classification'],
Expand Down Expand Up @@ -2139,6 +2141,7 @@ public function getCalendarObjectByUID($principalUri, $uid) {
public function getCalendarObjectById(string $principalUri, int $id): ?array {
$query = $this->db->getQueryBuilder();
$query->select(['co.id', 'co.uri', 'co.lastmodified', 'co.etag', 'co.calendarid', 'co.size', 'co.calendardata', 'co.componenttype', 'co.classification', 'co.deleted_at'])
->selectAlias('c.uri', 'calendaruri')
->from('calendarobjects', 'co')
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)))
Expand All @@ -2153,10 +2156,11 @@ public function getCalendarObjectById(string $principalUri, int $id): ?array {

return [
'id' => $row['id'],
'uri' => $row['uri'],
'uri' => $row['c.uri'],
'lastmodified' => $row['lastmodified'],
'etag' => '"' . $row['etag'] . '"',
'calendarid' => $row['calendarid'],
'calendaruri' => $row['calendaruri'],
'size' => (int)$row['size'],
'calendardata' => $this->readBlob($row['calendardata']),
'component' => strtolower($row['componenttype']),
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@ public function restore(): void {
public function getDeletedAt(): ?int {
return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
}

public function getCalendarUri(): string {
return $this->objectData['calendaruri'];
}
}
4 changes: 4 additions & 0 deletions apps/dav/lib/CalDAV/Trashbin/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

class Plugin extends ServerPlugin {
public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
public const PROPERTY_CALENDAR_URI = '{http://nextcloud.com/ns}calendar-uri';

/** @var bool */
private $disableTrashbin;
Expand Down Expand Up @@ -95,6 +96,9 @@ private function propFind(
$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
return $node->getDeletedAt();
});
$propFind->handle(self::PROPERTY_CALENDAR_URI, function () use ($node) {
return $node->getCalendarUri();
});
}
}

Expand Down

0 comments on commit 4fc002a

Please sign in to comment.