Skip to content
Merged
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
12 changes: 10 additions & 2 deletions lib/DAV/CalendarPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

class CalendarPlugin implements ICalendarProvider {

private const USER_PRINCIPAL_PREFIX = 'principals/users/';

/** @var DeckCalendarBackend */
private $backend;
/** @var ConfigService */
Expand All @@ -33,7 +35,7 @@ public function getAppId(): string {
}

public function fetchAllForCalendarHome(string $principalUri): array {
if (!$this->calendarIntegrationEnabled) {
if (!$this->calendarIntegrationEnabled || !$this->isOwnCalendarHome($principalUri)) {
return [];
}

Expand All @@ -46,7 +48,7 @@ public function fetchAllForCalendarHome(string $principalUri): array {
}

public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool {
if (!$this->calendarIntegrationEnabled) {
if (!$this->calendarIntegrationEnabled || !$this->isOwnCalendarHome($principalUri)) {
return false;
}

Expand All @@ -71,4 +73,10 @@ public function getCalendarInCalendarHome(string $principalUri, string $calendar
}
return null;
}

private function isOwnCalendarHome(string $principalUri): bool {
$userId = $this->configService->getUserId();

return $userId !== null && $principalUri === self::USER_PRINCIPAL_PREFIX . $userId;
}
}
Loading