@@ -39,116 +39,116 @@ |
||
39 | 39 | */ |
40 | 40 | class ExternalSharesController extends Controller { |
41 | 41 | |
42 | - /** @var \OCA\Files_Sharing\External\Manager */ |
|
43 | - private $externalManager; |
|
44 | - /** @var IClientService */ |
|
45 | - private $clientService; |
|
42 | + /** @var \OCA\Files_Sharing\External\Manager */ |
|
43 | + private $externalManager; |
|
44 | + /** @var IClientService */ |
|
45 | + private $clientService; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $appName |
|
49 | - * @param IRequest $request |
|
50 | - * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
51 | - * @param IClientService $clientService |
|
52 | - */ |
|
53 | - public function __construct($appName, |
|
54 | - IRequest $request, |
|
55 | - \OCA\Files_Sharing\External\Manager $externalManager, |
|
56 | - IClientService $clientService) { |
|
57 | - parent::__construct($appName, $request); |
|
58 | - $this->externalManager = $externalManager; |
|
59 | - $this->clientService = $clientService; |
|
60 | - } |
|
47 | + /** |
|
48 | + * @param string $appName |
|
49 | + * @param IRequest $request |
|
50 | + * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
51 | + * @param IClientService $clientService |
|
52 | + */ |
|
53 | + public function __construct($appName, |
|
54 | + IRequest $request, |
|
55 | + \OCA\Files_Sharing\External\Manager $externalManager, |
|
56 | + IClientService $clientService) { |
|
57 | + parent::__construct($appName, $request); |
|
58 | + $this->externalManager = $externalManager; |
|
59 | + $this->clientService = $clientService; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @NoAdminRequired |
|
64 | - * @NoOutgoingFederatedSharingRequired |
|
65 | - * |
|
66 | - * @return JSONResponse |
|
67 | - */ |
|
68 | - public function index() { |
|
69 | - return new JSONResponse($this->externalManager->getOpenShares()); |
|
70 | - } |
|
62 | + /** |
|
63 | + * @NoAdminRequired |
|
64 | + * @NoOutgoingFederatedSharingRequired |
|
65 | + * |
|
66 | + * @return JSONResponse |
|
67 | + */ |
|
68 | + public function index() { |
|
69 | + return new JSONResponse($this->externalManager->getOpenShares()); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @NoAdminRequired |
|
74 | - * @NoOutgoingFederatedSharingRequired |
|
75 | - * |
|
76 | - * @param int $id |
|
77 | - * @return JSONResponse |
|
78 | - */ |
|
79 | - public function create($id) { |
|
80 | - $this->externalManager->acceptShare($id); |
|
81 | - return new JSONResponse(); |
|
82 | - } |
|
72 | + /** |
|
73 | + * @NoAdminRequired |
|
74 | + * @NoOutgoingFederatedSharingRequired |
|
75 | + * |
|
76 | + * @param int $id |
|
77 | + * @return JSONResponse |
|
78 | + */ |
|
79 | + public function create($id) { |
|
80 | + $this->externalManager->acceptShare($id); |
|
81 | + return new JSONResponse(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @NoAdminRequired |
|
86 | - * @NoOutgoingFederatedSharingRequired |
|
87 | - * |
|
88 | - * @param integer $id |
|
89 | - * @return JSONResponse |
|
90 | - */ |
|
91 | - public function destroy($id) { |
|
92 | - $this->externalManager->declineShare($id); |
|
93 | - return new JSONResponse(); |
|
94 | - } |
|
84 | + /** |
|
85 | + * @NoAdminRequired |
|
86 | + * @NoOutgoingFederatedSharingRequired |
|
87 | + * |
|
88 | + * @param integer $id |
|
89 | + * @return JSONResponse |
|
90 | + */ |
|
91 | + public function destroy($id) { |
|
92 | + $this->externalManager->declineShare($id); |
|
93 | + return new JSONResponse(); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Test whether the specified remote is accessible |
|
98 | - * |
|
99 | - * @param string $remote |
|
100 | - * @param bool $checkVersion |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - protected function testUrl($remote, $checkVersion = false) { |
|
104 | - try { |
|
105 | - $client = $this->clientService->newClient(); |
|
106 | - $response = json_decode($client->get( |
|
107 | - $remote, |
|
108 | - [ |
|
109 | - 'timeout' => 3, |
|
110 | - 'connect_timeout' => 3, |
|
111 | - ] |
|
112 | - )->getBody()); |
|
96 | + /** |
|
97 | + * Test whether the specified remote is accessible |
|
98 | + * |
|
99 | + * @param string $remote |
|
100 | + * @param bool $checkVersion |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + protected function testUrl($remote, $checkVersion = false) { |
|
104 | + try { |
|
105 | + $client = $this->clientService->newClient(); |
|
106 | + $response = json_decode($client->get( |
|
107 | + $remote, |
|
108 | + [ |
|
109 | + 'timeout' => 3, |
|
110 | + 'connect_timeout' => 3, |
|
111 | + ] |
|
112 | + )->getBody()); |
|
113 | 113 | |
114 | - if ($checkVersion) { |
|
115 | - return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
116 | - } else { |
|
117 | - return is_object($response); |
|
118 | - } |
|
119 | - } catch (\Exception $e) { |
|
120 | - return false; |
|
121 | - } |
|
122 | - } |
|
114 | + if ($checkVersion) { |
|
115 | + return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
116 | + } else { |
|
117 | + return is_object($response); |
|
118 | + } |
|
119 | + } catch (\Exception $e) { |
|
120 | + return false; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @PublicPage |
|
126 | - * @NoOutgoingFederatedSharingRequired |
|
127 | - * @NoIncomingFederatedSharingRequired |
|
128 | - * |
|
129 | - * @param string $remote |
|
130 | - * @return DataResponse |
|
131 | - */ |
|
132 | - public function testRemote($remote) { |
|
133 | - if (strpos($remote, '#') !== false || strpos($remote, '?') !== false) { |
|
134 | - return new DataResponse(false); |
|
135 | - } |
|
124 | + /** |
|
125 | + * @PublicPage |
|
126 | + * @NoOutgoingFederatedSharingRequired |
|
127 | + * @NoIncomingFederatedSharingRequired |
|
128 | + * |
|
129 | + * @param string $remote |
|
130 | + * @return DataResponse |
|
131 | + */ |
|
132 | + public function testRemote($remote) { |
|
133 | + if (strpos($remote, '#') !== false || strpos($remote, '?') !== false) { |
|
134 | + return new DataResponse(false); |
|
135 | + } |
|
136 | 136 | |
137 | - if ( |
|
138 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
139 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
140 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
141 | - ) { |
|
142 | - return new DataResponse('https'); |
|
143 | - } elseif ( |
|
144 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
145 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
146 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
147 | - ) { |
|
148 | - return new DataResponse('http'); |
|
149 | - } else { |
|
150 | - return new DataResponse(false); |
|
151 | - } |
|
152 | - } |
|
137 | + if ( |
|
138 | + $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
139 | + $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
140 | + $this->testUrl('https://' . $remote . '/status.php', true) |
|
141 | + ) { |
|
142 | + return new DataResponse('https'); |
|
143 | + } elseif ( |
|
144 | + $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
145 | + $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
146 | + $this->testUrl('http://' . $remote . '/status.php', true) |
|
147 | + ) { |
|
148 | + return new DataResponse('http'); |
|
149 | + } else { |
|
150 | + return new DataResponse(false); |
|
151 | + } |
|
152 | + } |
|
153 | 153 | |
154 | 154 | } |
@@ -135,15 +135,15 @@ |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | if ( |
138 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
139 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
140 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
138 | + $this->testUrl('https://'.$remote.'/ocs-provider/') || |
|
139 | + $this->testUrl('https://'.$remote.'/ocs-provider/index.php') || |
|
140 | + $this->testUrl('https://'.$remote.'/status.php', true) |
|
141 | 141 | ) { |
142 | 142 | return new DataResponse('https'); |
143 | 143 | } elseif ( |
144 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
145 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
146 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
144 | + $this->testUrl('http://'.$remote.'/ocs-provider/') || |
|
145 | + $this->testUrl('http://'.$remote.'/ocs-provider/index.php') || |
|
146 | + $this->testUrl('http://'.$remote.'/status.php', true) |
|
147 | 147 | ) { |
148 | 148 | return new DataResponse('http'); |
149 | 149 | } else { |