Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,7 @@
use Sabre\VObject\ParseException;
use Sabre\VObject\Reader;
use Sabre\VObject\Splitter\ICalendar;
use Sabre\VObject\UUIDUtil;
use function count;

class RefreshWebcalService {
Expand DownExpand Up@@ -113,15 +114,13 @@ public function refreshSubscription(string $principalUri, string $uri) {

while ($vObject = $splitter->getNext()) {
/** @var Component $vObject */
$uid = null;
$compName = null;

foreach ($vObject->getComponents() as $component) {
if ($component->name === 'VTIMEZONE') {
continue;
}

$uid = $component->{'UID'}->getValue();
$compName = $component->name;

if ($stripAlarms) {
Expand All@@ -136,7 +135,7 @@ public function refreshSubscription(string $principalUri, string $uri) {
continue;
}

$uri = $uid . '.ics';
$uri = $this->getRandomCalendarObjectUri();
$calendarData = $vObject->serialize();
try {
$this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
Expand DownExpand Up@@ -413,4 +412,13 @@ private function cleanURL(string $url) {

return $cleanURL;
}

/**
* Returns a random uri for a calendar-object
*
* @return string
*/
public function getRandomCalendarObjectUri():string {
return UUIDUtil::getUUID() . '.ics';
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,8 +69,14 @@ protected function setUp(): void {
* @dataProvider runDataProvider
*/
public function testRun(string $body, string $contentType, string $result) {
$refreshWebcalService = new RefreshWebcalService($this->caldavBackend,
$this->clientService, $this->config, $this->logger);
$refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
->setMethods(['getRandomCalendarObjectUri'])
->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
->getMock();

$refreshWebcalService
->method('getRandomCalendarObjectUri')
->willReturn('uri-1.ics');

$this->caldavBackend->expects($this->once())
->method('getSubscriptionsForUser')
Expand DownExpand Up@@ -130,7 +136,7 @@ public function testRun(string $body, string $contentType, string $result) {

$this->caldavBackend->expects($this->once())
->method('createCalendarObject')
->with(42, '12345.ics', $result, 1);
->with(42, 'uri-1.ics', $result, 1);

$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
Expand Down