Skip to content

Commit c68f50b

Browse files
committed
DAV: AppCalendar fix creating events by also query filename
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
1 parent 272af9c commit c68f50b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

apps/dav/lib/CalDAV/AppCalendar/AppCalendar.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,13 @@ public function childExists($name): bool {
141141
}
142142

143143
public function getChild($name) {
144-
$pos = strrpos($name, '.ics');
145-
$children = $this->calendar->search(substr($name, 0, $pos === false ? null : $pos), ['UID'], [], 1);
144+
// Try to get calendar by filename
145+
$children = $this->calendar->search($name, ['X-FILENAME'], [], 1);
146+
if (count($children) === 0) {
147+
// If nothing found try to get by UID from filename
148+
$pos = strrpos($name, '.ics');
149+
$children = $this->calendar->search(substr($name, 0, $pos ?: null), ['UID'], [], 1);
150+
}
146151

147152
if (count($children) > 0) {
148153
return new CalendarObject($this, $this->calendar, $children[0]);

apps/dav/lib/CalDAV/AppCalendar/CalendarObject.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public function getName(): string {
105105
if ($base === null) {
106106
throw new NotFound('Invalid node');
107107
}
108+
if (isset($base['X-FILENAME'])) {
109+
return (string)$base['X-FILENAME'];
110+
}
108111
return (string)$base->UID . '.ics';
109112
}
110113

0 commit comments

Comments
 (0)