Merge pull request #168 from matrix-org/dbkr/keypair_3pid_invites

Wire up support for keypair 3pid invites.
This commit is contained in:
David Baker 2016-02-23 16:37:55 +00:00
commit b384d8c91a
2 changed files with 16 additions and 4 deletions

View File

@ -316,7 +316,7 @@ module.exports = React.createClass({
}); });
break; break;
case 'view_room': case 'view_room':
this._viewRoom(payload.room_id, payload.show_settings, payload.event_id); this._viewRoom(payload.room_id, payload.show_settings, payload.event_id, payload.invite_sign_url);
break; break;
case 'view_prev_room': case 'view_prev_room':
roomIndexDelta = -1; roomIndexDelta = -1;
@ -353,6 +353,7 @@ module.exports = React.createClass({
action: 'view_room', action: 'view_room',
room_id: foundRoom.roomId, room_id: foundRoom.roomId,
event_id: payload.event_id, event_id: payload.event_id,
invite_sign_url: payload.invite_sign_url,
}); });
return; return;
} }
@ -363,6 +364,7 @@ module.exports = React.createClass({
action: 'view_room', action: 'view_room',
room_id: result.room_id, room_id: result.room_id,
event_id: payload.event_id, event_id: payload.event_id,
invite_sign_url: payload.invite_sign_url,
}); });
}); });
break; break;
@ -438,7 +440,7 @@ module.exports = React.createClass({
// //
// eventId is optional and will cause a switch to the context of that // eventId is optional and will cause a switch to the context of that
// particular event. // particular event.
_viewRoom: function(roomId, showSettings, eventId) { _viewRoom: function(roomId, showSettings, eventId, invite_sign_url) {
// before we switch room, record the scroll state of the current room // before we switch room, record the scroll state of the current room
this._updateScrollMap(); this._updateScrollMap();
@ -450,6 +452,7 @@ module.exports = React.createClass({
highlightedEventId: eventId, highlightedEventId: eventId,
initialEventPixelOffset: undefined, initialEventPixelOffset: undefined,
page_type: this.PageTypes.RoomView, page_type: this.PageTypes.RoomView,
inviteSignUrl: invite_sign_url,
}; };
// if we aren't given an explicit event id, look for one in the // if we aren't given an explicit event id, look for one in the
@ -540,9 +543,11 @@ module.exports = React.createClass({
action: 'view_room_alias', action: 'view_room_alias',
room_alias: self.starting_room_alias, room_alias: self.starting_room_alias,
event_id: self.starting_event_id, event_id: self.starting_event_id,
invite_sign_url: self.starting_room_invite_sign_url,
}); });
delete self.starting_room_alias; delete self.starting_room_alias;
delete self.starting_event_id; delete self.starting_event_id;
delete self.starting_room_invite_sign_url;
} else if (!self.state.page_type) { } else if (!self.state.page_type) {
if (!self.state.currentRoom) { if (!self.state.currentRoom) {
var firstRoom = null; var firstRoom = null;
@ -659,7 +664,6 @@ module.exports = React.createClass({
action: 'start_post_registration', action: 'start_post_registration',
}); });
} else if (screen.indexOf('room/') == 0) { } else if (screen.indexOf('room/') == 0) {
if (!this.state.logged_in && this.props.startingQueryParams.email) { if (!this.state.logged_in && this.props.startingQueryParams.email) {
console.log("Redirecting to email registration"); console.log("Redirecting to email registration");
this.showScreen("register"); this.showScreen("register");
@ -676,10 +680,12 @@ module.exports = React.createClass({
action: 'view_room_alias', action: 'view_room_alias',
room_alias: roomString, room_alias: roomString,
event_id: eventId, event_id: eventId,
invite_sign_url: params.signurl,
}); });
} else { } else {
// Okay, we'll take you here soon... // Okay, we'll take you here soon...
this.starting_room_alias = roomString; this.starting_room_alias = roomString;
this.starting_room_invite_sign_url = params.signurl;
this.starting_event_id = eventId; this.starting_event_id = eventId;
// ...but you're still going to have to log in. // ...but you're still going to have to log in.
this.notifyNewScreen('login'); this.notifyNewScreen('login');
@ -689,6 +695,7 @@ module.exports = React.createClass({
action: 'view_room', action: 'view_room',
room_id: roomString, room_id: roomString,
event_id: eventId, event_id: eventId,
invite_sign_url: params.signurl,
}); });
} }
} }
@ -875,6 +882,7 @@ module.exports = React.createClass({
ref="roomView" ref="roomView"
roomId={this.state.currentRoom} roomId={this.state.currentRoom}
eventId={this.state.initialEventId} eventId={this.state.initialEventId}
inviteSignUrl={this.state.inviteSignUrl}
highlightedEventId={this.state.highlightedEventId} highlightedEventId={this.state.highlightedEventId}
eventPixelOffset={this.state.initialEventPixelOffset} eventPixelOffset={this.state.initialEventPixelOffset}
key={this.state.currentRoom} key={this.state.currentRoom}

View File

@ -63,6 +63,10 @@ module.exports = React.createClass({
roomId: React.PropTypes.string.isRequired, roomId: React.PropTypes.string.isRequired,
// 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,
// id of an event to jump to. If not given, will go to the end of the // id of an event to jump to. If not given, will go to the end of the
// live timeline. // live timeline.
eventId: React.PropTypes.string, eventId: React.PropTypes.string,
@ -707,7 +711,7 @@ module.exports = React.createClass({
} }
display_name_promise.then(() => { display_name_promise.then(() => {
return MatrixClientPeg.get().joinRoom(this.props.roomId) return MatrixClientPeg.get().joinRoom(this.props.roomId, { inviteSignUrl: this.props.inviteSignUrl } )
}).done(function() { }).done(function() {
// It is possible that there is no Room yet if state hasn't come down // 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, // from /sync - joinRoom will resolve when the HTTP request to join succeeds,