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>
This commit is contained in:
David Baker 2022-03-02 09:59:01 +00:00 committed by GitHub
parent e6ea58e84d
commit 2d58704d26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,9 +152,9 @@ export default class CallHandler extends EventEmitter {
public roomIdForCall(call: MatrixCall): string { public roomIdForCall(call: MatrixCall): string {
if (!call) return null; if (!call) return null;
const voipConfig = SdkConfig.get()['voip']; // check asserted identity: if we're not obeying asserted identity,
// this map will never be populated, but we check anyway for sanity
if (voipConfig && voipConfig.obeyAssertedIdentity) { if (this.shouldObeyAssertedfIdentity()) {
const nativeUser = this.assertedIdentityNativeUsers[call.callId]; const nativeUser = this.assertedIdentityNativeUsers[call.callId];
if (nativeUser) { if (nativeUser) {
const room = findDMForUser(MatrixClientPeg.get(), 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 { public getSupportsPstnProtocol(): boolean {
return this.supportsPstnProtocol; 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()); 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; const newAssertedIdentity = call.getRemoteAssertedIdentity().id;
let newNativeAssertedIdentity = newAssertedIdentity; let newNativeAssertedIdentity = newAssertedIdentity;
if (newAssertedIdentity) { if (newAssertedIdentity) {