|
|
|
@ -74,26 +74,13 @@ var Quota = require("./commands/quota");
|
|
|
|
|
var Keys = require("./keys");
|
|
|
|
|
var Util = require("./common-util");
|
|
|
|
|
|
|
|
|
|
var getCanonicalKey = function (input) {
|
|
|
|
|
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) {
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var unsafeKey = getCanonicalKey(args[0]);
|
|
|
|
|
var unsafeKey = Keys.canonicalize(args[0]);
|
|
|
|
|
if (!unsafeKey) {
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
}
|
|
|
|
@ -119,7 +106,7 @@ commands.RM_QUOTA = function (Env, args) {
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var unsafeKey = getCanonicalKey(args[0]);
|
|
|
|
|
var unsafeKey = Keys.canonicalize(args[0]);
|
|
|
|
|
if (!unsafeKey) {
|
|
|
|
|
throw new Error("INVALID_ARGS");
|
|
|
|
|
}
|
|
|
|
|