Fix transfer ownership to ourselves via a team

This commit is contained in:
yflory 2019-10-28 14:30:32 +01:00
parent 93e4c8a9e2
commit 07fbe6c284

View File

@ -164,7 +164,7 @@ define([
var ed = $(el).attr('data-ed'); var ed = $(el).attr('data-ed');
if (!ed) { return; } if (!ed) { return; }
if (teamOwner && teams[teamOwner] && teams[teamOwner].edPublic === ed) { me = true; } if (teamOwner && teams[teamOwner] && teams[teamOwner].edPublic === ed) { me = true; }
if (ed === edPublic) { me = true; } if (ed === edPublic && !teamOwner) { me = true; }
return ed; return ed;
}).filter(function (x) { return x; }); }).filter(function (x) { return x; });
NThen(function (waitFor) { NThen(function (waitFor) {
@ -195,7 +195,8 @@ define([
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
sel.forEach(function (el) { sel.forEach(function (el) {
var friend = friends[$(el).attr('data-curve')]; var curve = $(el).attr('data-curve');
var friend = curve === user.curvePublic ? user : friends[curve];
if (!friend) { return; } if (!friend) { return; }
common.mailbox.sendTo("RM_OWNER", { common.mailbox.sendTo("RM_OWNER", {
channel: channel, channel: channel,
@ -264,7 +265,10 @@ define([
var sel = $sel.toArray(); var sel = $sel.toArray();
if (!sel.length) { return; } if (!sel.length) { return; }
var toAdd = sel.map(function (el) { var toAdd = sel.map(function (el) {
var friend = friends[$(el).attr('data-curve')]; var curve = $(el).attr('data-curve');
// If the pad is woned by a team, we can transfer ownership to ourselves
if (curve === user.curvePublic && teamOwner) { return priv.edPublic; }
var friend = friends[curve];
if (!friend) { return; } if (!friend) { return; }
return friend.edPublic; return friend.edPublic;
}).filter(function (x) { return x; }); }).filter(function (x) { return x; });
@ -340,7 +344,8 @@ define([
} }
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
sel.forEach(function (el) { sel.forEach(function (el) {
var friend = friends[$(el).attr('data-curve')]; var curve = $(el).attr('data-curve');
var friend = curve === user.curvePublic ? user : friends[curve];
if (!friend) { return; } if (!friend) { return; }
common.mailbox.sendTo("ADD_OWNER", { common.mailbox.sendTo("ADD_OWNER", {
channel: channel, channel: channel,