Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #59 from matrix-org/kegan/3pid-inv
Browse files Browse the repository at this point in the history
Finish 3PID invites impl
  • Loading branch information
kegsay committed Dec 17, 2015
2 parents 478ca91 + 12943b1 commit 498990b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,17 @@ class Register extends Signup {

_tryRegister(authDict) {
var self = this;

var bindEmail;

if (this.username && this.password) {
// only need to bind_email when sending u/p - sending it at other
// times clobbers the u/p resulting in M_MISSING_PARAM (password)
bindEmail = true;
}

return MatrixClientPeg.get().register(
this.username, this.password, this.params.sessionId, authDict
this.username, this.password, this.params.sessionId, authDict, bindEmail
).then(function(result) {
self.credentials = result;
self.setStep("COMPLETE");
Expand Down
19 changes: 18 additions & 1 deletion src/TextForEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ function textForMemberEvent(ev) {
) : "";
switch (ev.getContent().membership) {
case 'invite':
return senderName + " invited " + targetName + ".";
var threePidContent = ev.getContent().third_party_invite;
if (threePidContent) {
// TODO: When we have third_party_invite.display_name we should
// do this as "$displayname received the invitation from $sender"
// or equiv
return targetName + " received an invitation from " + senderName +
".";
}
else {
return senderName + " invited " + targetName + ".";
}
case 'ban':
return senderName + " banned " + targetName + "." + reason;
case 'join':
Expand Down Expand Up @@ -101,6 +111,12 @@ function textForCallInviteEvent(event) {
return senderName + " placed a " + type + " call." + supported;
};

function textForThreePidInviteEvent(event) {
var senderName = event.sender ? event.sender.name : event.getSender();
return senderName + " sent an invitation to " + event.getContent().display_name +
" to join the room.";
};

var handlers = {
'm.room.message': textForMessageEvent,
'm.room.name': textForRoomNameEvent,
Expand All @@ -109,6 +125,7 @@ var handlers = {
'm.call.invite': textForCallInviteEvent,
'm.call.answer': textForCallAnswerEvent,
'm.call.hangup': textForCallHangupEvent,
'm.room.third_party_invite': textForThreePidInviteEvent
};

module.exports = {
Expand Down
10 changes: 9 additions & 1 deletion src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = React.createClass({
config: React.PropTypes.object.isRequired,
ConferenceHandler: React.PropTypes.any,
onNewScreen: React.PropTypes.func,
registrationUrl: React.PropTypes.string
registrationUrl: React.PropTypes.string,
startingQueryParams: React.PropTypes.object
},

PageTypes: {
Expand Down Expand Up @@ -75,6 +76,12 @@ module.exports = React.createClass({
return s;
},

getDefaultProps: function() {
return {
startingQueryParams: {}
};
},

componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction);
if (this.state.logged_in) {
Expand Down Expand Up @@ -706,6 +713,7 @@ module.exports = React.createClass({
clientSecret={this.state.register_client_secret}
sessionId={this.state.register_session_id}
idSid={this.state.register_id_sid}
email={this.props.startingQueryParams.email}
hsUrl={this.props.config.default_hs_url}
isUrl={this.props.config.default_is_url}
registrationUrl={this.props.registrationUrl}
Expand Down
2 changes: 2 additions & 0 deletions src/components/structures/login/Registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = React.createClass({
idSid: React.PropTypes.string,
hsUrl: React.PropTypes.string,
isUrl: React.PropTypes.string,
email: React.PropTypes.string,
// registration shouldn't know or care how login is done.
onLoginClick: React.PropTypes.func.isRequired
},
Expand Down Expand Up @@ -185,6 +186,7 @@ module.exports = React.createClass({
registerStep = (
<RegistrationForm
showEmail={true}
defaultEmail={this.props.email}
minPasswordLength={MIN_PASSWORD_LENGTH}
onError={this.onFormValidationFailed}
onRegisterClick={this.onFormSubmit} />
Expand Down
1 change: 1 addition & 0 deletions src/components/views/rooms/EventTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var eventTileTypes = {
'm.call.hangup' : 'messages.TextualEvent',
'm.room.name' : 'messages.TextualEvent',
'm.room.topic' : 'messages.TextualEvent',
'm.room.third_party_invite': 'messages.TextualEvent'
};

var MAX_READ_AVATARS = 5;
Expand Down

0 comments on commit 498990b

Please sign in to comment.