From 2d58704d2602cd554cdf248a6ad54e345dab726c Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Mar 2022 09:59:01 +0000 Subject: [PATCH] Clean up asserted identity code (#7934) * Clean up asserted identity code Add logging when we received asserted identity events but ignore them, and just disable the whole code path if it's not enabled in the config. * Actually, put the check back - better to check anyway * Update to ? syntax Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Put back lost return Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- src/CallHandler.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index 991e0c3039..60094262ed 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -152,9 +152,9 @@ export default class CallHandler extends EventEmitter { public roomIdForCall(call: MatrixCall): string { if (!call) return null; - const voipConfig = SdkConfig.get()['voip']; - - if (voipConfig && voipConfig.obeyAssertedIdentity) { + // check asserted identity: if we're not obeying asserted identity, + // this map will never be populated, but we check anyway for sanity + if (this.shouldObeyAssertedfIdentity()) { const nativeUser = this.assertedIdentityNativeUsers[call.callId]; if (nativeUser) { const room = findDMForUser(MatrixClientPeg.get(), nativeUser); @@ -262,6 +262,10 @@ export default class CallHandler extends EventEmitter { } } + private shouldObeyAssertedfIdentity(): boolean { + return SdkConfig.get()['voip']?.obeyAssertedIdentity; + } + public getSupportsPstnProtocol(): boolean { return this.supportsPstnProtocol; } @@ -489,6 +493,11 @@ export default class CallHandler extends EventEmitter { logger.log(`Call ID ${call.callId} got new asserted identity:`, call.getRemoteAssertedIdentity()); + if (!this.shouldObeyAssertedfIdentity()) { + logger.log("asserted identity not enabled in config: ignoring"); + return; + } + const newAssertedIdentity = call.getRemoteAssertedIdentity().id; let newNativeAssertedIdentity = newAssertedIdentity; if (newAssertedIdentity) {