|
|
@ -1,4 +1,5 @@
|
|
|
|
var Decrees = module.exports;
|
|
|
|
var Decrees = module.exports;
|
|
|
|
|
|
|
|
var Core = require("./commands/core");
|
|
|
|
|
|
|
|
|
|
|
|
/* Admin decrees which modify global server state
|
|
|
|
/* Admin decrees which modify global server state
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +30,10 @@ SET_LAST_BROADCAST_HASH
|
|
|
|
SET_SURVEY_URL
|
|
|
|
SET_SURVEY_URL
|
|
|
|
SET_MAINTENANCE
|
|
|
|
SET_MAINTENANCE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// EASIER CONFIG
|
|
|
|
|
|
|
|
SET_ADMIN_EMAIL
|
|
|
|
|
|
|
|
SET_SUPPORT_MAILBOX
|
|
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
@ -37,9 +42,11 @@ REVOKE_INVITE
|
|
|
|
REDEEM_INVITE
|
|
|
|
REDEEM_INVITE
|
|
|
|
|
|
|
|
|
|
|
|
// 2.0
|
|
|
|
// 2.0
|
|
|
|
Env.adminEmail
|
|
|
|
|
|
|
|
Env.supportMailbox
|
|
|
|
|
|
|
|
Env.DEV_MODE || Env.FRESH_MODE,
|
|
|
|
Env.DEV_MODE || Env.FRESH_MODE,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ADD_ADMIN_KEY
|
|
|
|
|
|
|
|
RM_ADMIN_KEY
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
var commands = {};
|
|
|
|
var commands = {};
|
|
|
@ -88,6 +95,20 @@ var isNonNegativeNumber = function (n) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var default_validator = function () { return true; };
|
|
|
|
|
|
|
|
var makeGenericSetter = function (attr, validator) {
|
|
|
|
|
|
|
|
validator = validator || default_validator;
|
|
|
|
|
|
|
|
return function (Env, args) {
|
|
|
|
|
|
|
|
if (!validator(args)) {
|
|
|
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var value = args[0];
|
|
|
|
|
|
|
|
if (value === Env[attr]) { return false; }
|
|
|
|
|
|
|
|
Env[attr] = value;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var isInteger = function (n) {
|
|
|
|
var isInteger = function (n) {
|
|
|
|
return !(typeof(n) !== 'number' || isNaN(n) || (n % 1) !== 0);
|
|
|
|
return !(typeof(n) !== 'number' || isNaN(n) || (n % 1) !== 0);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -97,15 +118,7 @@ var args_isInteger = function (args) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var makeIntegerSetter = function (attr) {
|
|
|
|
var makeIntegerSetter = function (attr) {
|
|
|
|
return function (Env, args) {
|
|
|
|
return makeGenericSetter(attr, args_isInteger);
|
|
|
|
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)
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAX_UPLOAD_SIZE', [50 * 1024 * 1024]]], console.log)
|
|
|
@ -130,6 +143,14 @@ var args_isString = function (args) {
|
|
|
|
return Array.isArray(args) && typeof(args[0]) === "string";
|
|
|
|
return Array.isArray(args) && typeof(args[0]) === "string";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_ADMIN_EMAIL', ['admin@website.tld']]], console.log)
|
|
|
|
|
|
|
|
commands.SET_ADMIN_EMAIL = makeGenericSetter('adminEmail', args_isString);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_SUPPORT_MAILBOX', ["Tdz6+fE9N9XXBY93rW5qeNa/k27yd40c0vq7EJyt7jA="]]], console.log)
|
|
|
|
|
|
|
|
commands.SET_SUPPORT_MAILBOX = makeGenericSetter('supportMailbox', function (args) {
|
|
|
|
|
|
|
|
return args_isString(args) && Core.isValidPublicKey(args[0]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Maintenance: Empty string or an object with a start and end time
|
|
|
|
// Maintenance: Empty string or an object with a start and end time
|
|
|
|
var isNumber = function (value) {
|
|
|
|
var isNumber = function (value) {
|
|
|
|
return typeof(value) === "number" && !isNaN(value);
|
|
|
|
return typeof(value) === "number" && !isNaN(value);
|
|
|
|