1414use OCA \FederatedFileSharing \Events \FederatedShareAddedEvent ;
1515use OCA \Files_Sharing \Helper ;
1616use OCA \Files_Sharing \ResponseDefinitions ;
17- use OCP \AppFramework \Http ;
1817use OCP \DB \Exception ;
1918use OCP \DB \QueryBuilder \IQueryBuilder ;
2019use OCP \EventDispatcher \IEventDispatcher ;
3433use OCP \IUser ;
3534use OCP \IUserSession ;
3635use OCP \Notification \IManager ;
37- use OCP \OCM \Exceptions \OCMProviderException ;
3836use OCP \OCS \IDiscoveryService ;
3937use OCP \Server ;
4038use OCP \Share ;
5654 * accepted: bool,
5755 * share_type:int,
5856 * password: string,
59- * mountpoint_hash:
60- * string
57+ * mountpoint_hash: string
6158 * }
6259 */
6360class Manager {
@@ -80,6 +77,7 @@ public function __construct(
8077 private LoggerInterface $ logger ,
8178 private IRootFolder $ rootFolder ,
8279 private SetupManager $ setupManager ,
80+ private ICertificateManager $ certificateManager ,
8381 ) {
8482 $ this ->user = $ userSession ->getUser ();
8583 }
@@ -524,7 +522,6 @@ private function sendFeedbackToRemote(string $remote, string $token, string $rem
524522 * @return array|false
525523 */
526524 protected function tryOCMEndPoint (string $ remoteDomain , string $ token , string $ remoteId , string $ feedback ) {
527- $ response = null ;
528525 switch ($ feedback ) {
529526 case 'accept ' :
530527 $ notification = $ this ->cloudFederationFactory ->getCloudFederationNotification ();
@@ -538,11 +535,7 @@ protected function tryOCMEndPoint(string $remoteDomain, string $token, string $r
538535 ]
539536
540537 );
541- try {
542- $ response = $ this ->cloudFederationProviderManager ->sendCloudNotification ($ remoteDomain , $ notification );
543- } catch (OCMProviderException ) {
544- }
545- break ;
538+ return $ this ->cloudFederationProviderManager ->sendNotification ($ remoteDomain , $ notification );
546539 case 'decline ' :
547540 $ notification = $ this ->cloudFederationFactory ->getCloudFederationNotification ();
548541 $ notification ->setMessage (
@@ -553,26 +546,9 @@ protected function tryOCMEndPoint(string $remoteDomain, string $token, string $r
553546 'sharedSecret ' => $ token ,
554547 'message ' => 'Recipient declined the share '
555548 ]
556-
557549 );
558- try {
559- $ response = $ this ->cloudFederationProviderManager ->sendCloudNotification ($ remoteDomain , $ notification );
560- } catch (OCMProviderException ) {
561- }
562- break ;
563- default :
564- throw new \RuntimeException ('Unknown feedback ' );
550+ return $ this ->cloudFederationProviderManager ->sendNotification ($ remoteDomain , $ notification );
565551 }
566-
567- if ($ response !== null && $ response ->getStatusCode () === Http::STATUS_CREATED ) {
568- $ result = json_decode ($ response ->getBody (), true );
569- if (is_array ($ result )) {
570- return $ result ;
571- } else {
572- return [];
573- }
574- }
575-
576552 return false ;
577553 }
578554
@@ -589,7 +565,7 @@ public function getMount(array $data, ?IUser $user = null) {
589565 $ data ['manager ' ] = $ this ;
590566 $ mountPoint = '/ ' . $ user ->getUID () . '/files ' . $ data ['mountpoint ' ];
591567 $ data ['mountpoint ' ] = $ mountPoint ;
592- $ data ['certificateManager ' ] = Server:: get (ICertificateManager::class) ;
568+ $ data ['certificateManager ' ] = $ this -> certificateManager ;
593569 return new Mount (self ::STORAGE , $ mountPoint , $ data , $ this , $ this ->storageLoader );
594570 }
595571
0 commit comments