From 9816fe0ed7c1bcdd65bc22af63bb3856f1e99109 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 6 Jun 2019 14:34:57 +0100 Subject: [PATCH] Fix email invites address-match checking Riot was always saying the email address that the invite was sent to was not associated with your account. Two fixes here: 1. We mounted RoomPreviewBar with no invitedEmail prop and then changed the prop later, but RoomPreviewBar only checked for it on mount. Make sure we re-check when the props change. 2. Pass oobData through RoomPreviewBar because we need to pass it to the RoomAvatar for 3pid invites. https://github.com/vector-im/riot-web/issues/9816 --- src/components/structures/RoomView.js | 2 ++ src/components/views/rooms/RoomPreviewBar.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7c0710a18d..d91a600582 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1551,6 +1551,7 @@ module.exports = React.createClass({ joining={this.state.joining} inviterName={inviterName} invitedEmail={invitedEmail} + oobData={this.props.oobData} room={this.state.room} /> @@ -1681,6 +1682,7 @@ module.exports = React.createClass({ joining={this.state.joining} inviterName={inviterName} invitedEmail={invitedEmail} + oobData={this.props.oobData} canPreview={this.state.canPeek} room={this.state.room} /> diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 5d79463112..cadd9a1c55 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -54,6 +54,9 @@ module.exports = React.createClass({ // If invited by 3rd party invite, the email address the invite was sent to invitedEmail: PropTypes.string, + // For third party invites, information passed about the room out-of-band + oobData: PropTypes.object, + // A standard client/server API error object. If supplied, indicates that the // caller was unable to fetch details about the room for the given reason. error: PropTypes.object, @@ -87,6 +90,16 @@ module.exports = React.createClass({ }, componentWillMount: function() { + this._checkInvitedEmail(); + }, + + componentDidUpdate: function(prevProps, prevState) { + if (this.props.invitedEmail !== prevProps.invitedEmail || this.props.inviterName !== prevProps.inviterName) { + this._checkInvitedEmail(); + } + }, + + _checkInvitedEmail: function() { // If this is an invite and we've been told what email // address was invited, fetch the user's list of Threepids // so we can check them against the one that was invited @@ -335,7 +348,7 @@ module.exports = React.createClass({ } case MessageCase.Invite: { const RoomAvatar = sdk.getComponent("views.avatars.RoomAvatar"); - const avatar = ; + const avatar = ; const inviteMember = this._getInviteMember(); let inviterElement;