implement SET_ADMIN_EMAIL and SET_SUPPORT_MAILBOX decrees

and update changelog
pull/1/head
ansuz 4 years ago
parent bd37e45eb4
commit 8c61948d02

@ -5,6 +5,9 @@
* reminders in calendars
* import/export
* include LICENSE for ical.js
* translations
* out of BETA
* available from user admin menu
* use a specific version of bootstrap-tokenfield in bower.json
* don't create readmes
* support displaying a roadmap in static pages' footer
@ -18,6 +21,12 @@
* lock sheets faster when applying checkpoints
* guard against undefined checkpoints
* don't spam users with prompts to checkpoints when they can't
* decrees
* SET_ADMIN_EMAIL
* SET_SUPPORT_MAILBOX
* Add DAPSI to our sponsor list
* checkup
* check for duplicate or incorrect headers
# 4.4.0

@ -13,6 +13,10 @@ Core.isValidId = function (chan) {
[32, 33, 48].indexOf(chan.length) > -1;
};
Core.isValidPublicKey = function (owner) {
return typeof(owner) === 'string' && owner.length === 44;
};
var makeToken = Core.makeToken = function () {
return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
.toString(16);

@ -1,4 +1,5 @@
var Decrees = module.exports;
var Core = require("./commands/core");
/* Admin decrees which modify global server state
@ -29,6 +30,10 @@ SET_LAST_BROADCAST_HASH
SET_SURVEY_URL
SET_MAINTENANCE
// EASIER CONFIG
SET_ADMIN_EMAIL
SET_SUPPORT_MAILBOX
NOT IMPLEMENTED:
// RESTRICTED REGISTRATION
@ -37,9 +42,11 @@ REVOKE_INVITE
REDEEM_INVITE
// 2.0
Env.adminEmail
Env.supportMailbox
Env.DEV_MODE || Env.FRESH_MODE,
ADD_ADMIN_KEY
RM_ADMIN_KEY
*/
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) {
return !(typeof(n) !== 'number' || isNaN(n) || (n % 1) !== 0);
};
@ -97,15 +118,7 @@ var args_isInteger = function (args) {
};
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;
};
return makeGenericSetter(attr, args_isInteger);
};
// 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";
};
// 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
var isNumber = function (value) {
return typeof(value) === "number" && !isNaN(value);

@ -1,4 +1,5 @@
var Meta = module.exports;
var Core = require("./commands/core");
var deduplicate = require("./common-util").deduplicateString;
@ -35,9 +36,7 @@ the owners field is guaranteed to exist.
var commands = {};
var isValidPublicKey = function (owner) {
return typeof(owner) === 'string' && owner.length === 44;
};
var isValidPublicKey = Core.isValidPublicKey;
// isValidPublicKey is a better indication of what the above function does
// I'm preserving this function name in case we ever want to expand its

Loading…
Cancel
Save