Skip to content

Commit

Permalink
Use ISO8601 timestamps for the CalDAV trashbin
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Jun 23, 2021
1 parent 35fe1df commit 5d63a23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
namespace OCA\DAV\CalDAV;

use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use OCA\DAV\AppInfo\Application;
use OCA\DAV\Connector\Sabre\Principal;
use OCA\DAV\DAV\Sharing\Backend;
Expand Down
7 changes: 7 additions & 0 deletions apps/dav/lib/CalDAV/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
namespace OCA\DAV\CalDAV;

use DateTimeImmutable;
use DateTimeInterface;
use OCA\DAV\DAV\Sharing\IShareable;
use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
use OCP\IConfig;
Expand Down Expand Up @@ -63,6 +65,11 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable
* @param IConfig $config
*/
public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config) {
// Convert deletion date to ISO8601 string
if (isset($calendarInfo[\OCA\DAV\CalDAV\Trashbin\Plugin::PROPERTY_DELETED_AT])) {
$calendarInfo[\OCA\DAV\CalDAV\Trashbin\Plugin::PROPERTY_DELETED_AT] = (new DateTimeImmutable('@' . $calendarInfo[\OCA\DAV\CalDAV\Trashbin\Plugin::PROPERTY_DELETED_AT]))->format(DateTimeInterface::ATOM);
}

parent::__construct($caldavBackend, $calendarInfo);

if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
Expand Down
9 changes: 8 additions & 1 deletion apps/dav/lib/CalDAV/Trashbin/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
namespace OCA\DAV\CalDAV\Trashbin;

use Closure;
use DateTimeImmutable;
use DateTimeInterface;
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\RetentionService;
use OCP\IRequest;
Expand Down Expand Up @@ -101,7 +103,12 @@ private function propFind(
INode $node): void {
if ($node instanceof DeletedCalendarObject) {
$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
return $node->getDeletedAt();
$ts = $node->getDeletedAt();
if ($ts === null) {
return null;
}

return (new DateTimeImmutable('@' . $ts))->format(DateTimeInterface::ATOM);
});
$propFind->handle(self::PROPERTY_CALENDAR_URI, function () use ($node) {
return $node->getCalendarUri();
Expand Down

0 comments on commit 5d63a23

Please sign in to comment.