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