Remove legacy codepaths for Unknown Device Error (UDE/UDD) handling
as we now always `setGlobalErrorOnUnknownDevices(false)` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
cc68f53fc2
commit
f0cabd55c0
7 changed files with 63 additions and 481 deletions
|
@ -9,7 +9,6 @@ src/components/structures/UploadBar.js
|
||||||
src/components/views/avatars/MemberAvatar.js
|
src/components/views/avatars/MemberAvatar.js
|
||||||
src/components/views/create_room/RoomAlias.js
|
src/components/views/create_room/RoomAlias.js
|
||||||
src/components/views/dialogs/SetPasswordDialog.js
|
src/components/views/dialogs/SetPasswordDialog.js
|
||||||
src/components/views/dialogs/UnknownDeviceDialog.js
|
|
||||||
src/components/views/elements/AddressSelector.js
|
src/components/views/elements/AddressSelector.js
|
||||||
src/components/views/elements/DirectorySearchBox.js
|
src/components/views/elements/DirectorySearchBox.js
|
||||||
src/components/views/elements/MemberEventListSummary.js
|
src/components/views/elements/MemberEventListSummary.js
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
@import "./views/dialogs/_SlashCommandHelpDialog.scss";
|
@import "./views/dialogs/_SlashCommandHelpDialog.scss";
|
||||||
@import "./views/dialogs/_TabbedIntegrationManagerDialog.scss";
|
@import "./views/dialogs/_TabbedIntegrationManagerDialog.scss";
|
||||||
@import "./views/dialogs/_TermsDialog.scss";
|
@import "./views/dialogs/_TermsDialog.scss";
|
||||||
@import "./views/dialogs/_UnknownDeviceDialog.scss";
|
|
||||||
@import "./views/dialogs/_UploadConfirmDialog.scss";
|
@import "./views/dialogs/_UploadConfirmDialog.scss";
|
||||||
@import "./views/dialogs/_UserSettingsDialog.scss";
|
@import "./views/dialogs/_UserSettingsDialog.scss";
|
||||||
@import "./views/dialogs/_WidgetOpenIDPermissionsDialog.scss";
|
@import "./views/dialogs/_WidgetOpenIDPermissionsDialog.scss";
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 OpenMarket Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog ul {
|
|
||||||
list-style: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
// userid
|
|
||||||
.mx_UnknownDeviceDialog p {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: $font-16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog .mx_DeviceVerifyButtons {
|
|
||||||
flex-direction: row !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog .mx_Dialog_content {
|
|
||||||
margin-bottom: 24px;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog_deviceList > li {
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_UnknownDeviceDialog_deviceList > li > * {
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
|
@ -60,7 +60,6 @@ import * as sdk from './index';
|
||||||
import { _t } from './languageHandler';
|
import { _t } from './languageHandler';
|
||||||
import Matrix from 'matrix-js-sdk';
|
import Matrix from 'matrix-js-sdk';
|
||||||
import dis from './dispatcher/dispatcher';
|
import dis from './dispatcher/dispatcher';
|
||||||
import { showUnknownDeviceDialogForCalls } from './cryptodevices';
|
|
||||||
import WidgetUtils from './utils/WidgetUtils';
|
import WidgetUtils from './utils/WidgetUtils';
|
||||||
import WidgetEchoStore from './stores/WidgetEchoStore';
|
import WidgetEchoStore from './stores/WidgetEchoStore';
|
||||||
import SettingsStore, { SettingLevel } from './settings/SettingsStore';
|
import SettingsStore, { SettingLevel } from './settings/SettingsStore';
|
||||||
|
@ -134,33 +133,6 @@ function _reAttemptCall(call) {
|
||||||
function _setCallListeners(call) {
|
function _setCallListeners(call) {
|
||||||
call.on("error", function(err) {
|
call.on("error", function(err) {
|
||||||
console.error("Call error:", err);
|
console.error("Call error:", err);
|
||||||
if (err.code === 'unknown_devices') {
|
|
||||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
|
||||||
|
|
||||||
Modal.createTrackedDialog('Call Failed', '', QuestionDialog, {
|
|
||||||
title: _t('Call Failed'),
|
|
||||||
description: _t(
|
|
||||||
"There are unknown sessions in this room: "+
|
|
||||||
"if you proceed without verifying them, it will be "+
|
|
||||||
"possible for someone to eavesdrop on your call.",
|
|
||||||
),
|
|
||||||
button: _t('Review Sessions'),
|
|
||||||
onFinished: function(confirmed) {
|
|
||||||
if (confirmed) {
|
|
||||||
const room = MatrixClientPeg.get().getRoom(call.roomId);
|
|
||||||
showUnknownDeviceDialogForCalls(
|
|
||||||
MatrixClientPeg.get(),
|
|
||||||
room,
|
|
||||||
() => {
|
|
||||||
_reAttemptCall(call);
|
|
||||||
},
|
|
||||||
call.direction === 'outbound' ? _t("Call Anyway") : _t("Answer Anyway"),
|
|
||||||
call.direction === 'outbound' ? _t("Call") : _t("Answer"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (
|
if (
|
||||||
MatrixClientPeg.get().getTurnServers().length === 0 &&
|
MatrixClientPeg.get().getTurnServers().length === 0 &&
|
||||||
SettingsStore.getValue("fallbackICEServerAllowed") === null
|
SettingsStore.getValue("fallbackICEServerAllowed") === null
|
||||||
|
@ -174,7 +146,6 @@ function _setCallListeners(call) {
|
||||||
title: _t('Call Failed'),
|
title: _t('Call Failed'),
|
||||||
description: err.message,
|
description: err.message,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
call.on("hangup", function() {
|
call.on("hangup", function() {
|
||||||
_setCallState(undefined, call.roomId, "ended");
|
_setCallState(undefined, call.roomId, "ended");
|
||||||
|
|
|
@ -24,7 +24,6 @@ import { _t, _td } from '../../languageHandler';
|
||||||
import * as sdk from '../../index';
|
import * as sdk from '../../index';
|
||||||
import {MatrixClientPeg} from '../../MatrixClientPeg';
|
import {MatrixClientPeg} from '../../MatrixClientPeg';
|
||||||
import Resend from '../../Resend';
|
import Resend from '../../Resend';
|
||||||
import * as cryptodevices from '../../cryptodevices';
|
|
||||||
import dis from '../../dispatcher/dispatcher';
|
import dis from '../../dispatcher/dispatcher';
|
||||||
import {messageForResourceLimitError, messageForSendError} from '../../utils/ErrorUtils';
|
import {messageForResourceLimitError, messageForSendError} from '../../utils/ErrorUtils';
|
||||||
|
|
||||||
|
@ -126,13 +125,6 @@ export default createReactClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSendWithoutVerifyingClick: function() {
|
|
||||||
cryptodevices.getUnknownDevicesForRoom(MatrixClientPeg.get(), this.props.room).then((devices) => {
|
|
||||||
cryptodevices.markAllDevicesKnown(MatrixClientPeg.get(), devices);
|
|
||||||
Resend.resendUnsentEvents(this.props.room);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_onResendAllClick: function() {
|
_onResendAllClick: function() {
|
||||||
Resend.resendUnsentEvents(this.props.room);
|
Resend.resendUnsentEvents(this.props.room);
|
||||||
dis.dispatch({action: 'focus_composer'});
|
dis.dispatch({action: 'focus_composer'});
|
||||||
|
@ -143,10 +135,6 @@ export default createReactClass({
|
||||||
dis.dispatch({action: 'focus_composer'});
|
dis.dispatch({action: 'focus_composer'});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onShowDevicesClick: function() {
|
|
||||||
cryptodevices.showUnknownDeviceDialogForMessages(MatrixClientPeg.get(), this.props.room);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onRoomLocalEchoUpdated: function(event, room, oldEventId, oldStatus) {
|
_onRoomLocalEchoUpdated: function(event, room, oldEventId, oldStatus) {
|
||||||
if (room.roomId !== this.props.room.roomId) return;
|
if (room.roomId !== this.props.room.roomId) return;
|
||||||
|
|
||||||
|
@ -213,24 +201,7 @@ export default createReactClass({
|
||||||
if (!unsentMessages.length) return null;
|
if (!unsentMessages.length) return null;
|
||||||
|
|
||||||
let title;
|
let title;
|
||||||
let content;
|
|
||||||
|
|
||||||
const hasUDE = unsentMessages.some((m) => {
|
|
||||||
return m.error && m.error.name === "UnknownDeviceError";
|
|
||||||
});
|
|
||||||
|
|
||||||
if (hasUDE) {
|
|
||||||
title = _t("Message not sent due to unknown sessions being present");
|
|
||||||
content = _t(
|
|
||||||
"<showSessionsText>Show sessions</showSessionsText>, <sendAnywayText>send anyway</sendAnywayText> or <cancelText>cancel</cancelText>.",
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
'showSessionsText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="resend" onClick={this._onShowDevicesClick}>{ sub }</a>,
|
|
||||||
'sendAnywayText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="sendAnyway" onClick={this._onSendWithoutVerifyingClick}>{ sub }</a>,
|
|
||||||
'cancelText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let consentError = null;
|
let consentError = null;
|
||||||
let resourceLimitError = null;
|
let resourceLimitError = null;
|
||||||
for (const m of unsentMessages) {
|
for (const m of unsentMessages) {
|
||||||
|
@ -277,8 +248,9 @@ export default createReactClass({
|
||||||
} else {
|
} else {
|
||||||
title = _t('%(count)s of your messages have not been sent.', { count: unsentMessages.length });
|
title = _t('%(count)s of your messages have not been sent.', { count: unsentMessages.length });
|
||||||
}
|
}
|
||||||
content = _t("%(count)s <resendText>Resend all</resendText> or <cancelText>cancel all</cancelText> now. " +
|
|
||||||
"You can also select individual messages to resend or cancel.",
|
const content = _t("%(count)s <resendText>Resend all</resendText> or <cancelText>cancel all</cancelText> " +
|
||||||
|
"now. You can also select individual messages to resend or cancel.",
|
||||||
{ count: unsentMessages.length },
|
{ count: unsentMessages.length },
|
||||||
{
|
{
|
||||||
'resendText': (sub) =>
|
'resendText': (sub) =>
|
||||||
|
@ -287,7 +259,6 @@ export default createReactClass({
|
||||||
<a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
|
<a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return <div className="mx_RoomStatusBar_connectionLostBar">
|
return <div className="mx_RoomStatusBar_connectionLostBar">
|
||||||
<img src={require("../../../res/img/feather-customised/warning-triangle.svg")} width="24" height="24" title={_t("Warning")} alt="" />
|
<img src={require("../../../res/img/feather-customised/warning-triangle.svg")} width="24" height="24" title={_t("Warning")} alt="" />
|
||||||
|
|
|
@ -1,187 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Vector Creations Ltd
|
|
||||||
Copyright 2017 New Vector Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import createReactClass from 'create-react-class';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import * as sdk from '../../../index';
|
|
||||||
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
|
||||||
import { _t } from '../../../languageHandler';
|
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
|
||||||
import { markAllDevicesKnown } from '../../../cryptodevices';
|
|
||||||
|
|
||||||
function UserUnknownDeviceList(props) {
|
|
||||||
const MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo');
|
|
||||||
const {userId, userDevices} = props;
|
|
||||||
|
|
||||||
const deviceListEntries = Object.keys(userDevices).map((deviceId) =>
|
|
||||||
<li key={deviceId}><MemberDeviceInfo device={userDevices[deviceId]} userId={userId} showDeviceId={true} /></li>,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ul className="mx_UnknownDeviceDialog_deviceList">
|
|
||||||
{ deviceListEntries }
|
|
||||||
</ul>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserUnknownDeviceList.propTypes = {
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
|
|
||||||
// map from deviceid -> deviceinfo
|
|
||||||
userDevices: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function UnknownDeviceList(props) {
|
|
||||||
const {devices} = props;
|
|
||||||
|
|
||||||
const userListEntries = Object.keys(devices).map((userId) =>
|
|
||||||
<li key={userId}>
|
|
||||||
<p>{ userId }:</p>
|
|
||||||
<UserUnknownDeviceList userId={userId} userDevices={devices[userId]} />
|
|
||||||
</li>,
|
|
||||||
);
|
|
||||||
|
|
||||||
return <ul>{ userListEntries }</ul>;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnknownDeviceList.propTypes = {
|
|
||||||
// map from userid -> deviceid -> deviceinfo
|
|
||||||
devices: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export default createReactClass({
|
|
||||||
displayName: 'UnknownDeviceDialog',
|
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
room: PropTypes.object.isRequired,
|
|
||||||
|
|
||||||
// map from userid -> deviceid -> deviceinfo or null if devices are not yet loaded
|
|
||||||
devices: PropTypes.object,
|
|
||||||
|
|
||||||
onFinished: PropTypes.func.isRequired,
|
|
||||||
|
|
||||||
// Label for the button that marks all devices known and tries the send again
|
|
||||||
sendAnywayLabel: PropTypes.string.isRequired,
|
|
||||||
|
|
||||||
// Label for the button that to send the event if you've verified all devices
|
|
||||||
sendLabel: PropTypes.string.isRequired,
|
|
||||||
|
|
||||||
// function to retry the request once all devices are verified / known
|
|
||||||
onSend: PropTypes.func.isRequired,
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount: function() {
|
|
||||||
MatrixClientPeg.get().on("deviceVerificationChanged", this._onDeviceVerificationChanged);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
|
||||||
if (MatrixClientPeg.get()) {
|
|
||||||
MatrixClientPeg.get().removeListener("deviceVerificationChanged", this._onDeviceVerificationChanged);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_onDeviceVerificationChanged: function(userId, deviceId, deviceInfo) {
|
|
||||||
if (this.props.devices[userId] && this.props.devices[userId][deviceId]) {
|
|
||||||
// XXX: Mutating props :/
|
|
||||||
this.props.devices[userId][deviceId] = deviceInfo;
|
|
||||||
this.forceUpdate();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_onDismissClicked: function() {
|
|
||||||
this.props.onFinished();
|
|
||||||
},
|
|
||||||
|
|
||||||
_onSendAnywayClicked: function() {
|
|
||||||
markAllDevicesKnown(MatrixClientPeg.get(), this.props.devices);
|
|
||||||
|
|
||||||
this.props.onFinished();
|
|
||||||
this.props.onSend();
|
|
||||||
},
|
|
||||||
|
|
||||||
_onSendClicked: function() {
|
|
||||||
this.props.onFinished();
|
|
||||||
this.props.onSend();
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
if (this.props.devices === null) {
|
|
||||||
const Spinner = sdk.getComponent("elements.Spinner");
|
|
||||||
return <Spinner />;
|
|
||||||
}
|
|
||||||
|
|
||||||
let warning;
|
|
||||||
if (SettingsStore.getValue("blacklistUnverifiedDevices", this.props.room.roomId)) {
|
|
||||||
warning = (
|
|
||||||
<h4>
|
|
||||||
{ _t("You are currently blacklisting unverified sessions; to send " +
|
|
||||||
"messages to these sessions you must verify them.") }
|
|
||||||
</h4>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
warning = (
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
{ _t("We recommend you go through the verification process " +
|
|
||||||
"for each session to confirm they belong to their legitimate owner, " +
|
|
||||||
"but you can resend the message without verifying if you prefer.") }
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let haveUnknownDevices = false;
|
|
||||||
Object.keys(this.props.devices).forEach((userId) => {
|
|
||||||
Object.keys(this.props.devices[userId]).map((deviceId) => {
|
|
||||||
const device = this.props.devices[userId][deviceId];
|
|
||||||
if (device.isUnverified() && !device.isKnown()) {
|
|
||||||
haveUnknownDevices = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const sendButtonOnClick = haveUnknownDevices ? this._onSendAnywayClicked : this._onSendClicked;
|
|
||||||
const sendButtonLabel = haveUnknownDevices ? this.props.sendAnywayLabel : this.props.sendAnywayLabel;
|
|
||||||
|
|
||||||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
|
||||||
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
|
||||||
return (
|
|
||||||
<BaseDialog className='mx_UnknownDeviceDialog'
|
|
||||||
onFinished={this.props.onFinished}
|
|
||||||
title={_t('Room contains unknown sessions')}
|
|
||||||
contentId='mx_Dialog_content'
|
|
||||||
>
|
|
||||||
<div className="mx_Dialog_content" id='mx_Dialog_content'>
|
|
||||||
<h4>
|
|
||||||
{ _t('"%(RoomName)s" contains sessions that you haven\'t seen before.', {RoomName: this.props.room.name}) }
|
|
||||||
</h4>
|
|
||||||
{ warning }
|
|
||||||
{ _t("Unknown sessions") }:
|
|
||||||
|
|
||||||
<UnknownDeviceList devices={this.props.devices} />
|
|
||||||
</div>
|
|
||||||
<DialogButtons primaryButton={sendButtonLabel}
|
|
||||||
onPrimaryButtonClick={sendButtonOnClick}
|
|
||||||
onCancel={this._onDismissClicked} />
|
|
||||||
</BaseDialog>
|
|
||||||
);
|
|
||||||
// XXX: do we want to give the user the option to enable blacklistUnverifiedDevices for this room (or globally) at this point?
|
|
||||||
// It feels like confused users will likely turn it on and then disappear in a cloud of UISIs...
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,123 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 New Vector Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Resend from './Resend';
|
|
||||||
import * as sdk from './index';
|
|
||||||
import dis from './dispatcher/dispatcher';
|
|
||||||
import Modal from './Modal';
|
|
||||||
import { _t } from './languageHandler';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark all given devices as 'known'
|
|
||||||
*
|
|
||||||
* @param {MatrixClient} matrixClient A MatrixClient
|
|
||||||
* @param {Object} devices Map from userid -> deviceid -> deviceinfo
|
|
||||||
*/
|
|
||||||
export function markAllDevicesKnown(matrixClient, devices) {
|
|
||||||
Object.keys(devices).forEach((userId) => {
|
|
||||||
Object.keys(devices[userId]).map((deviceId) => {
|
|
||||||
matrixClient.setDeviceKnown(userId, deviceId, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all crypto devices in a room that are marked neither known
|
|
||||||
* nor verified.
|
|
||||||
*
|
|
||||||
* @param {MatrixClient} matrixClient A MatrixClient
|
|
||||||
* @param {Room} room js-sdk room object representing the room
|
|
||||||
* @return {Promise} A promise which resolves to a map userId->deviceId->{@link
|
|
||||||
* module:crypto~DeviceInfo|DeviceInfo}.
|
|
||||||
*/
|
|
||||||
export async function getUnknownDevicesForRoom(matrixClient, room) {
|
|
||||||
const roomMembers = (await room.getEncryptionTargetMembers()).map((m) => {
|
|
||||||
return m.userId;
|
|
||||||
});
|
|
||||||
const devices = await matrixClient.downloadKeys(roomMembers, false);
|
|
||||||
const unknownDevices = {};
|
|
||||||
// This is all devices in this room, so find the unknown ones.
|
|
||||||
Object.keys(devices).forEach((userId) => {
|
|
||||||
Object.keys(devices[userId]).map((deviceId) => {
|
|
||||||
const device = devices[userId][deviceId];
|
|
||||||
|
|
||||||
if (device.isUnverified() && !device.isKnown()) {
|
|
||||||
if (unknownDevices[userId] === undefined) {
|
|
||||||
unknownDevices[userId] = {};
|
|
||||||
}
|
|
||||||
unknownDevices[userId][deviceId] = device;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return unknownDevices;
|
|
||||||
}
|
|
||||||
|
|
||||||
function focusComposer() {
|
|
||||||
dis.dispatch({action: 'focus_composer'});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the UnknownDeviceDialog for a given room. The dialog will inform the user
|
|
||||||
* that messages they sent to this room have not been sent due to unknown devices
|
|
||||||
* being present.
|
|
||||||
*
|
|
||||||
* @param {MatrixClient} matrixClient A MatrixClient
|
|
||||||
* @param {Room} room js-sdk room object representing the room
|
|
||||||
*/
|
|
||||||
export function showUnknownDeviceDialogForMessages(matrixClient, room) {
|
|
||||||
getUnknownDevicesForRoom(matrixClient, room).then((unknownDevices) => {
|
|
||||||
const onSendClicked = () => {
|
|
||||||
Resend.resendUnsentEvents(room);
|
|
||||||
};
|
|
||||||
|
|
||||||
const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog');
|
|
||||||
Modal.createTrackedDialog('Unknown Device Dialog', '', UnknownDeviceDialog, {
|
|
||||||
room: room,
|
|
||||||
devices: unknownDevices,
|
|
||||||
sendAnywayLabel: _t("Send anyway"),
|
|
||||||
sendLabel: _t("Send"),
|
|
||||||
onSend: onSendClicked,
|
|
||||||
onFinished: focusComposer,
|
|
||||||
}, 'mx_Dialog_unknownDevice');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the UnknownDeviceDialog for a given room. The dialog will inform the user
|
|
||||||
* that a call they tried to place or answer in the room couldn't be placed or
|
|
||||||
* answered due to unknown devices being present.
|
|
||||||
*
|
|
||||||
* @param {MatrixClient} matrixClient A MatrixClient
|
|
||||||
* @param {Room} room js-sdk room object representing the room
|
|
||||||
* @param {func} sendAnyway Function called when the 'call anyway' or 'call'
|
|
||||||
* button is pressed. This should attempt to place or answer the call again.
|
|
||||||
* @param {string} sendAnywayLabel Label for the button displayed to retry the call
|
|
||||||
* when unknown devices are still present (eg. "Call Anyway")
|
|
||||||
* @param {string} sendLabel Label for the button displayed to retry the call
|
|
||||||
* after all devices have been verified (eg. "Call")
|
|
||||||
*/
|
|
||||||
export function showUnknownDeviceDialogForCalls(matrixClient, room, sendAnyway, sendAnywayLabel, sendLabel) {
|
|
||||||
getUnknownDevicesForRoom(matrixClient, room).then((unknownDevices) => {
|
|
||||||
const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog');
|
|
||||||
Modal.createTrackedDialog('Unknown Device Dialog', '', UnknownDeviceDialog, {
|
|
||||||
room: room,
|
|
||||||
devices: unknownDevices,
|
|
||||||
sendAnywayLabel: sendAnywayLabel,
|
|
||||||
sendLabel: sendLabel,
|
|
||||||
onSend: sendAnyway,
|
|
||||||
}, 'mx_Dialog_unknownDevice');
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in a new issue