Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
ansuz 4 years ago
commit c10a49145d

@ -179,5 +179,24 @@ define(function() {
// You can change the value here.
// config.maxOwnedTeams = 5;
// The userlist displayed in collaborative documents is stored alongside the document data.
// Everytime someone with edit rights joins a document or modify their user data (display
// name, avatar, color, etc.), they update the "userlist" part of the document. When too many
// editors are in the same document, all these changes increase the risks of conflicts which
// require CPU time to solve. A "degraded" mode can now be set when a certain number of editors
// are in a document at the same time. This mode disables the userlist, the chat and the
// position of other users' cursor. You can configure the number of user from which the session
// will enter into degraded mode. A big number may result in collaborative edition being broken,
// but this number depends on the network and CPU performances of each user's device.
config.degradedLimit = 8;
// In "legacy" mode, one-time users were always creating an "anonymous" drive when visiting CryptPad
// in which they could store their pads. The new "driveless" mode allow users to open an existing
// pad without creating a drive in the background. The drive will only be created if they visit
// a different page (Drive, Settings, etc.) or try to create a new pad themselves. You can disable
// the driveless mode by changing the following value to "false"
config.allowDrivelessMode = true;
config.allowDrivelessMode = true;
return config;
});

@ -1095,6 +1095,7 @@ define([
common.changePadPassword = function (Crypt, Crypto, data, cb) {
var href = data.href;
var oldPassword = data.oldPassword;
var newPassword = data.password;
var teamId = data.teamId;
if (!href) { return void cb({ error: 'EINVAL_HREF' }); }
@ -1123,7 +1124,9 @@ define([
var isSharedFolder = parsed.type === 'drive';
var optsGet = {};
var optsGet = {
password: oldPassword
};
var optsPut = {
password: newPassword,
metadata: {},
@ -1133,7 +1136,7 @@ define([
var cryptgetVal;
Nthen(function (waitFor) {
if (parsed.hashData && parsed.hashData.password) {
if (parsed.hashData && parsed.hashData.password && !oldPassword) {
common.getPadAttribute('password', waitFor(function (err, password) {
optsGet.password = password;
}), href);
@ -1418,6 +1421,7 @@ define([
common.changeOOPassword = function (data, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
var href = data.href;
var oldPassword = data.oldPassword;
var newPassword = data.password;
var teamId = data.teamId;
if (!href) { return void cb({ error: 'EINVAL_HREF' }); }
@ -1452,12 +1456,16 @@ define([
validateKey: newSecret.keys.validateKey
},
};
var optsGet = {};
var optsGet = {
password: oldPassword
};
Nthen(function (waitFor) {
common.getPadAttribute('', waitFor(function (err, _data) {
padData = _data;
optsGet.password = padData.password;
if (!oldPassword) {
optsGet.password = padData.password;
}
}), href);
common.getAccessKeys(waitFor(function (keys) {
optsGet.accessKeys = keys;

@ -888,9 +888,16 @@ define([
});
}
var href = data.href;
var hashes = priv.hashes || {};
var bestHash = hashes.editHash || hashes.viewHash || hashes.fileHash;
if (data.fakeHref) {
href = Hash.hashToHref(bestHash, priv.app);
}
sframeChan.query(q, {
teamId: typeof(owned) !== "boolean" ? owned : undefined,
href: data.href,
href: href,
oldPassword: priv.password,
password: newPass
}, function (err, data) {
$(passwordOk).text(Messages.properties_changePasswordButton);
@ -956,7 +963,7 @@ define([
spinner.spin();
sframeChan.query('Q_DELETE_OWNED', {
teamId: typeof(owned) !== "boolean" ? owned : undefined,
channel: data.channel
channel: data.channel || priv.channel
}, function (err, obj) {
spinner.done();
UI.findCancelButton().click();

@ -331,6 +331,8 @@ define([
teamId = data.teamId;
}
// XXX CLEAR CACHE
if (channel === store.driveChannel && !force) {
return void cb({error: 'User drive removal blocked!'});
}
@ -586,11 +588,14 @@ define([
var proxy = store.proxy || {};
var disableThumbnails = Util.find(proxy, ['settings', 'general', 'disableThumbnails']);
var teams = (store.modules['team'] && store.modules['team'].getTeamsData(app)) || {};
if (!proxy.uid) {
store.noDriveUid = store.noDriveUid || Hash.createChannelId();
}
var metadata = {
// "user" is shared with everybody via the userlist
user: {
name: proxy[Constants.displayNameKey] || store.noDriveName || "",
uid: proxy.uid || Hash.createChannelId(), // Random uid in nodrive mode
uid: proxy.uid || store.noDriveUid, // Random uid in nodrive mode
avatar: Util.find(proxy, ['profile', 'avatar']),
profile: Util.find(proxy, ['profile', 'view']),
color: getUserColor(),
@ -858,6 +863,7 @@ define([
Store.setDisplayName = function (clientId, value, cb) {
if (!store.proxy) {
store.noDriveName = value;
broadcast([clientId], "UPDATE_METADATA");
return void cb();
}
if (store.modules['profile']) {
@ -2836,7 +2842,10 @@ define([
store.driveMetadata = info.metadata;
if (!rt.proxy.drive || typeof(rt.proxy.drive) !== 'object') { rt.proxy.drive = {}; }
if (!rt.proxy[Constants.displayNameKey] && store.noDriveName) {
store.proxy[Constants.displayNameKey] = store.noDriveName;
rt.proxy[Constants.displayNameKey] = store.noDriveName;
}
if (!rt.proxy.uid && store.noDriveUid) {
rt.proxy.uid = store.noDriveUid;
}
/*
// deprecating localStorage migration as of 4.2.0

@ -2,11 +2,12 @@ define([
'/common/common-util.js',
'/common/common-constants.js',
'/customize/messages.js',
'/customize/application_config.js',
'/bower_components/chainpad-crypto/crypto.js',
], function (Util, Constants, Messages, Crypto) {
], function (Util, Constants, Messages, AppConfig, Crypto) {
var Cursor = {};
var DEGRADED = 3; // XXX Number of users before switching to degraded mode
var DEGRADED = AppConfig.degradedLimit || 8;
var convertToUint8 = function (obj) {
var l = Object.keys(obj).length;
@ -50,6 +51,12 @@ define([
});
};
var updateDegraded = function (ctx, wc, chan) {
var m = wc.members;
chan.degraded = (m.length-1) >= DEGRADED;
ctx.emit('DEGRADED', { degraded: chan.degraded }, chan.clients);
};
var initCursor = function (ctx, obj, client, cb) {
var channel = obj.channel;
var secret = obj.secret;
@ -92,14 +99,10 @@ define([
// ==> And push the new tab to the list
chan.clients.push(client);
updateDegraded(ctx, chan.wc, chan);
return void cb();
}
var updateDegraded = function (ctx, wc, chan) {
var m = wc.members;
chan.degraded = (m.length-1) >= DEGRADED;
ctx.emit('DEGRADED', { degraded: chan.degraded }, chan.clients);
};
var onOpen = function (wc) {
ctx.channels[channel] = ctx.channels[channel] || {};

@ -868,7 +868,6 @@ define([
if (fId && Env.folders[fId] && Env.folders[fId].deleting) {
delete Env.folders[fId].deleting;
}
console.error(obj.error, chan);
Feedback.send('ERROR_DELETING_OWNED_PAD=' + chan + '|' + obj.error, true);
return void cb();
}
@ -881,6 +880,11 @@ define([
ids.push(fId);
}
if (!ids.length) {
toDelete = undefined;
return void cb();
}
ids.forEach(function (id) {
var paths = findFile(Env, id);
var _resolved = _resolvePaths(Env, paths);
@ -912,8 +916,13 @@ define([
});
});
}).nThen(function () {
// Remove deleted pads from the drive
_delete(Env, { resolved: toDelete }, cb);
if (!toDelete) {
// Nothing to delete
cb();
} else {
// Remove deleted pads from the drive
_delete(Env, { resolved: toDelete }, cb);
}
// If we were using the access modal, send a refresh command
if (data.channel) {
Env.Store.refreshDriveUI();

@ -221,8 +221,11 @@ define([
}
} catch (e) { console.error(e); }
// NOTE: Driveless mode should only work for existing pads, but we can't check that
// before creating the worker because we need the anon RPC to do so.
// We're only going to check if a hash exists in the URL or not.
Cryptpad.ready(waitFor(), {
noDrive: cfg.noDrive,
noDrive: cfg.noDrive && AppConfig.allowDrivelessMode && currentPad.hash,
driveEvents: cfg.driveEvents,
cache: Boolean(cfg.cache),
currentPad: currentPad
@ -1404,6 +1407,7 @@ define([
};
config.data = {
app: parsed.type,
channel: secret.channel,
hashes: hashes,
password: password,
isTemplate: isTemplate,

@ -212,6 +212,7 @@ MessengerUI, Messages) {
var $editUsersList = $('<div>', {'class': 'cp-toolbar-userlist-others'})
.appendTo($editUsers);
var degradedLimit = Config.degradedLimit || 8;
if (!online) {
$('<em>').text(Messages.userlist_offline).appendTo($editUsersList);
numberOfEditUsers = '?';
@ -219,8 +220,7 @@ MessengerUI, Messages) {
} else if (metadataMgr.isDegraded() === true) {
numberOfEditUsers = Math.max(metadataMgr.getChannelMembers().length - 1, 0);
numberOfViewUsers = '';
Messages.toolbar_degraded = "Too many editors are present in the pad. The userlist has been disabled to improve performances"; // XXX
$('<em>').text(Messages.toolbar_degraded).appendTo($editUsersList);
$('<em>').text(Messages._getKey('toolbar_degraded', [degradedLimit])).appendTo($editUsersList);
}
// Update the buttons

@ -44,6 +44,7 @@ define([
meta.debugDrive = drive;
};
SFCommonO.start({
noDrive: true,
addData:addData
});
});

@ -101,6 +101,7 @@ define([
origin: window.location.origin,
pathname: window.location.pathname,
feedbackAllowed: Utils.Feedback.state,
channel: config.data.channel,
hashes: config.data.hashes,
password: config.data.password,
propChannels: config.data.getPropChannels(),

Loading…
Cancel
Save