|
|
@ -986,8 +986,20 @@ define([
|
|
|
|
var state = team.roster.getState() || {};
|
|
|
|
var state = team.roster.getState() || {};
|
|
|
|
var members = state.members || {};
|
|
|
|
var members = state.members || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var md;
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
// Get pending owners
|
|
|
|
// Get pending owners
|
|
|
|
var md = team.listmap.metadata || {};
|
|
|
|
ctx.Store.getPadMetadata(null, {
|
|
|
|
|
|
|
|
channel: teamData.channel
|
|
|
|
|
|
|
|
}, waitFor(function (obj) {
|
|
|
|
|
|
|
|
if (obj && obj.error) {
|
|
|
|
|
|
|
|
md = team.listmap.metadata || {};
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
md = obj;
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
ctx.pending_owners = md.pending_owners;
|
|
|
|
if (Array.isArray(md.pending_owners)) {
|
|
|
|
if (Array.isArray(md.pending_owners)) {
|
|
|
|
// Get the members associated to the pending_owners' edPublic and mark them as such
|
|
|
|
// Get the members associated to the pending_owners' edPublic and mark them as such
|
|
|
|
md.pending_owners.forEach(function (ed) {
|
|
|
|
md.pending_owners.forEach(function (ed) {
|
|
|
@ -1027,6 +1039,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cb(members);
|
|
|
|
cb(members);
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Return folders with edit rights available to everybody (decrypted pad href)
|
|
|
|
// Return folders with edit rights available to everybody (decrypted pad href)
|
|
|
@ -1144,8 +1157,7 @@ define([
|
|
|
|
if (!teamData) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
if (!teamData) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
var team = ctx.teams[teamId];
|
|
|
|
var team = ctx.teams[teamId];
|
|
|
|
if (!team) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
if (!team) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
var md = team.listmap.metadata || {};
|
|
|
|
var isPendingOwner = user.pendingOwner;
|
|
|
|
var isPendingOwner = (md.pending_owners || []).indexOf(user.edPublic) !== -1;
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
var cmd = isPendingOwner ? 'RM_PENDING_OWNERS' : 'RM_OWNERS';
|
|
|
|
var cmd = isPendingOwner ? 'RM_PENDING_OWNERS' : 'RM_OWNERS';
|
|
|
|
|
|
|
|
|
|
|
@ -1364,13 +1376,30 @@ define([
|
|
|
|
var describeUser = function (ctx, data, cId, cb) {
|
|
|
|
var describeUser = function (ctx, data, cId, cb) {
|
|
|
|
var teamId = data.teamId;
|
|
|
|
var teamId = data.teamId;
|
|
|
|
if (!teamId) { return void cb({error: 'EINVAL'}); }
|
|
|
|
if (!teamId) { return void cb({error: 'EINVAL'}); }
|
|
|
|
|
|
|
|
var teamData = Util.find(ctx, ['store', 'proxy', 'teams', teamId]);
|
|
|
|
var team = ctx.teams[teamId];
|
|
|
|
var team = ctx.teams[teamId];
|
|
|
|
if (!team) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
if (!teamData || !team) { return void cb ({error: 'ENOENT'}); }
|
|
|
|
if (!team.roster) { return void cb({error: 'NO_ROSTER'}); }
|
|
|
|
if (!team.roster) { return void cb({error: 'NO_ROSTER'}); }
|
|
|
|
if (!data.curvePublic || !data.data) { return void cb({error: 'MISSING_DATA'}); }
|
|
|
|
if (!data.curvePublic || !data.data) { return void cb({error: 'MISSING_DATA'}); }
|
|
|
|
var state = team.roster.getState();
|
|
|
|
var state = team.roster.getState();
|
|
|
|
var user = state.members[data.curvePublic];
|
|
|
|
var user = state.members[data.curvePublic];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var md;
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
|
|
|
// Get pending owners
|
|
|
|
|
|
|
|
ctx.Store.getPadMetadata(null, {
|
|
|
|
|
|
|
|
channel: teamData.channel
|
|
|
|
|
|
|
|
}, waitFor(function (obj) {
|
|
|
|
|
|
|
|
if (obj && obj.error) {
|
|
|
|
|
|
|
|
md = team.listmap.metadata || {};
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
md = obj;
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
user.pendingOwner = Array.isArray(md.pending_owners) &&
|
|
|
|
|
|
|
|
md.pending_owners.indexOf(user.edPublic) !== -1;
|
|
|
|
|
|
|
|
|
|
|
|
// It it is an ownership revocation, we have to set it in pad metadata first
|
|
|
|
// It it is an ownership revocation, we have to set it in pad metadata first
|
|
|
|
if (user.role === "OWNER" && data.data.role !== "OWNER") {
|
|
|
|
if (user.role === "OWNER" && data.data.role !== "OWNER") {
|
|
|
|
revokeOwnership(ctx, teamId, user, function (err) {
|
|
|
|
revokeOwnership(ctx, teamId, user, function (err) {
|
|
|
@ -1401,6 +1430,7 @@ define([
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
cb();
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var inviteToTeam = function (ctx, data, cId, cb) {
|
|
|
|
var inviteToTeam = function (ctx, data, cId, cb) {
|
|
|
|