From 826a86c7d6602e71b5bec314362cd44209b05b06 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 19 Dec 2019 16:21:10 +0100 Subject: [PATCH] Fix joining your own team --- www/common/outer/team.js | 13 ++++++++++++- www/teams/inner.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index ef2fabd59..b7d6e3fb7 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -1489,6 +1489,17 @@ define([ inviteContent = obj; })); }).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 var rosterData = Util.find(inviteContent, ['teamData', 'keys', 'roster']); var myKeys = inviteContent.ephemeral; @@ -1512,12 +1523,12 @@ define([ var state = roster.getState(); rosterState = state.members[myKeys.curvePublic]; roster.accept(myData.curvePublic, waitFor(function (err) { + roster.stop(); if (err) { waitFor.abort(); console.error(err); return void cb({error: 'ACCEPT_ERROR'}); } - roster.stop(); })); })); }).nThen(function () { diff --git a/www/teams/inner.js b/www/teams/inner.js index 913ca4ca8..fb80caeb2 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -1127,6 +1127,7 @@ define([ password: pw, }, waitFor(function (obj) { if (obj && obj.error) { + console.error(obj.error); // Wrong password or other error... waitFor.abort(); if (obj.error === 'INVALID_INVITE_CONTENT') {