Skip to content

Commit d87248f

Browse files
Merge pull request #27632 from nextcloud/chore/caldav-trashbin-iso-timestamps
Use ISO8601 timestamps for the CalDAV trashbin
2 parents a52ed8e + 3a690b1 commit d87248f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

apps/dav/lib/CalDAV/Calendar.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
*/
2929
namespace OCA\DAV\CalDAV;
3030

31+
use DateTimeImmutable;
32+
use DateTimeInterface;
33+
use OCA\DAV\CalDAV\Trashbin\Plugin as TrashbinPlugin;
3134
use OCA\DAV\DAV\Sharing\IShareable;
3235
use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
3336
use OCP\IConfig;
@@ -63,6 +66,13 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable
6366
* @param IConfig $config
6467
*/
6568
public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config) {
69+
// Convert deletion date to ISO8601 string
70+
if (isset($calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT])) {
71+
$calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT] = (new DateTimeImmutable())
72+
->setTimestamp($calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT])
73+
->format(DateTimeInterface::ATOM);
74+
}
75+
6676
parent::__construct($caldavBackend, $calendarInfo);
6777

6878
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {

apps/dav/lib/CalDAV/Trashbin/Plugin.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
namespace OCA\DAV\CalDAV\Trashbin;
2727

2828
use Closure;
29+
use DateTimeImmutable;
30+
use DateTimeInterface;
2931
use OCA\DAV\CalDAV\Calendar;
3032
use OCA\DAV\CalDAV\RetentionService;
3133
use OCP\IRequest;
@@ -101,7 +103,14 @@ private function propFind(
101103
INode $node): void {
102104
if ($node instanceof DeletedCalendarObject) {
103105
$propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) {
104-
return $node->getDeletedAt();
106+
$ts = $node->getDeletedAt();
107+
if ($ts === null) {
108+
return null;
109+
}
110+
111+
return (new DateTimeImmutable())
112+
->setTimestamp($ts)
113+
->format(DateTimeInterface::ATOM);
105114
});
106115
$propFind->handle(self::PROPERTY_CALENDAR_URI, function () use ($node) {
107116
return $node->getCalendarUri();

0 commit comments

Comments
 (0)