mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-02 01:45:46 +08:00
expose more limits
This commit is contained in:
parent
f7eee84845
commit
31d80c6dc6
4 changed files with 77 additions and 8 deletions
|
@ -417,9 +417,15 @@ module.exports = (db, server, userHandler) => {
|
|||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
|
||||
imapMaxUpload: Joi.number().min(0),
|
||||
imapMaxDownload: Joi.number().min(0),
|
||||
pop3MaxDownload: Joi.number().min(0),
|
||||
imapMaxUpload: Joi.number()
|
||||
.min(0)
|
||||
.default(0),
|
||||
imapMaxDownload: Joi.number()
|
||||
.min(0)
|
||||
.default(0),
|
||||
pop3MaxDownload: Joi.number()
|
||||
.min(0)
|
||||
.default(0),
|
||||
|
||||
tags: Joi.array().items(
|
||||
Joi.string()
|
||||
|
@ -812,10 +818,31 @@ module.exports = (db, server, userHandler) => {
|
|||
db.redis
|
||||
.multi()
|
||||
// sending counters are stored in Redis
|
||||
|
||||
// sent messages
|
||||
.get('wdr:' + userData._id.toString())
|
||||
.ttl('wdr:' + userData._id.toString())
|
||||
|
||||
// forwarded messages
|
||||
.get('wdf:' + userData._id.toString())
|
||||
.ttl('wdf:' + userData._id.toString())
|
||||
|
||||
// rate limited recipient
|
||||
.get('rl:rcpt:' + userData._id.toString())
|
||||
.ttl('rl:rcpt:' + userData._id.toString())
|
||||
|
||||
// rate limited imap uploads
|
||||
.get('iup:' + userData._id.toString())
|
||||
.ttl('iup:' + userData._id.toString())
|
||||
|
||||
// rate limited imap downloads
|
||||
.get('idw:' + userData._id.toString())
|
||||
.ttl('idw:' + userData._id.toString())
|
||||
|
||||
// rate limited pop3 downloads
|
||||
.get('pdw:' + userData._id.toString())
|
||||
.ttl('pdw:' + userData._id.toString())
|
||||
|
||||
.exec((err, result) => {
|
||||
if (err) {
|
||||
// ignore
|
||||
|
@ -831,6 +858,18 @@ module.exports = (db, server, userHandler) => {
|
|||
let forwardsSent = Number(result && result[2] && result[2][1]) || 0;
|
||||
let forwardsTtl = Number(result && result[3] && result[3][1]) || 0;
|
||||
|
||||
let received = Number(result && result[4] && result[4][1]) || 0;
|
||||
let receivedTtl = Number(result && result[5] && result[5][1]) || 0;
|
||||
|
||||
let imapUpload = Number(result && result[6] && result[6][1]) || 0;
|
||||
let imapUploadTtl = Number(result && result[7] && result[7][1]) || 0;
|
||||
|
||||
let imapDownload = Number(result && result[8] && result[8][1]) || 0;
|
||||
let imapDownloadTtl = Number(result && result[9] && result[9][1]) || 0;
|
||||
|
||||
let pop3Download = Number(result && result[10] && result[10][1]) || 0;
|
||||
let pop3DownloadTtl = Number(result && result[11] && result[11][1]) || 0;
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
id: user,
|
||||
|
@ -858,15 +897,41 @@ module.exports = (db, server, userHandler) => {
|
|||
allowed: Number(userData.quota) || config.maxStorage * 1024 * 1024,
|
||||
used: Math.max(Number(userData.storageUsed) || 0, 0)
|
||||
},
|
||||
|
||||
recipients: {
|
||||
allowed: recipients,
|
||||
used: recipientsSent,
|
||||
ttl: recipientsTtl >= 0 ? recipientsTtl : false
|
||||
},
|
||||
|
||||
forwards: {
|
||||
allowed: forwards,
|
||||
used: forwardsSent,
|
||||
ttl: forwardsTtl >= 0 ? forwardsTtl : false
|
||||
},
|
||||
|
||||
received: {
|
||||
allowed: 150, // TODO: most probably should be read from config or user data
|
||||
used: received,
|
||||
ttl: receivedTtl >= 0 ? receivedTtl : false
|
||||
},
|
||||
|
||||
imapUpload: {
|
||||
allowed: Number(userData.imapMaxUpload) || (config.imap.maxUploadMB || 10) * 1024 * 1024,
|
||||
used: imapUpload,
|
||||
ttl: imapUploadTtl >= 0 ? imapUploadTtl : false
|
||||
},
|
||||
|
||||
imapDownload: {
|
||||
allowed: Number(userData.imapMaxDownload) || (config.imap.maxDownloadMB || 10) * 1024 * 1024,
|
||||
used: imapDownload,
|
||||
ttl: imapDownloadTtl >= 0 ? imapDownloadTtl : false
|
||||
},
|
||||
|
||||
pop3Download: {
|
||||
allowed: Number(userData.pop3MaxDownload) || (config.pop3.maxDownloadMB || 10) * 1024 * 1024,
|
||||
used: pop3Download,
|
||||
ttl: pop3DownloadTtl >= 0 ? pop3DownloadTtl : false
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ let getDBConnection = (main, config, callback) => {
|
|||
return callback(null, main.db(config));
|
||||
}
|
||||
}
|
||||
MongoClient.connect(config, (err, db) => {
|
||||
MongoClient.connect(config, { useNewUrlParser: true }, (err, db) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
|
|
@ -1033,6 +1033,10 @@ class UserHandler {
|
|||
recipients: data.recipients || 0,
|
||||
forwards: data.forwards || 0,
|
||||
|
||||
imapMaxUpload: data.imapMaxUpload || 0,
|
||||
imapMaxDownload: data.imapMaxDownload || 0,
|
||||
pop3MaxDownload: data.pop3MaxDownload || 0,
|
||||
|
||||
targets: [].concat(data.targets || []),
|
||||
|
||||
// autoreply status
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"eslint-config-nodemailer": "^1.2.0",
|
||||
"grunt": "^1.0.3",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-eslint": "^20.1.0",
|
||||
"grunt-eslint": "^20.2.0",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"grunt-shell-spawn": "^0.3.10",
|
||||
"grunt-wait": "^0.1.0",
|
||||
|
@ -49,16 +49,16 @@
|
|||
"js-yaml": "3.12.0",
|
||||
"key-fingerprint": "1.1.0",
|
||||
"libbase64": "1.0.2",
|
||||
"libmime": "3.1.0",
|
||||
"libmime": "4.0.0",
|
||||
"libqp": "1.1.0",
|
||||
"linkify-it": "2.0.3",
|
||||
"mailsplit": "4.1.2",
|
||||
"mailsplit": "4.2.0",
|
||||
"mobileconfig": "2.1.0",
|
||||
"mongo-cursor-pagination-node6": "5.0.0",
|
||||
"mongodb": "3.1.0-beta4",
|
||||
"mongodb-extended-json": "1.10.0",
|
||||
"node-forge": "0.7.5",
|
||||
"nodemailer": "4.6.5",
|
||||
"nodemailer": "4.6.6",
|
||||
"npmlog": "4.1.2",
|
||||
"openpgp": "3.0.11",
|
||||
"pem": "^1.12.5",
|
||||
|
|
Loading…
Add table
Reference in a new issue