Expose calendar-uri as property of deleted caldav events
The trashbin is one report across all calendars of a user. In order to refresh the data of a single calendar when one of its events is restored, we need to know what calendar the event belongs to. There doesn't seem to be a standard property for a URI, so this adds a custom Nextcloud prop for the calendar-uri. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
b908db7ac8
commit
462962197d
|
@ -1101,6 +1101,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
public function getDeletedCalendarObjectsByPrincipal(string $principalUri): array {
|
public function getDeletedCalendarObjectsByPrincipal(string $principalUri): array {
|
||||||
$query = $this->db->getQueryBuilder();
|
$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'])
|
$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')
|
->from('calendarobjects', 'co')
|
||||||
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
|
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
|
||||||
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
|
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
|
||||||
|
@ -1111,10 +1112,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['co.uri'],
|
||||||
'lastmodified' => $row['lastmodified'],
|
'lastmodified' => $row['lastmodified'],
|
||||||
'etag' => '"' . $row['etag'] . '"',
|
'etag' => '"' . $row['etag'] . '"',
|
||||||
'calendarid' => $row['calendarid'],
|
'calendarid' => $row['calendarid'],
|
||||||
|
'calendaruri' => $row['calendaruri'],
|
||||||
'size' => (int)$row['size'],
|
'size' => (int)$row['size'],
|
||||||
'component' => strtolower($row['componenttype']),
|
'component' => strtolower($row['componenttype']),
|
||||||
'classification' => (int)$row['classification'],
|
'classification' => (int)$row['classification'],
|
||||||
|
@ -2139,6 +2141,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
public function getCalendarObjectById(string $principalUri, int $id): ?array {
|
public function getCalendarObjectById(string $principalUri, int $id): ?array {
|
||||||
$query = $this->db->getQueryBuilder();
|
$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'])
|
$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')
|
->from('calendarobjects', 'co')
|
||||||
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
|
->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
|
||||||
->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)))
|
->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)))
|
||||||
|
@ -2153,10 +2156,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['c.uri'],
|
||||||
'lastmodified' => $row['lastmodified'],
|
'lastmodified' => $row['lastmodified'],
|
||||||
'etag' => '"' . $row['etag'] . '"',
|
'etag' => '"' . $row['etag'] . '"',
|
||||||
'calendarid' => $row['calendarid'],
|
'calendarid' => $row['calendarid'],
|
||||||
|
'calendaruri' => $row['calendaruri'],
|
||||||
'size' => (int)$row['size'],
|
'size' => (int)$row['size'],
|
||||||
'calendardata' => $this->readBlob($row['calendardata']),
|
'calendardata' => $this->readBlob($row['calendardata']),
|
||||||
'component' => strtolower($row['componenttype']),
|
'component' => strtolower($row['componenttype']),
|
||||||
|
|
|
@ -97,4 +97,8 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable {
|
||||||
public function getDeletedAt(): ?int {
|
public function getDeletedAt(): ?int {
|
||||||
return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
|
return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCalendarUri(): string {
|
||||||
|
return $this->objectData['calendaruri'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ use function implode;
|
||||||
|
|
||||||
class Plugin extends ServerPlugin {
|
class Plugin extends ServerPlugin {
|
||||||
public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
|
public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
|
||||||
|
public const PROPERTY_CALENDAR_URI = '{http://nextcloud.com/ns}calendar-uri';
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $disableTrashbin;
|
private $disableTrashbin;
|
||||||
|
@ -95,6 +96,9 @@ class Plugin extends ServerPlugin {
|
||||||
$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
|
$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
|
||||||
return $node->getDeletedAt();
|
return $node->getDeletedAt();
|
||||||
});
|
});
|
||||||
|
$propFind->handle(self::PROPERTY_CALENDAR_URI, function () use ($node) {
|
||||||
|
return $node->getCalendarUri();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue