From a7bb17b9770ef2711ce76991d81249a6f2fb212d Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 3 Dec 2019 02:41:28 -0800 Subject: [PATCH] remove _adnApi and expect LokiAppDotNetAPI to be like the serverAPI --- js/modules/loki_file_server_api.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/js/modules/loki_file_server_api.js b/js/modules/loki_file_server_api.js index 97c72fcb4..8cd1107f4 100644 --- a/js/modules/loki_file_server_api.js +++ b/js/modules/loki_file_server_api.js @@ -13,20 +13,19 @@ const DEVICE_MAPPING_USER_ANNOTATION_TYPE = class LokiFileServerInstance { constructor(ourKey) { this.ourKey = ourKey; - // why don't we extend this? - this._adnApi = new LokiAppDotNetAPI(ourKey); - this.avatarMap = {}; } // FIXME: this is not file-server specific // and is currently called by LokiAppDotNetAPI. // LokiAppDotNetAPI (base) should not know about LokiFileServer. async establishConnection(serverUrl) { - // FIXME: we don't always need a token... - this._server = await this._adnApi.findOrCreateServer(serverUrl); + // why don't we extend this? + this._server = new LokiAppDotNetAPI(this.ourKey, serverUrl); + // get a token for multidevice + const gotToken = await this._server.getOrRefreshServerToken(); // TODO: Handle this failure gracefully - if (!this._server) { - log.error('Failed to establish connection to file server'); + if (!gotToken) { + log.error('You are blacklisted form this home server'); } } async getUserDeviceMapping(pubKey) { @@ -45,10 +44,6 @@ class LokiFileServerInstance { await Promise.all( users.map(async user => { let found = false; - // if this user has an avatar set, copy it into the map - this.avatarMap[user.username] = user.avatar_image - ? user.avatar_image.url - : false; if (!user.annotations || !user.annotations.length) { log.info( `verifyUserObjectDeviceMap no annotation for ${user.username}`