diff --git a/src/components/views/dialogs/EncryptedEventDialog.js b/src/components/views/dialogs/EncryptedEventDialog.js index 46dfe5fc4f..be8656064c 100644 --- a/src/components/views/dialogs/EncryptedEventDialog.js +++ b/src/components/views/dialogs/EncryptedEventDialog.js @@ -22,15 +22,27 @@ module.exports = React.createClass({ displayName: 'EncryptedEventDialog', propTypes: { - onFinished: React.PropTypes.func, + event: React.PropTypes.object.isRequired, + onFinished: React.PropTypes.func.isRequired, + }, + + getInitialState: function() { + return { device: this.refreshDevice() }; }, componentWillMount: function() { + this._unmounted = false; var client = MatrixClientPeg.get(); client.on("deviceVerificationChanged", this.onDeviceVerificationChanged); + // no need to redownload keys if we already have the device + if (this.state.device) { + return; + } client.downloadKeys([this.props.event.getSender()], true).done(()=>{ - var devices = client.getStoredDevicesForUser(this.props.event.getSender()); + if (this._unmounted) { + return; + } this.setState({ device: this.refreshDevice() }); }, (err)=>{ console.log("Error downloading devices", err); @@ -38,6 +50,7 @@ module.exports = React.createClass({ }, componentWillUnmount: function() { + this._unmounted = true; var client = MatrixClientPeg.get(); if (client) { client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged); @@ -45,16 +58,7 @@ module.exports = React.createClass({ }, refreshDevice: function() { - // XXX: gutwrench - is there any reason not to expose this on MatrixClient itself? - return MatrixClientPeg.get()._crypto.getDeviceByIdentityKey( - this.props.event.getSender(), - this.props.event.getWireContent().algorithm, - this.props.event.getWireContent().sender_key - ); - }, - - getInitialState: function() { - return { device: this.refreshDevice() }; + return MatrixClientPeg.get().getEventSenderDeviceInfo(this.props.event); }, onDeviceVerificationChanged: function(userId, device) { @@ -71,72 +75,113 @@ module.exports = React.createClass({ } }, - render: function() { - var event = this.props.event; + _renderDeviceInfo: function() { var device = this.state.device; + if (!device) { + return (unknown device); + } + var verificationStatus = (NOT verified); + if (device.isBlocked()) { + verificationStatus = (Blocked); + } else if (device.isVerified()) { + verificationStatus = "verified"; + } + + return ( + + + + + + + + + + + + + + + + + + + +
Name{ device.getDisplayName() }
Device ID{ device.deviceId }
Verification{ verificationStatus }
Ed25519 fingerprint{device.getFingerprint()}
+ ); + }, + + _renderEventInfo: function() { + var event = this.props.event; + + return ( + + + + + + + + + + + + + + + + + + + { + event.getContent().msgtype === 'm.bad.encrypted' ? ( + + + + + ) : null + } + + + + + +
User ID{ event.getSender() }
Curve25519 identity key{ event.getSenderKey() || none }
Claimed Ed25519 fingerprint key{ event.getKeysClaimed().ed25519 || none }
Algorithm{ event.getWireContent().algorithm || unencrypted }
Decryption error{ event.getContent().body }
Session ID{ event.getWireContent().session_id || none }
+ ); + }, + + render: function() { var MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo'); + var buttons = null; + if (this.state.device) { + buttons = ( + + ); + } + return (
End-to-end encryption information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - event.getContent().msgtype === 'm.bad.encrypted' ? ( - - - - - ) : '' - } - - - - - -
Sent by{ event.getSender() }
Sender device name{ device ? device.getDisplayName() : unknown device}
Sender device ID{ device ? { device.deviceId } : unknown device}
Sender device verification{ MatrixClientPeg.get().isEventSenderVerified(event) ? "verified" : NOT verified }
Sender device ed25519 identity key{ device ? {device.getFingerprint()} : unknown device}
Sender device curve25519 olm key{ event.getWireContent().sender_key || none }
Algorithm{ event.getWireContent().algorithm || unencrypted }
Decryption error{ event.getContent().body }
Session ID{ event.getWireContent().session_id || none }
+

Event information

+ {this._renderEventInfo()} + +

Sender device information

+ {this._renderDeviceInfo()}
- + {buttons}
); } }); - -