From bc9af04820932142a55b07f86662b6f07117a3df Mon Sep 17 00:00:00 2001 From: HF Date: Sat, 18 Mar 2023 16:21:14 +0100 Subject: [PATCH] change how names are displayed --- ppfun-bridge/src/ppfunMatrixBridge.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ppfun-bridge/src/ppfunMatrixBridge.js b/ppfun-bridge/src/ppfunMatrixBridge.js index f573c47..93312d7 100644 --- a/ppfun-bridge/src/ppfunMatrixBridge.js +++ b/ppfun-bridge/src/ppfunMatrixBridge.js @@ -184,8 +184,12 @@ class PPfunMatrixBridge { } let name = this.idToNameMap.get(userId); if (!name) { - this.idToNameMap.set(userId, userId.substring(1)); - name = await this.getDisplayName(userId); + if (uid) { + name = `[mx] ${await this.getDisplayName(userId)}`; + } else { + name = userId.substring(1); + } + this.idToNameMap.set(userId, name); } if (name === 'event' || name === 'info') { // don'tallow special names used by system @@ -212,10 +216,9 @@ class PPfunMatrixBridge { const intent = this.matrixBridge.getIntent(); const profile = await intent.getProfileInfo(userId, 'displayname'); const { displayname } = profile; - this.idToNameMap.set(userId, displayname); return displayname; } catch (e) { - console.error(`Could not fetch DiplayName for ${uid}: ${e}`); + console.error(`Could not fetch DiplayName for ${userId}: ${e}`); return userId.substring(1); } } @@ -239,7 +242,7 @@ class PPfunMatrixBridge { } this.ppfunSocket.emit( 'sendChatMessage', - (uid) ? name : `[mx] ${name}`, + name, uid || null, msgString, cid,