implement ADD_QUOTA admin decree
parent
998f2267c4
commit
af47b2cab1
|
@ -71,11 +71,37 @@ commands.UPDATE_DEFAULT_STORAGE = function (Env, args) {
|
|||
return true;
|
||||
};
|
||||
|
||||
//var Quota = require("./commands/quota");
|
||||
var Quota = require("./commands/quota");
|
||||
var Keys = require("./keys");
|
||||
|
||||
// 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)
|
||||
commands.ADD_QUOTA = function (Env, args) {
|
||||
args = args;
|
||||
throw new Error("NOT_IMPLEMENTED");
|
||||
if (!Array.isArray(args) || args.length !== 2) {
|
||||
throw new Error("INVALID_ARGS");
|
||||
}
|
||||
|
||||
var publicSigningKey = args[0];
|
||||
// this might throw, but that's fine
|
||||
var user = Keys.parseUser(publicSigningKey);
|
||||
if (!user || !user.pubkey || user.pubkey.length !== 44) {
|
||||
throw new Error("INVALID_ARGS");
|
||||
}
|
||||
|
||||
// make sure you're not overwriting an existing limit
|
||||
if (Env.customLimits[user.pubkey]) {
|
||||
throw new Error("EEXISTS");
|
||||
}
|
||||
|
||||
var limit = args[1];
|
||||
if (!Quota.isValidLimit(limit)) { // do we really want this?
|
||||
throw new Error("INVALID_ARGS");
|
||||
}
|
||||
|
||||
// map the new limit to the user's unsafeKey
|
||||
Env.customLimits[user.pubkey] = limit;
|
||||
Env.limits[user.pubkey] = limit;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
commands.RM_QUOTA = function (Env, args) {
|
||||
|
|
Loading…
Reference in New Issue