Merge pull request #233 from matrix-org/dbkr/show_invited_email
Display a warning if a third party invite for a room was sent to an address that is not bound publicly to our accountpull/21833/head
commit
03de19cd27
|
@ -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}
|
||||
|
|
|
@ -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 (
|
||||
<div className="mx_RoomView">
|
||||
<RoomHeader ref="header" room={this.state.room} oobData={this.props.oobData} />
|
||||
|
@ -1115,6 +1125,7 @@ module.exports = React.createClass({
|
|||
canJoin={ true } canPreview={ false }
|
||||
spinner={this.state.joining}
|
||||
inviterName={inviterName}
|
||||
invitedEmail={invitedEmail}
|
||||
room={this.state.room}
|
||||
/>
|
||||
</div>
|
||||
|
@ -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 (
|
||||
<div className="mx_RoomView">
|
||||
<RoomHeader ref="header" room={this.state.room}/>
|
||||
|
@ -1218,29 +1230,28 @@ module.exports = React.createClass({
|
|||
else if (this.state.searching) {
|
||||
aux = <SearchBar ref="search_bar" searchInProgress={this.state.searchInProgress } onCancelClick={this.onCancelSearchClick} onSearch={this.onSearch}/>;
|
||||
}
|
||||
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 = (
|
||||
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked} canJoin={true}
|
||||
onRejectClick={ this.onRejectThreepidInviteButtonClicked }
|
||||
onRejectClick={this.onRejectThreepidInviteButtonClicked}
|
||||
spinner={this.state.joining}
|
||||
inviterName={inviterName}
|
||||
invitedEmail={invitedEmail}
|
||||
canPreview={this.state.canPeek}
|
||||
room={this.state.room}
|
||||
/>
|
||||
);
|
||||
}
|
||||
else if (!myMember || myMember.membership !== "join") {
|
||||
aux = (
|
||||
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked} canJoin={true}
|
||||
spinner={this.state.joining} canPreview={ this.state.canPeek }
|
||||
room={this.state.room}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
var auxPanel = (
|
||||
<AuxPanel ref="auxPanel" room={this.state.room}
|
||||
|
|
|
@ -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',
|
||||
|
@ -29,6 +30,9 @@ module.exports = React.createClass({
|
|||
// if inviterName is specified, the preview bar will shown an invite to the room.
|
||||
// You should also specify onRejectClick if specifiying inviterName
|
||||
inviterName: React.PropTypes.string,
|
||||
|
||||
// If invited by 3rd party invite, the email address the invite was sent to
|
||||
invitedEmail: React.PropTypes.string,
|
||||
canJoin: React.PropTypes.bool,
|
||||
canPreview: React.PropTypes.bool,
|
||||
spinner: React.PropTypes.bool,
|
||||
|
@ -43,10 +47,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 (<div className="mx_RoomPreviewBar">
|
||||
<Spinner />
|
||||
|
@ -54,6 +82,21 @@ module.exports = React.createClass({
|
|||
}
|
||||
|
||||
if (this.props.inviterName) {
|
||||
var emailMatchBlock;
|
||||
if (this.props.invitedEmail) {
|
||||
if (this.state.threePidFetchError) {
|
||||
emailMatchBlock = <div className="error">
|
||||
Vector was unable to ascertain that the address this invite was
|
||||
sent to matches one associated with your account.
|
||||
</div>
|
||||
} else if (this.state.invitedEmailMxid != MatrixClientPeg.get().credentials.userId) {
|
||||
emailMatchBlock = <div className="warning">
|
||||
<img src="img/warning.svg" width="24" height="23" title= "/!\\" alt="/!\\" />
|
||||
This invitation was sent to <span className="email">{this.props.invitedEmail}</span>
|
||||
which is not publicly associated with your account.
|
||||
</div>
|
||||
}
|
||||
}
|
||||
joinBlock = (
|
||||
<div>
|
||||
<div className="mx_RoomPreviewBar_invite_text">
|
||||
|
@ -62,6 +105,7 @@ module.exports = React.createClass({
|
|||
<div className="mx_RoomPreviewBar_join_text">
|
||||
Would you like to <a onClick={ this.props.onJoinClick }>accept</a> or <a onClick={ this.props.onRejectClick }>decline</a> this invitation?
|
||||
</div>
|
||||
{emailMatchBlock}
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue