Merge branch 'communities-allow-list' of github.com:xwiki-labs/cryptpad into communities-allow-list

pull/1/head
ansuz 5 years ago
commit 77785e79af

@ -36,6 +36,27 @@ define([
})); }));
}; };
var isOwned = function (common, data) {
data = data || {};
var priv = common.getMetadataMgr().getPrivateData();
var edPublic = priv.edPublic;
var owned = false;
if (Array.isArray(data.owners) && data.owners.length) {
if (data.owners.indexOf(edPublic) !== -1) {
owned = true;
} else {
Object.keys(priv.teams || {}).some(function (id) {
var team = priv.teams[id] || {};
if (team.viewer) { return; }
if (data.owners.indexOf(team.edPublic) === -1) { return; }
owned = id;
return true;
});
}
}
return owned;
};
var getOwnersTab = function (common, data, opts, _cb) { var getOwnersTab = function (common, data, opts, _cb) {
var cb = Util.once(Util.mkAsync(_cb)); var cb = Util.once(Util.mkAsync(_cb));
@ -350,6 +371,7 @@ define([
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
var user = common.getMetadataMgr().getUserData(); var user = common.getMetadataMgr().getUserData();
var edPublic = priv.edPublic; var edPublic = priv.edPublic;
var channel = data.channel; var channel = data.channel;
var owners = data.owners || []; var owners = data.owners || [];
@ -428,6 +450,7 @@ define([
var ed = $el.attr('data-ed'); var ed = $el.attr('data-ed');
if (!ed) { return; } if (!ed) { return; }
nThen(function (waitFor) { nThen(function (waitFor) {
/*
var msg = Messages.allow_removeConfirm; var msg = Messages.allow_removeConfirm;
UI.confirm(msg, waitFor(function (yes) { UI.confirm(msg, waitFor(function (yes) {
if (!yes) { if (!yes) {
@ -436,6 +459,7 @@ define([
} }
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
*/
// Send the command // Send the command
sframeChan.query('Q_SET_PAD_METADATA', { sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel, channel: channel,
@ -570,6 +594,7 @@ define([
}).filter(function (x) { return x; }); }).filter(function (x) { return x; });
nThen(function (waitFor) { nThen(function (waitFor) {
/*
var msg = Messages.allow_addConfirm; var msg = Messages.allow_addConfirm;
UI.confirm(msg, waitFor(function (yes) { UI.confirm(msg, waitFor(function (yes) {
if (!yes) { if (!yes) {
@ -578,6 +603,7 @@ define([
} }
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
*/
// Offer ownership to a friend // Offer ownership to a friend
if (toAdd.length) { if (toAdd.length) {
// Send the command // Send the command
@ -629,27 +655,6 @@ define([
cb(void 0, link); cb(void 0, link);
}; };
var isOwned = function (common, data) {
data = data || {};
var priv = common.getMetadataMgr().getPrivateData();
var edPublic = priv.edPublic;
var owned = false;
if (Array.isArray(data.owners) && data.owners.length) {
if (data.owners.indexOf(edPublic) !== -1) {
owned = true;
} else {
Object.keys(priv.teams || {}).some(function (id) {
var team = priv.teams[id] || {};
if (team.viewer) { return; }
if (data.owners.indexOf(team.edPublic) === -1) { return; }
owned = id;
return true;
});
}
}
return owned;
};
var getUserList = function (common, list) { var getUserList = function (common, list) {
if (!Array.isArray(list)) { return; } if (!Array.isArray(list)) { return; }
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
@ -1060,6 +1065,9 @@ define([
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
var owned = isOwned(common, data); var owned = isOwned(common, data);
if (typeof(owned) !== "boolean") {
data.teamId = Number(owned);
}
var parsed = Hash.parsePadUrl(data.href || data.roHref); var parsed = Hash.parsePadUrl(data.href || data.roHref);
disabled = !owned || !parsed.hashData || parsed.hashData.type !== 'pad'; disabled = !owned || !parsed.hashData || parsed.hashData.type !== 'pad';
allowDisabled = parsed.type === 'drive'; allowDisabled = parsed.type === 'drive';

Loading…
Cancel
Save