diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index dd89e118d7..7ee7936d73 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -390,7 +390,7 @@ module.exports = React.createClass({ case 'view_room': this._viewRoom( payload.room_id, payload.room_alias, payload.show_settings, payload.event_id, - payload.invite_sign_url, payload.oob_data + payload.third_party_invite, payload.oob_data ); break; case 'view_prev_room': @@ -437,7 +437,7 @@ module.exports = React.createClass({ room_id: foundRoom.roomId, room_alias: payload.room_alias, event_id: payload.event_id, - invite_sign_url: payload.invite_sign_url, + third_party_invite: payload.third_party_invite, oob_data: payload.oob_data, }); return; @@ -450,7 +450,7 @@ module.exports = React.createClass({ room_id: result.room_id, room_alias: payload.room_alias, event_id: payload.event_id, - invite_sign_url: payload.invite_sign_url, + third_party_invite: payload.third_party_invite, oob_data: payload.oob_data, }); }); @@ -539,10 +539,14 @@ module.exports = React.createClass({ // // eventId is optional and will cause a switch to the context of that // particular event. + // @param {Object} thirdPartyInvite Object containing data about the third party + // we received to join the room, if any. + // @param {string} thirdPartyInvite.inviteSignUrl 3pid invite sign URL + // @param {string} thirdPartyInvite.invitedwithEmail The email address the invite was sent to // @param {Object} oob_data Object of additional data about the room // that has been passed out-of-band (eg. // room name and avatar from an invite email) - _viewRoom: function(roomId, roomAlias, showSettings, eventId, invite_sign_url, oob_data) { + _viewRoom: function(roomId, roomAlias, showSettings, eventId, thirdPartyInvite, oob_data) { // before we switch room, record the scroll state of the current room this._updateScrollMap(); @@ -555,7 +559,7 @@ module.exports = React.createClass({ highlightedEventId: eventId, initialEventPixelOffset: undefined, page_type: this.PageTypes.RoomView, - inviteSignUrl: invite_sign_url, + thirdPartyInvite: thirdPartyInvite, roomOobData: oob_data, }; @@ -783,6 +787,11 @@ module.exports = React.createClass({ var roomString = segments[0]; var eventId = segments[1]; // undefined if no event id given + // FIXME: sort_out caseConsistency + var third_party_invite = { + inviteSignUrl: params.signurl, + invitedEmail: params.email, + }; var oob_data = { name: params.room_name, avatarUrl: params.room_avatar_url, @@ -794,7 +803,7 @@ module.exports = React.createClass({ action: 'view_room_alias', room_alias: roomString, event_id: eventId, - invite_sign_url: params.signurl, + third_party_invite: third_party_invite, oob_data: oob_data, }); } else { @@ -802,7 +811,7 @@ module.exports = React.createClass({ action: 'view_room', room_id: roomString, event_id: eventId, - invite_sign_url: params.signurl, + third_party_invite: third_party_invite, oob_data: oob_data, }); } @@ -1009,7 +1018,7 @@ module.exports = React.createClass({ roomId={this.state.currentRoom} roomAlias={this.state.currentRoomAlias} eventId={this.state.initialEventId} - inviteSignUrl={this.state.inviteSignUrl} + thirdPartyInvite={this.state.thirdPartyInvite} oobData={this.state.roomOobData} highlightedEventId={this.state.highlightedEventId} eventPixelOffset={this.state.initialEventPixelOffset} diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 1cb576d14f..ddf0571511 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -60,9 +60,12 @@ module.exports = React.createClass({ // useful for joining rooms by alias correctly (and fixing https://github.com/vector-im/vector-web/issues/819) roomAlias: React.PropTypes.string, - // The URL used to join this room from an email invite - // (given as part of the link in the invite email) - inviteSignUrl: React.PropTypes.string, + // An object representing a third party invite to join this room + // Fields: + // * inviteSignUrl (string) The URL used to join this room from an email invite + // (given as part of the link in the invite email) + // * invitedEmail (string) The email address that was invited to this room + thirdPartyInvite: React.PropTypes.object, // Any data about the room that would normally come from the Home Server // but has been passed out-of-band, eg. the room name and avatar URL @@ -544,8 +547,9 @@ module.exports = React.createClass({ } display_name_promise.then(() => { + var sign_url = this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : undefined; return MatrixClientPeg.get().joinRoom(this.props.roomAlias || this.props.roomId, - { inviteSignUrl: this.props.inviteSignUrl } ) + { inviteSignUrl: sign_url } ) }).done(function() { // It is possible that there is no Room yet if state hasn't come down // from /sync - joinRoom will resolve when the HTTP request to join succeeds, @@ -1105,7 +1109,13 @@ module.exports = React.createClass({ if (this.props.oobData) { inviterName = this.props.oobData.inviterName; } + var invitedEmail = undefined; + if (this.props.thirdPartyInvite) { + invitedEmail = this.props.thirdPartyInvite.invitedEmail; + } + // We have no room object for this room, only the ID. + // We've got to this room by following a link, possibly a third party invite. return (
@@ -1115,6 +1125,7 @@ module.exports = React.createClass({ canJoin={ true } canPreview={ false } spinner={this.state.joining} inviterName={inviterName} + invitedEmail={invitedEmail} room={this.state.room} />
@@ -1147,6 +1158,7 @@ module.exports = React.createClass({ // as they could be a spam vector. // XXX: in future we could give the option of a 'Preview' button which lets them view anyway. + // We have a regular invite for this room. return (
@@ -1218,29 +1230,28 @@ module.exports = React.createClass({ else if (this.state.searching) { aux = ; } - else if (this.state.guestsCanJoin && MatrixClientPeg.get().isGuest() && - (!myMember || myMember.membership !== "join")) { + else if (!myMember || myMember.membership !== "join") { + // We do have a room object for this room, but we're not currently in it. + // We may have a 3rd party invite to it. var inviterName = undefined; if (this.props.oobData) { inviterName = this.props.oobData.inviterName; } + var invitedEmail = undefined; + if (this.props.thirdPartyInvite) { + invitedEmail = this.props.thirdPartyInvite.invitedEmail; + } aux = ( ); } - else if (!myMember || myMember.membership !== "join") { - aux = ( - - ); - } var auxPanel = ( { + 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 (
@@ -54,6 +82,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 address 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 = (
@@ -62,6 +105,7 @@ module.exports = React.createClass({
Would you like to accept or decline this invitation?
+ {emailMatchBlock}
);