|
|
@ -11,6 +11,13 @@ UPDATE_DEFAULT_STORAGE(<number>)
|
|
|
|
SET_QUOTA(<string:signkey>, limit)
|
|
|
|
SET_QUOTA(<string:signkey>, limit)
|
|
|
|
RM_QUOTA(<string:signkey>)
|
|
|
|
RM_QUOTA(<string:signkey>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET_MAX_UPLOAD_SIZE
|
|
|
|
|
|
|
|
SET_PREMIUM_UPLOAD_SIZE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BACKGROUND PROCESSES
|
|
|
|
|
|
|
|
DISABLE_INTEGRATED_TASKS
|
|
|
|
|
|
|
|
DISABLE_INTEGRATED_EVICTION
|
|
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
@ -24,18 +31,9 @@ UPDATE_ACCOUNT_RETENTION_TIME
|
|
|
|
UPDATE_ARCHIVE_RETENTION_TIME
|
|
|
|
UPDATE_ARCHIVE_RETENTION_TIME
|
|
|
|
|
|
|
|
|
|
|
|
// 3.0
|
|
|
|
// 3.0
|
|
|
|
UPDATE_MAX_UPLOAD_SIZE
|
|
|
|
|
|
|
|
UPDATE_PREMIUM_UPLOAD_SIZE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4.0
|
|
|
|
|
|
|
|
Env.adminEmail
|
|
|
|
Env.adminEmail
|
|
|
|
Env.supportMailbox
|
|
|
|
Env.supportMailbox
|
|
|
|
Env.DEV_MODE || Env.FRESH_MODE,
|
|
|
|
Env.DEV_MODE || Env.FRESH_MODE,
|
|
|
|
Env.maxUploadSize
|
|
|
|
|
|
|
|
Env.premiumUploadSize
|
|
|
|
|
|
|
|
Env.disableIntegratedTasks
|
|
|
|
|
|
|
|
Env.disableIntegratedEviction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
var commands = {};
|
|
|
|
var commands = {};
|
|
|
@ -52,33 +50,69 @@ var commands = {};
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var args_isBoolean = function (args) {
|
|
|
|
|
|
|
|
return !(!Array.isArray(args) || typeof(args[0]) !== 'boolean');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Toggles a simple boolean
|
|
|
|
// Toggles a simple boolean
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['RESTRICT_REGISTRATION', [true]]], console.log)
|
|
|
|
var makeBooleanSetter = function (attr) {
|
|
|
|
commands.RESTRICT_REGISTRATION = function (Env, args) {
|
|
|
|
return function (Env, args) {
|
|
|
|
if (!Array.isArray(args) || typeof(args[0]) !== 'boolean') {
|
|
|
|
if (!args_isBoolean(args)) {
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var bool = args[0];
|
|
|
|
var bool = args[0];
|
|
|
|
if (bool === Env.restrictRegistration) { return false; }
|
|
|
|
if (bool === Env[attr]) { return false; }
|
|
|
|
Env.restrictRegistration = bool;
|
|
|
|
Env[attr] = bool;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['RESTRICT_REGISTRATION', [true]]], console.log)
|
|
|
|
|
|
|
|
commands.RESTRICT_REGISTRATION = makeBooleanSetter('restrictRegistration');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['DISABLE_INTEGRATED_EVICTION', [true]]], console.log)
|
|
|
|
|
|
|
|
commands.DISABLE_INTEGRATED_EVICTION = makeBooleanSetter('disableIntegratedEviction');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['DISABLE_INTEGRATED_TASKS', [true]]], console.log)
|
|
|
|
|
|
|
|
commands.DISABLE_INTEGRATED_TASKS = makeBooleanSetter('disableIntegratedTasks');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
var isNonNegativeNumber = function (n) {
|
|
|
|
var isNonNegativeNumber = function (n) {
|
|
|
|
return !(typeof(n) !== 'number' || isNaN(n) || n < 0);
|
|
|
|
return !(typeof(n) !== 'number' || isNaN(n) || n < 0);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['UPDATE_DEFAULT_STORAGE', [100 * 1024 * 1024]]], console.log)
|
|
|
|
var isInteger = function (n) {
|
|
|
|
commands.UPDATE_DEFAULT_STORAGE = function (Env, args) {
|
|
|
|
return !(typeof(n) !== 'number' || isNaN(n) || (n % 1) !== 0);
|
|
|
|
if (!Array.isArray(args) || !isNonNegativeNumber(args[0])) {
|
|
|
|
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var limit = args[0];
|
|
|
|
|
|
|
|
if (limit === Env.defaultStorageLimit) { return false; }
|
|
|
|
|
|
|
|
Env.defaultStorageLimit = limit;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var args_isInteger = function (args) {
|
|
|
|
|
|
|
|
return !(!Array.isArray(args) || !isInteger(args[0]));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var makeIntegerSetter = function (attr) {
|
|
|
|
|
|
|
|
return function (Env, args) {
|
|
|
|
|
|
|
|
if (!args_isInteger(args)) {
|
|
|
|
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var integer = args[0];
|
|
|
|
|
|
|
|
if (integer === Env[attr]) { return false; }
|
|
|
|
|
|
|
|
Env[attr] = integer;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAX_UPLOAD_SIZE', [50 * 1024 * 1024]]], console.log)
|
|
|
|
|
|
|
|
commands.SET_MAX_UPLOAD_SIZE = makeIntegerSetter('maxUploadSize');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_PREMIUM_UPLOAD_SIZE', [150 * 1024 * 1024]]], console.log)
|
|
|
|
|
|
|
|
commands.SET_PREMIUM_UPLOAD_SIZE = makeIntegerSetter('premiumUploadSize');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['UPDATE_DEFAULT_STORAGE', [100 * 1024 * 1024]]], console.log)
|
|
|
|
|
|
|
|
commands.UPDATE_DEFAULT_STORAGE = makeIntegerSetter('defaultStorageLimit');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commands.SET_LAST_EVICTION = makeIntegerSetter('lastEviction');
|
|
|
|
|
|
|
|
|
|
|
|
var Quota = require("./commands/quota");
|
|
|
|
var Quota = require("./commands/quota");
|
|
|
|
var Keys = require("./keys");
|
|
|
|
var Keys = require("./keys");
|
|
|
|
var Util = require("./common-util");
|
|
|
|
var Util = require("./common-util");
|
|
|
|