From bad48da11a8b80abe0449b4cb3a031a670c22100 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 14 Nov 2019 11:50:06 -0700 Subject: [PATCH 1/2] Check the right Synapse endpoint for determining admin capabilities --- src/client.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index bcc0ab5f1..d7796906e 100644 --- a/src/client.js +++ b/src/client.js @@ -4021,9 +4021,13 @@ MatrixClient.prototype.isFallbackICEServerAllowed = function() { * @return {boolean} true if the user appears to be a Synapse administrator. */ MatrixClient.prototype.isSynapseAdministrator = function() { - return this.whoisSynapseUser(this.getUserId()) - .then(() => true) - .catch(() => false); + const path = utils.encodeUri( + "/_synapse/admin/v1/users/$userId/admin", + { $userId: userId }, + ); + return this._http.authedRequest( + undefined, 'GET', path, undefined, undefined, {prefix: ''}, + ).then(r => r['admin']); // pull out the specific boolean we want }; /** From 904a2f466e518f41eb0bd54777ab56bdbe73a7e3 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 14 Nov 2019 11:54:13 -0700 Subject: [PATCH 2/2] Maybe use the right user ID too --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index d7796906e..a55828240 100644 --- a/src/client.js +++ b/src/client.js @@ -4023,7 +4023,7 @@ MatrixClient.prototype.isFallbackICEServerAllowed = function() { MatrixClient.prototype.isSynapseAdministrator = function() { const path = utils.encodeUri( "/_synapse/admin/v1/users/$userId/admin", - { $userId: userId }, + { $userId: this.getUserId() }, ); return this._http.authedRequest( undefined, 'GET', path, undefined, undefined, {prefix: ''},