|
|
@ -395,8 +395,7 @@ var getHash = function (Env, publicKey, cb) {
|
|
|
|
|
|
|
|
|
|
|
|
// The limits object contains storage limits for all the publicKey that have paid
|
|
|
|
// The limits object contains storage limits for all the publicKey that have paid
|
|
|
|
// To each key is associated an object containing the 'limit' value and a 'note' explaining that limit
|
|
|
|
// To each key is associated an object containing the 'limit' value and a 'note' explaining that limit
|
|
|
|
var limits = {};
|
|
|
|
var updateLimits = function (Env, config, publicKey, cb /*:(?string, ?any[])=>void*/) {
|
|
|
|
var updateLimits = function (config, publicKey, cb /*:(?string, ?any[])=>void*/) {
|
|
|
|
|
|
|
|
if (config.adminEmail === false) {
|
|
|
|
if (config.adminEmail === false) {
|
|
|
|
if (config.allowSubscriptions === false) { return; }
|
|
|
|
if (config.allowSubscriptions === false) { return; }
|
|
|
|
throw new Error("allowSubscriptions must be false if adminEmail is false");
|
|
|
|
throw new Error("allowSubscriptions must be false if adminEmail is false");
|
|
|
@ -461,15 +460,15 @@ var updateLimits = function (config, publicKey, cb /*:(?string, ?any[])=>void*/)
|
|
|
|
response.on('end', function () {
|
|
|
|
response.on('end', function () {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
var json = JSON.parse(str);
|
|
|
|
var json = JSON.parse(str);
|
|
|
|
limits = json;
|
|
|
|
Env.limits = json;
|
|
|
|
Object.keys(customLimits).forEach(function (k) {
|
|
|
|
Object.keys(customLimits).forEach(function (k) {
|
|
|
|
if (!isLimit(customLimits[k])) { return; }
|
|
|
|
if (!isLimit(customLimits[k])) { return; }
|
|
|
|
limits[k] = customLimits[k];
|
|
|
|
Env.limits[k] = customLimits[k];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var l;
|
|
|
|
var l;
|
|
|
|
if (userId) {
|
|
|
|
if (userId) {
|
|
|
|
var limit = limits[userId];
|
|
|
|
var limit = Env.limits[userId];
|
|
|
|
l = limit && typeof limit.limit === "number" ?
|
|
|
|
l = limit && typeof limit.limit === "number" ?
|
|
|
|
[limit.limit, limit.plan, limit.note] : [defaultLimit, '', ''];
|
|
|
|
[limit.limit, limit.plan, limit.note] : [defaultLimit, '', ''];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -490,7 +489,7 @@ var updateLimits = function (config, publicKey, cb /*:(?string, ?any[])=>void*/)
|
|
|
|
|
|
|
|
|
|
|
|
var getLimit = function (Env, publicKey, cb) {
|
|
|
|
var getLimit = function (Env, publicKey, cb) {
|
|
|
|
var unescapedKey = unescapeKeyCharacters(publicKey);
|
|
|
|
var unescapedKey = unescapeKeyCharacters(publicKey);
|
|
|
|
var limit = limits[unescapedKey];
|
|
|
|
var limit = Env.limits[unescapedKey];
|
|
|
|
var defaultLimit = typeof(Env.defaultStorageLimit) === 'number'?
|
|
|
|
var defaultLimit = typeof(Env.defaultStorageLimit) === 'number'?
|
|
|
|
Env.defaultStorageLimit: DEFAULT_LIMIT;
|
|
|
|
Env.defaultStorageLimit: DEFAULT_LIMIT;
|
|
|
|
|
|
|
|
|
|
|
@ -1063,7 +1062,11 @@ type NetfluxWebsocketSrvContext_t = {
|
|
|
|
)=>void
|
|
|
|
)=>void
|
|
|
|
};
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
RPC.create = function (config /*:Config_t*/, cb /*:(?Error, ?Function)=>void*/) {
|
|
|
|
RPC.create = function (
|
|
|
|
|
|
|
|
config /*:Config_t*/,
|
|
|
|
|
|
|
|
debuggable /*:<T>(string, T)=>T*/,
|
|
|
|
|
|
|
|
cb /*:(?Error, ?Function)=>void*/
|
|
|
|
|
|
|
|
) {
|
|
|
|
// load pin-store...
|
|
|
|
// load pin-store...
|
|
|
|
console.log('loading rpc module...');
|
|
|
|
console.log('loading rpc module...');
|
|
|
|
|
|
|
|
|
|
|
@ -1081,8 +1084,10 @@ RPC.create = function (config /*:Config_t*/, cb /*:(?Error, ?Function)=>void*/)
|
|
|
|
msgStore: (undefined /*:any*/),
|
|
|
|
msgStore: (undefined /*:any*/),
|
|
|
|
pinStore: (undefined /*:any*/),
|
|
|
|
pinStore: (undefined /*:any*/),
|
|
|
|
pinnedPads: {},
|
|
|
|
pinnedPads: {},
|
|
|
|
evPinnedPadsReady: mkEvent(true)
|
|
|
|
evPinnedPadsReady: mkEvent(true),
|
|
|
|
|
|
|
|
limits: {}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
debuggable('rpc_env', Env);
|
|
|
|
|
|
|
|
|
|
|
|
var Sessions = Env.Sessions;
|
|
|
|
var Sessions = Env.Sessions;
|
|
|
|
var paths = Env.paths;
|
|
|
|
var paths = Env.paths;
|
|
|
@ -1264,7 +1269,7 @@ RPC.create = function (config /*:Config_t*/, cb /*:(?Error, ?Function)=>void*/)
|
|
|
|
Respond(e, size);
|
|
|
|
Respond(e, size);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
case 'UPDATE_LIMITS':
|
|
|
|
case 'UPDATE_LIMITS':
|
|
|
|
return void updateLimits(config, safeKey, function (e, limit) {
|
|
|
|
return void updateLimits(Env, config, safeKey, function (e, limit) {
|
|
|
|
if (e) {
|
|
|
|
if (e) {
|
|
|
|
WARN(e, limit);
|
|
|
|
WARN(e, limit);
|
|
|
|
return void Respond(e);
|
|
|
|
return void Respond(e);
|
|
|
@ -1376,7 +1381,7 @@ RPC.create = function (config /*:Config_t*/, cb /*:(?Error, ?Function)=>void*/)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateLimitDaily = function () {
|
|
|
|
var updateLimitDaily = function () {
|
|
|
|
updateLimits(config, undefined, function (e) {
|
|
|
|
updateLimits(Env, config, undefined, function (e) {
|
|
|
|
if (e) {
|
|
|
|
if (e) {
|
|
|
|
WARN('limitUpdate', e);
|
|
|
|
WARN('limitUpdate', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|