File tree Expand file tree Collapse file tree 4 files changed +20
-15
lines changed
Expand file tree Collapse file tree 4 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,8 @@ protected function checkServer($url) {
113113 }
114114
115115 if ($ this ->trustedServers ->isOwnCloudServer ($ url ) === false ) {
116- $ message = 'No server to federate found ' ;
117- $ hint = $ this ->l ->t ('No server to federate found ' );
116+ $ message = 'No server to federate with found ' ;
117+ $ hint = $ this ->l ->t ('No server to federate with found ' );
118118 throw new HintException ($ message , $ hint );
119119 }
120120
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public function addServer($url) {
8989 if ($ result ) {
9090 return (int )$ this ->connection ->lastInsertId ('*PREFIX* ' .$ this ->dbTable );
9191 } else {
92- $ message = 'Internal failure, Could not add ownCloud as trusted server: ' . $ url ;
92+ $ message = 'Internal failure, Could not add trusted server: ' . $ url ;
9393 $ message_t = $ this ->IL10N ->t ('Could not add server ' );
9494 throw new HintException ($ message , $ message_t );
9595 }
Original file line number Diff line number Diff line change @@ -211,23 +211,29 @@ public function getServerStatus($url) {
211211 }
212212
213213 /**
214- * check if URL point to a ownCloud server
214+ * check if URL point to a ownCloud/Nextcloud server
215215 *
216216 * @param string $url
217217 * @return bool
218218 */
219219 public function isOwnCloudServer ($ url ) {
220220 $ isValidOwnCloud = false ;
221221 $ client = $ this ->httpClientService ->newClient ();
222- $ result = $ client ->get (
223- $ url . '/status.php ' ,
224- [
225- 'timeout ' => 3 ,
226- 'connect_timeout ' => 3 ,
227- ]
228- );
229- if ($ result ->getStatusCode () === Http::STATUS_OK ) {
230- $ isValidOwnCloud = $ this ->checkOwnCloudVersion ($ result ->getBody ());
222+ try {
223+ $ result = $ client ->get (
224+ $ url . '/status.php ' ,
225+ [
226+ 'timeout ' => 3 ,
227+ 'connect_timeout ' => 3 ,
228+ ]
229+ );
230+ if ($ result ->getStatusCode () === Http::STATUS_OK ) {
231+ $ isValidOwnCloud = $ this ->checkOwnCloudVersion ($ result ->getBody ());
232+
233+ }
234+ } catch (\Exception $ e ) {
235+ $ this ->logger ->debug ('No Nextcloud server: ' . $ e ->getMessage ());
236+ return false ;
231237 }
232238
233239 return $ isValidOwnCloud ;
Original file line number Diff line number Diff line change @@ -309,7 +309,6 @@ public function dataTestIsOwnCloudServer() {
309309 }
310310
311311 /**
312- * @expectedException \Exception
313312 * @expectedExceptionMessage simulated exception
314313 */
315314 public function testIsOwnCloudServerFail () {
@@ -323,7 +322,7 @@ public function testIsOwnCloudServerFail() {
323322 throw new \Exception ('simulated exception ' );
324323 });
325324
326- $ this ->trustedServers ->isOwnCloudServer ($ server );
325+ $ this ->assertFalse ( $ this -> trustedServers ->isOwnCloudServer ($ server) );
327326 }
328327
329328 /**
You can’t perform that action at this time.
0 commit comments