allow administrators to increase limits for friends
This commit is contained in:
parent
087eee55f6
commit
c3e3da4948
@ -159,6 +159,24 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
defaultStorageLimit: 50 * 1024 * 1024,
|
defaultStorageLimit: 50 * 1024 * 1024,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CryptPad allows administrators to give custom limits to their friends.
|
||||||
|
* add an entry for each friend, identified by their user id,
|
||||||
|
* which can be found on the settings page. Include a 'limit' (number of bytes),
|
||||||
|
* a 'plan' (string), and a 'note' (string).
|
||||||
|
*
|
||||||
|
* hint: 1GB is 1024 * 1024 * 1024 bytes
|
||||||
|
*/
|
||||||
|
customLimits: {
|
||||||
|
/*
|
||||||
|
"https://my.awesome.website/user/#/1/cryptpad-user/YZgXQxKR0Rcb6r6CmxHPdAGLVludrAF2lEnkbx1vVOo=": {
|
||||||
|
limit: 20 * 1024 * 1024 * 1024,
|
||||||
|
plan: 'insider',
|
||||||
|
note: 'storage space donated by my.awesome.website'
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* By default, CryptPad also contacts our accounts server once a day to check for changes in
|
* By default, CryptPad also contacts our accounts server once a day to check for changes in
|
||||||
* the people who have accounts. This check-in will also send the version of your CryptPad
|
* the people who have accounts. This check-in will also send the version of your CryptPad
|
||||||
|
|||||||
26
rpc.js
26
rpc.js
@ -428,6 +428,27 @@ var updateLimits = function (config, publicKey, cb /*:(?string, ?any[])=>void*/)
|
|||||||
"Content-Length": Buffer.byteLength(body)
|
"Content-Length": Buffer.byteLength(body)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// read custom limits from the config
|
||||||
|
var customLimits = (function (custom) {
|
||||||
|
var limits = {};
|
||||||
|
Object.keys(custom).forEach(function (k) {
|
||||||
|
k.replace(/\/([^\/]+)$/, function (all, safeKey) {
|
||||||
|
var id = unescapeKeyCharacters(safeKey || '');
|
||||||
|
limits[id] = custom[k];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return limits;
|
||||||
|
}(config.customLimits || {}));
|
||||||
|
|
||||||
|
var isLimit = function (o) {
|
||||||
|
var valid = o && typeof(o) === 'object' &&
|
||||||
|
typeof(o.limit) === 'number' &&
|
||||||
|
typeof(o.plan) === 'string' &&
|
||||||
|
typeof(o.note) === 'string';
|
||||||
|
return valid;
|
||||||
|
};
|
||||||
|
|
||||||
var req = Https.request(options, function (response) {
|
var req = Https.request(options, function (response) {
|
||||||
if (!('' + response.statusCode).match(/^2\d\d$/)) {
|
if (!('' + response.statusCode).match(/^2\d\d$/)) {
|
||||||
return void cb('SERVER ERROR ' + response.statusCode);
|
return void cb('SERVER ERROR ' + response.statusCode);
|
||||||
@ -442,6 +463,11 @@ var updateLimits = function (config, publicKey, cb /*:(?string, ?any[])=>void*/)
|
|||||||
try {
|
try {
|
||||||
var json = JSON.parse(str);
|
var json = JSON.parse(str);
|
||||||
limits = json;
|
limits = json;
|
||||||
|
Object.keys(customLimits).forEach(function (k) {
|
||||||
|
if (!isLimit(customLimits[k])) { return; }
|
||||||
|
limits[k] = customLimits[k];
|
||||||
|
});
|
||||||
|
|
||||||
var l;
|
var l;
|
||||||
if (userId) {
|
if (userId) {
|
||||||
var limit = limits[userId];
|
var limit = limits[userId];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user