diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 5990a98e47..cec02291b7 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -18,6 +18,7 @@ limitations under the License. var React = require('react'); var sdk = require('../../../index'); +var MatrixClientPeg = require('../../../MatrixClientPeg'); module.exports = React.createClass({ displayName: 'RoomPreviewBar', @@ -45,10 +46,34 @@ module.exports = React.createClass({ }; }, + getInitialState: function() { + return { + busy: false + } + }, + + componentWillMount: function() { + // If this is an invite and we've been told what email + // address was invited, fetch the user's list of 3pids + // so we can check them against the one that was invited + if (this.props.inviterName && this.props.invitedEmail) { + this.setState({busy: true}); + MatrixClientPeg.get().lookupThreePid( + 'email', this.props.invitedEmail + ).finally(() => { + this.setState({busy: false}); + }).done((result) => { + this.setState({invitedEmailMxid: result.mxid}); + }, (err) => { + this.setState({threePidFetchError: err}); + }); + } + }, + render: function() { var joinBlock, previewBlock; - if (this.props.spinner) { + if (this.props.spinner || this.state.busy) { var Spinner = sdk.getComponent("elements.Spinner"); return (
@@ -56,6 +81,21 @@ module.exports = React.createClass({ } if (this.props.inviterName) { + var emailMatchBlock; + if (this.props.invitedEmail) { + if (this.state.threePidFetchError) { + emailMatchBlock =
+ Vector was unable to ascertain that the addres this invite was + sent to matches one associated with your account. +
+ } else if (this.state.invitedEmailMxid != MatrixClientPeg.get().credentials.userId) { + emailMatchBlock =
+ /!\\ + This invitation was sent to {this.props.invitedEmail} + which is not publicly associated with your account. +
+ } + } joinBlock = (
@@ -64,7 +104,7 @@ module.exports = React.createClass({
Would you like to accept or decline this invitation?
-
{this.props.invitedEmail} was invited
+ {emailMatchBlock}
);