allow settings receivedMax

This commit is contained in:
Andris Reinman 2018-06-12 13:45:02 +03:00
parent 6a16a08916
commit 5a0b00a7af
7 changed files with 28 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define({ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs", "title": "WildDuck API", "url": "https://api.wildduck.email", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2018-06-12T08:58:21.233Z", "url": "http://apidocjs.com", "version": "0.17.6" } }); define({ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs", "title": "WildDuck API", "url": "https://api.wildduck.email", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2018-06-12T10:44:54.834Z", "url": "http://apidocjs.com", "version": "0.17.6" } });

View file

@ -1 +1 @@
{ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs", "title": "WildDuck API", "url": "https://api.wildduck.email", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2018-06-12T08:58:21.233Z", "url": "http://apidocjs.com", "version": "0.17.6" } } { "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs", "title": "WildDuck API", "url": "https://api.wildduck.email", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2018-06-12T10:44:54.834Z", "url": "http://apidocjs.com", "version": "0.17.6" } }

View file

@ -309,6 +309,7 @@ module.exports = (db, server, userHandler) => {
* @apiParam {Number} [imapMaxUpload] How many bytes can be uploaded via IMAP during 24 hour * @apiParam {Number} [imapMaxUpload] How many bytes can be uploaded via IMAP during 24 hour
* @apiParam {Number} [imapMaxDownload] How many bytes can be downloaded via IMAP during 24 hour * @apiParam {Number} [imapMaxDownload] How many bytes can be downloaded via IMAP during 24 hour
* @apiParam {Number} [pop3MaxDownload] How many bytes can be downloaded via POP3 during 24 hour * @apiParam {Number} [pop3MaxDownload] How many bytes can be downloaded via POP3 during 24 hour
* @apiParam {Number} [receivedMax] How many messages can be received from MX during 1 hour
* @apiParam {String} [sess] Session identifier for the logs * @apiParam {String} [sess] Session identifier for the logs
* @apiParam {String} [ip] IP address for the logs * @apiParam {String} [ip] IP address for the logs
* *
@ -426,6 +427,9 @@ module.exports = (db, server, userHandler) => {
pop3MaxDownload: Joi.number() pop3MaxDownload: Joi.number()
.min(0) .min(0)
.default(0), .default(0),
receivedMax: Joi.number()
.min(0)
.default(0),
tags: Joi.array().items( tags: Joi.array().items(
Joi.string() Joi.string()
@ -928,7 +932,7 @@ module.exports = (db, server, userHandler) => {
}, },
received: { received: {
allowed: 150, // TODO: most probably should be read from config or user data allowed: Number(userData.receivedMax) || 150,
used: received, used: received,
ttl: receivedTtl >= 0 ? receivedTtl : false ttl: receivedTtl >= 0 ? receivedTtl : false
}, },
@ -992,6 +996,7 @@ module.exports = (db, server, userHandler) => {
* @apiParam {Number} [imapMaxUpload] How many bytes can be uploaded via IMAP during 24 hour * @apiParam {Number} [imapMaxUpload] How many bytes can be uploaded via IMAP during 24 hour
* @apiParam {Number} [imapMaxDownload] How many bytes can be downloaded via IMAP during 24 hour * @apiParam {Number} [imapMaxDownload] How many bytes can be downloaded via IMAP during 24 hour
* @apiParam {Number} [pop3MaxDownload] How many bytes can be downloaded via POP3 during 24 hour * @apiParam {Number} [pop3MaxDownload] How many bytes can be downloaded via POP3 during 24 hour
* @apiParam {Number} [receivedMax] How many messages can be received from MX during 1 hour
* @apiParam {Boolean} [disable2fa] If true, then disables 2FA for this user * @apiParam {Boolean} [disable2fa] If true, then disables 2FA for this user
* @apiParam {Boolean} [disabled] If true then disables user account (can not login, can not receive messages) * @apiParam {Boolean} [disabled] If true then disables user account (can not login, can not receive messages)
* @apiParam {String} [sess] Session identifier for the logs * @apiParam {String} [sess] Session identifier for the logs
@ -1080,6 +1085,7 @@ module.exports = (db, server, userHandler) => {
imapMaxUpload: Joi.number().min(0), imapMaxUpload: Joi.number().min(0),
imapMaxDownload: Joi.number().min(0), imapMaxDownload: Joi.number().min(0),
pop3MaxDownload: Joi.number().min(0), pop3MaxDownload: Joi.number().min(0),
receivedMax: Joi.number().min(0),
disable2fa: Joi.boolean() disable2fa: Joi.boolean()
.empty('') .empty('')

View file

@ -22,15 +22,23 @@ let getDBConnection = (main, config, callback) => {
return callback(null, main.db(config)); return callback(null, main.db(config));
} }
} }
MongoClient.connect(config, { useNewUrlParser: true }, (err, db) => { MongoClient.connect(
if (err) { config,
return callback(err); {
useNewUrlParser: true,
reconnectTries: 100000,
reconnectInterval: 1000
},
(err, db) => {
if (err) {
return callback(err);
}
if (main && db.s && db.s.options && db.s.options.dbName) {
db = db.db(db.s.options.dbName);
}
return callback(null, db);
} }
if (main && db.s && db.s.options && db.s.options.dbName) { );
db = db.db(db.s.options.dbName);
}
return callback(null, db);
});
}; };
module.exports.connect = callback => { module.exports.connect = callback => {

View file

@ -1036,6 +1036,7 @@ class UserHandler {
imapMaxUpload: data.imapMaxUpload || 0, imapMaxUpload: data.imapMaxUpload || 0,
imapMaxDownload: data.imapMaxDownload || 0, imapMaxDownload: data.imapMaxDownload || 0,
pop3MaxDownload: data.pop3MaxDownload || 0, pop3MaxDownload: data.pop3MaxDownload || 0,
receivedMax: data.receivedMax || 0,
targets: [].concat(data.targets || []), targets: [].concat(data.targets || []),