1313use OCA \DAV \CalDAV \Federation \Protocol \ICalendarFederationProtocol ;
1414use OCA \DAV \DAV \Sharing \Backend as DavSharingBackend ;
1515use OCP \AppFramework \Http ;
16- use OCP \AppFramework \Services \IAppConfig ;
1716use OCP \Federation \Exceptions \ProviderCouldNotAddShareException ;
1817use OCP \Federation \ICloudFederationProvider ;
1918use OCP \Federation \ICloudFederationShare ;
@@ -27,7 +26,7 @@ class CalendarFederationProvider implements ICloudFederationProvider {
2726 public function __construct (
2827 private readonly LoggerInterface $ logger ,
2928 private readonly FederatedCalendarMapper $ federatedCalendarMapper ,
30- private readonly IAppConfig $ appConfig ,
29+ private readonly CalendarFederationConfig $ calendarFederationConfig ,
3130 ) {
3231 }
3332
@@ -36,7 +35,7 @@ public function getShareType(): string {
3635 }
3736
3837 public function shareReceived (ICloudFederationShare $ share ): string {
39- if (!$ this ->isFederationEnabled ()) {
38+ if (!$ this ->calendarFederationConfig -> isFederationEnabled ()) {
4039 $ this ->logger ->debug ('Received a federation invite but federation is disabled ' );
4140 throw new ProviderCouldNotAddShareException (
4241 'Server does not support talk federation ' ,
@@ -104,25 +103,6 @@ public function shareReceived(ICloudFederationShare $share): string {
104103 $ calendarUri = hash ('md5 ' , $ calendarUrl );
105104
106105 $ sharedWithPrincipal = 'principals/users/ ' . $ share ->getShareWith ();
107- /*
108- $hasExistingCalendar = $this->federatedCalendarMapper->hasCalendarWithUriAndPrincipalUri(
109- $calendarUri,
110- $sharedWithPrincipal,
111- );
112- if ($hasExistingCalendar) {
113- throw new ProviderCouldNotAddShareException(
114- 'Calendar has already been shared with the user',
115- '',
116- Http::STATUS_CONFLICT,
117- );
118- }
119- */
120- /*
121- $existingCalendar = $this->federatedCalendarMapper->findByUri(
122- $sharedWithPrincipal,
123- $calendarUri,
124- );
125- */
126106
127107 // Delete existing incoming federated share first
128108 $ this ->federatedCalendarMapper ->deleteByUri ($ sharedWithPrincipal , $ calendarUri );
@@ -143,6 +123,7 @@ public function shareReceived(ICloudFederationShare $share): string {
143123 }
144124
145125 public function notificationReceived ($ notificationType , $ providerId , array $ notification ) {
126+ // TODO: implement a notification to queue a sync job immediately if a calendar is changed
146127 }
147128
148129 /**
@@ -151,8 +132,4 @@ public function notificationReceived($notificationType, $providerId, array $noti
151132 public function getSupportedShareTypes (): array {
152133 return [self ::USER_SHARE_TYPE ];
153134 }
154-
155- private function isFederationEnabled (): bool {
156- return $ this ->appConfig ->getAppValueBool ('enableCalendarFederation ' , true );
157- }
158135}
0 commit comments