From 149f18790464fcb68df58ac352c8a372c0addf04 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:22:02 +0100 Subject: [PATCH] expose user trust in member panel --- .../session/rightpanel/MemberDetailsViewModel.js | 12 ++++++++++++ .../ui/session/rightpanel/MemberDetailsView.js | 15 +++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/domain/session/rightpanel/MemberDetailsViewModel.js b/src/domain/session/rightpanel/MemberDetailsViewModel.js index 774f64af..df622aae 100644 --- a/src/domain/session/rightpanel/MemberDetailsViewModel.js +++ b/src/domain/session/rightpanel/MemberDetailsViewModel.js @@ -29,10 +29,22 @@ export class MemberDetailsViewModel extends ViewModel { this._session = options.session; this.track(this._powerLevelsObservable.subscribe(() => this._onPowerLevelsChange())); this.track(this._observableMember.subscribe( () => this._onMemberChange())); + this._isTrusted = false; + this.init(); // TODO: call this from parent view model and do something smart with error view model if it fails async? + } + + async init() { + if (this.features.crossSigning) { + this._isTrusted = await this.logger.run({l: "MemberDetailsViewModel.verify user", id: this._member.userId}, log => { + return this._session.crossSigning.isUserTrusted(this._member.userId, log); + }); + this.emitChange("isTrusted"); + } } get name() { return this._member.name; } get userId() { return this._member.userId; } + get isTrusted() { return this._isTrusted; } get type() { return "member-details"; } get shouldShowBackButton() { return true; } diff --git a/src/platform/web/ui/session/rightpanel/MemberDetailsView.js b/src/platform/web/ui/session/rightpanel/MemberDetailsView.js index caa8037f..45504a74 100644 --- a/src/platform/web/ui/session/rightpanel/MemberDetailsView.js +++ b/src/platform/web/ui/session/rightpanel/MemberDetailsView.js @@ -19,15 +19,22 @@ import {TemplateView} from "../../general/TemplateView"; export class MemberDetailsView extends TemplateView { render(t, vm) { + const securityNodes = [ + t.p(vm.isEncrypted ? + vm.i18n`Messages in this room are end-to-end encrypted.` : + vm.i18n`Messages in this room are not end-to-end encrypted.`), + ] + + if (vm.features.crossSigning) { + securityNodes.push(t.p(vm => vm.isTrusted ? vm.i18n`This user is trusted` : vm.i18n`This user is not trusted`)); + } + return t.div({className: "MemberDetailsView"}, [ t.view(new AvatarView(vm, 128)), t.div({className: "MemberDetailsView_name"}, t.h2(vm => vm.name)), t.div({className: "MemberDetailsView_id"}, vm.userId), this._createSection(t, vm.i18n`Role`, vm => vm.role), - this._createSection(t, vm.i18n`Security`, vm.isEncrypted ? - vm.i18n`Messages in this room are end-to-end encrypted.` : - vm.i18n`Messages in this room are not end-to-end encrypted.` - ), + this._createSection(t, vm.i18n`Security`, securityNodes), this._createOptions(t, vm) ]); }