From 4869b4e0c3c888492bc576ede0ae8e9abb100344 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 19 Dec 2019 11:56:20 +0100 Subject: [PATCH] Delete invitation after using it --- www/common/outer/team.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 1c28da681..ef2fabd59 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -1478,6 +1478,7 @@ define([ var acceptLinkInvitation = function (ctx, data, cId, cb) { var inviteContent; + var rosterState; nThen(function (waitFor) { // Get team keys and ephemeral keys getInviteContent(ctx, data, cId, waitFor(function (obj) { @@ -1508,6 +1509,8 @@ define([ return void cb({error: 'ROSTER_ERROR'}); } var myData = Messaging.createData(ctx.store.proxy, false); + var state = roster.getState(); + rosterState = state.members[myKeys.curvePublic]; roster.accept(myData.curvePublic, waitFor(function (err) { if (err) { waitFor.abort(); @@ -1518,6 +1521,21 @@ define([ })); })); }).nThen(function () { + var tempRpc = {}; + initRpc(ctx, tempRpc, inviteContent.ephemeral, function (err) { + if (err) { return; } + var rpc = tempRpc.rpc; + if (rosterState.inviteChannel) { + rpc.removeOwnedChannel(rosterState.inviteChannel, function (err) { + if (err) { console.error(err); } + }); + } + if (rosterState.previewChannel) { + rpc.removeOwnedChannel(rosterState.previewChannel, function (err) { + if (err) { console.error(err); } + }); + } + }); // Add the team to our list and join... joinTeam(ctx, { team: inviteContent.teamData