From 5ee1f557d8354a18845a630e28a1c8ce2addab54 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 18 Dec 2018 13:11:47 -0200 Subject: [PATCH] [FIX] GET /info to check if it's a valid server instead of x-instance-id (#573) --- app/lib/rocketchat.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 7bfec9cc7..e5bab9919 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -1,6 +1,5 @@ import { AsyncStorage, Platform } from 'react-native'; import foreach from 'lodash/forEach'; -import RNFetchBlob from 'rn-fetch-blob'; import * as SDK from '@rocket.chat/sdk'; import reduxStore from './createStore'; @@ -78,15 +77,11 @@ const RocketChat = { console.warn(`AsyncStorage error: ${ error.message }`); } }, - _hasInstanceId(headers) { - return !!headers[Object.keys(headers).find(item => item.toLowerCase() === 'x-instance-id')]; - }, - async testServer(url) { + async testServer(server) { try { - let response = await RNFetchBlob.fetch('HEAD', url); - response = response.respInfo; - if (response.status === 200 && RocketChat._hasInstanceId(response.headers)) { - return url; + const result = await fetch(`${ server }/api/v1/info`).then(response => response.json()); + if (result.success && result.info) { + return server; } } catch (e) { log('testServer', e);