|
|
@ -7,12 +7,11 @@ IMPLEMENTED:
|
|
|
|
RESTRICT_REGISTRATION(<boolean>)
|
|
|
|
RESTRICT_REGISTRATION(<boolean>)
|
|
|
|
UPDATE_DEFAULT_STORAGE(<number>)
|
|
|
|
UPDATE_DEFAULT_STORAGE(<number>)
|
|
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QUOTA MANAGEMENT
|
|
|
|
// QUOTA MANAGEMENT
|
|
|
|
ADD_QUOTA
|
|
|
|
SET_QUOTA(<string:signkey>, limit)
|
|
|
|
RM_QUOTA(<string: unsafekey>)
|
|
|
|
RM_QUOTA(<string:signkey>)
|
|
|
|
UPDATE_QUOTA
|
|
|
|
|
|
|
|
|
|
|
|
NOT IMPLEMENTED:
|
|
|
|
|
|
|
|
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
|
// RESTRICTED REGISTRATION
|
|
|
|
ADD_INVITE
|
|
|
|
ADD_INVITE
|
|
|
@ -73,24 +72,34 @@ commands.UPDATE_DEFAULT_STORAGE = function (Env, args) {
|
|
|
|
|
|
|
|
|
|
|
|
var Quota = require("./commands/quota");
|
|
|
|
var Quota = require("./commands/quota");
|
|
|
|
var Keys = require("./keys");
|
|
|
|
var Keys = require("./keys");
|
|
|
|
|
|
|
|
var Util = require("./common-util");
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['ADD_QUOTA', ['[user@box:3000/VzeS4vP1DF+tXGuq1i50DKYuBL+09Yqy8kGxoUKRzhA=]', { limit: 2 * 1024 * 1024 * 1024, plan: 'buddy', note: "you're welcome" } ] ] ], console.log)
|
|
|
|
var getCanonicalKey = function (input) {
|
|
|
|
commands.ADD_QUOTA = function (Env, args) {
|
|
|
|
if (typeof(input) !== 'string') { return; }
|
|
|
|
|
|
|
|
// key is already in simple form. ensure that it is an 'unsafeKey'
|
|
|
|
|
|
|
|
if (input.length === 44) {
|
|
|
|
|
|
|
|
return Util.unescapeKeyCharacters(input);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return Keys.parseUser(input).pubkey;
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_QUOTA', ['[user@box:3000/VzeS4vP1DF+tXGuq1i50DKYuBL+09Yqy8kGxoUKRzhA=]', { limit: 2 * 1024 * 1024 * 1024, plan: 'buddy', note: "you're welcome" } ] ] ], console.log)
|
|
|
|
|
|
|
|
commands.SET_QUOTA = function (Env, args) {
|
|
|
|
if (!Array.isArray(args) || args.length !== 2) {
|
|
|
|
if (!Array.isArray(args) || args.length !== 2) {
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var publicSigningKey = args[0];
|
|
|
|
var unsafeKey = getCanonicalKey(args[0]);
|
|
|
|
// this might throw, but that's fine
|
|
|
|
if (!unsafeKey) {
|
|
|
|
var user = Keys.parseUser(publicSigningKey);
|
|
|
|
|
|
|
|
if (!user || !user.pubkey || user.pubkey.length !== 44) {
|
|
|
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// make sure you're not overwriting an existing limit
|
|
|
|
// make sure you're not overwriting an existing limit
|
|
|
|
if (Env.customLimits[user.pubkey]) {
|
|
|
|
//if (Env.customLimits[unsafeKey]) { throw new Error("EEXISTS"); }
|
|
|
|
throw new Error("EEXISTS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var limit = args[1];
|
|
|
|
var limit = args[1];
|
|
|
|
if (!Quota.isValidLimit(limit)) { // do we really want this?
|
|
|
|
if (!Quota.isValidLimit(limit)) { // do we really want this?
|
|
|
@ -98,20 +107,28 @@ commands.ADD_QUOTA = function (Env, args) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// map the new limit to the user's unsafeKey
|
|
|
|
// map the new limit to the user's unsafeKey
|
|
|
|
Env.customLimits[user.pubkey] = limit;
|
|
|
|
Env.customLimits[unsafeKey] = limit;
|
|
|
|
Env.limits[user.pubkey] = limit;
|
|
|
|
Env.limits[unsafeKey] = limit;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
commands.RM_QUOTA = function (Env, args) {
|
|
|
|
commands.RM_QUOTA = function (Env, args) {
|
|
|
|
args = args;
|
|
|
|
if (!Array.isArray(args) || args.length !== 1) {
|
|
|
|
throw new Error("NOT_IMPLEMENTED");
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
commands.UPDATE_QUOTA = function (Env, args) {
|
|
|
|
var unsafeKey = getCanonicalKey(args[0]);
|
|
|
|
args = args;
|
|
|
|
if (!unsafeKey) {
|
|
|
|
throw new Error("NOT_IMPLEMENTED");
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Env.customLimits[unsafeKey]) {
|
|
|
|
|
|
|
|
throw new Error("ENOENT");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete Env.customLimits[unsafeKey];
|
|
|
|
|
|
|
|
delete Env.limits[unsafeKey];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// [<command>, <args>, <author>, <time>]
|
|
|
|
// [<command>, <args>, <author>, <time>]
|
|
|
@ -164,7 +181,6 @@ Decrees.createLineHandler = function (Env) {
|
|
|
|
var Fs = require("fs");
|
|
|
|
var Fs = require("fs");
|
|
|
|
var Path = require("path");
|
|
|
|
var Path = require("path");
|
|
|
|
var readFileBin = require("./stream-file").readFileBin;
|
|
|
|
var readFileBin = require("./stream-file").readFileBin;
|
|
|
|
var Util = require("./common-util");
|
|
|
|
|
|
|
|
var Schedule = require("./schedule");
|
|
|
|
var Schedule = require("./schedule");
|
|
|
|
var Fse = require("fs-extra");
|
|
|
|
var Fse = require("fs-extra");
|
|
|
|
var nThen = require("nthen");
|
|
|
|
var nThen = require("nthen");
|
|
|
|