|
|
@ -1489,6 +1489,17 @@ define([
|
|
|
|
inviteContent = obj;
|
|
|
|
inviteContent = obj;
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
|
|
|
// Check if you're already a member of this team
|
|
|
|
|
|
|
|
var chan = Util.find(inviteContent, ['teamData', 'channel']);
|
|
|
|
|
|
|
|
var myTeams = ctx.store.proxy.teams || {};
|
|
|
|
|
|
|
|
var isMember = Object.keys(myTeams).some(function (k) {
|
|
|
|
|
|
|
|
var t = myTeams[k];
|
|
|
|
|
|
|
|
return t.channel === chan;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (isMember) {
|
|
|
|
|
|
|
|
waitFor.abort();
|
|
|
|
|
|
|
|
return void cb({error: 'ALREADY_MEMBER'});
|
|
|
|
|
|
|
|
}
|
|
|
|
// Accept the roster invitation: relplace our ephemeral keys with our user keys
|
|
|
|
// Accept the roster invitation: relplace our ephemeral keys with our user keys
|
|
|
|
var rosterData = Util.find(inviteContent, ['teamData', 'keys', 'roster']);
|
|
|
|
var rosterData = Util.find(inviteContent, ['teamData', 'keys', 'roster']);
|
|
|
|
var myKeys = inviteContent.ephemeral;
|
|
|
|
var myKeys = inviteContent.ephemeral;
|
|
|
@ -1512,12 +1523,12 @@ define([
|
|
|
|
var state = roster.getState();
|
|
|
|
var state = roster.getState();
|
|
|
|
rosterState = state.members[myKeys.curvePublic];
|
|
|
|
rosterState = state.members[myKeys.curvePublic];
|
|
|
|
roster.accept(myData.curvePublic, waitFor(function (err) {
|
|
|
|
roster.accept(myData.curvePublic, waitFor(function (err) {
|
|
|
|
|
|
|
|
roster.stop();
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
waitFor.abort();
|
|
|
|
waitFor.abort();
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
return void cb({error: 'ACCEPT_ERROR'});
|
|
|
|
return void cb({error: 'ACCEPT_ERROR'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
roster.stop();
|
|
|
|
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|