|
|
|
@ -5,6 +5,7 @@ var Decrees = module.exports;
|
|
|
|
|
IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
RESTRICT_REGISTRATION
|
|
|
|
|
UPDATE_DEFAULT_STORAGE
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
@ -15,7 +16,6 @@ ADD_INVITE
|
|
|
|
|
REVOKE_INVITE
|
|
|
|
|
REDEEM_INVITE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var commands = {};
|
|
|
|
@ -33,6 +33,7 @@ var commands = {};
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
@ -43,13 +44,23 @@ commands.RESTRICT_REGISTRATION = function (Env, args) {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
|
throw new Error('INVALID_ARGS');
|
|
|
|
|
}
|
|
|
|
|
var limit = args[0];
|
|
|
|
|
if (limit === Env.defaultStorageLimit) { return false; }
|
|
|
|
|
Env.defaultStorageLimit = limit;
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// [<command>, <args>, <author>, <time>]
|
|
|
|
|
var handleCommand = Decrees.handleCommand = function (Env, line) {
|
|
|
|
|
var command = line[0];
|
|
|
|
|
var args = line[1];
|
|
|
|
|
|
|
|
|
|
if (typeof(commands[command]) !== 'function') {
|
|
|
|
|
console.error(line);
|
|
|
|
|
throw new Error("DECREE_UNSUPPORTED_COMMAND");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,7 +112,7 @@ Decrees.load = function (Env, cb) {
|
|
|
|
|
Env.scheduleDecree = Env.scheduleDecree || Schedule();
|
|
|
|
|
|
|
|
|
|
var decreePath = Env.paths.decree;
|
|
|
|
|
var decreeName = Path.join(Env.paths.decree, 'decree.ndjson'); // XXX
|
|
|
|
|
var decreeName = Path.join(Env.paths.decree, 'decree.ndjson');
|
|
|
|
|
|
|
|
|
|
var stream = Fs.createReadStream(decreeName, {start: 0});
|
|
|
|
|
|
|
|
|
|