diff --git a/www/common/inner/access.js b/www/common/inner/access.js index e7f0fd5b2..31b488cb1 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -656,10 +656,8 @@ define([ var $sel = $div.find('.cp-usergrid-user.cp-selected'); var sel = $sel.toArray(); if (!sel.length) { return; } - var curves = []; var toAdd = sel.map(function (el) { var curve = $(el).attr('data-curve'); - curves.push(curve); var teamId = $(el).attr('data-teamid'); // If the pad is woned by a team, we can transfer ownership to ourselves if (curve === user.curvePublic && teamOwner) { return priv.edPublic; } @@ -691,14 +689,24 @@ define([ }, waitFor(function (err, res) { err = err || (res && res.error); redrawAll(true); - curves.forEach(function(curve){ - common.mailbox.sendTo("ADD_TO_ACCESS_LIST", { - channel: channel, - }, { - channel: friends[curve].notifications, - curvePublic: friends[curve].curvePublic - }); - }); + var $friends = $div.find('.cp-usergrid-user.cp-selected') + $friends.each(function (i, el) { + var curve = $(el).attr('data-curve'); + var ed = $(el).attr('data-ed'); + var friend = curve && friends[curve]; + var team = teamsData[ed]; + var mailbox = friend || team; + if (mailbox) { + if (friends[curve] && !mailbox.notifications) { return; } + if (mailbox.notifications && mailbox.curvePublic) { + common.mailbox.sendTo("ADD_TO_ACCESS_LIST", { + channel: channel, + }, { + channel: mailbox.notifications, + curvePublic: mailbox.curvePublic + }); + }} + }) if (err) { waitFor.abort();