|
|
|
@ -4,18 +4,30 @@ var Decrees = module.exports;
|
|
|
|
|
|
|
|
|
|
IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
RESTRICT_REGISTRATION
|
|
|
|
|
UPDATE_DEFAULT_STORAGE
|
|
|
|
|
RESTRICT_REGISTRATION(<boolean>)
|
|
|
|
|
UPDATE_DEFAULT_STORAGE(<number>)
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
// QUOTA MANAGEMENT
|
|
|
|
|
ADD_QUOTA
|
|
|
|
|
RM_QUOTA
|
|
|
|
|
RM_QUOTA(<string: unsafekey>)
|
|
|
|
|
UPDATE_QUOTA
|
|
|
|
|
|
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
|
|
ADD_INVITE
|
|
|
|
|
REVOKE_INVITE
|
|
|
|
|
REDEEM_INVITE
|
|
|
|
|
|
|
|
|
|
// 2.0
|
|
|
|
|
UPDATE_INACTIVE_TIME
|
|
|
|
|
UPDATE_ACCOUNT_RETENTION_TIME
|
|
|
|
|
UPDATE_ARCHIVE_RETENTION_TIME
|
|
|
|
|
|
|
|
|
|
// 3.0
|
|
|
|
|
UPDATE_MAX_UPLOAD_SIZE
|
|
|
|
|
UPDATE_PREMIUM_UPLOAD_SIZE
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var commands = {};
|
|
|
|
@ -44,9 +56,13 @@ commands.RESTRICT_REGISTRATION = function (Env, args) {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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) || typeof(args[0]) !== 'number' || isNaN(args[0]) || args[0] < 0) {
|
|
|
|
|
if (!Array.isArray(args) || isNonNegativeNumber(args[0])) {
|
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
|
}
|
|
|
|
|
var limit = args[0];
|
|
|
|
@ -55,6 +71,23 @@ commands.UPDATE_DEFAULT_STORAGE = function (Env, args) {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//var Quota = require("./commands/quota");
|
|
|
|
|
|
|
|
|
|
commands.ADD_QUOTA = function (Env, args) {
|
|
|
|
|
args = args;
|
|
|
|
|
throw new Error("NOT_IMPLEMENTED");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
commands.RM_QUOTA = function (Env, args) {
|
|
|
|
|
args = args;
|
|
|
|
|
throw new Error("NOT_IMPLEMENTED");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
commands.UPDATE_QUOTA = function (Env, args) {
|
|
|
|
|
args = args;
|
|
|
|
|
throw new Error("NOT_IMPLEMENTED");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// [<command>, <args>, <author>, <time>]
|
|
|
|
|
var handleCommand = Decrees.handleCommand = function (Env, line) {
|
|
|
|
|
var command = line[0];
|
|
|
|
@ -111,8 +144,7 @@ var Schedule = require("./schedule");
|
|
|
|
|
Decrees.load = function (Env, cb) {
|
|
|
|
|
Env.scheduleDecree = Env.scheduleDecree || Schedule();
|
|
|
|
|
|
|
|
|
|
var decreePath = Env.paths.decree;
|
|
|
|
|
var decreeName = Path.join(Env.paths.decree, 'decree.ndjson');
|
|
|
|
|
var decreeName = Path.join(Env.paths.decree, 'decree.ndjson'); // XXX mkdirp
|
|
|
|
|
|
|
|
|
|
var stream = Fs.createReadStream(decreeName, {start: 0});
|
|
|
|
|
|
|
|
|
|