mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-19 11:34:40 +08:00
do not COPY if QUOTA is full
This commit is contained in:
parent
977c36a0d5
commit
c1abce1363
2 changed files with 237 additions and 216 deletions
|
@ -88,9 +88,9 @@ module.exports = {
|
|||
TEMP_PASS_WINDOW: 24 * 3600 * 1000,
|
||||
|
||||
// mongdb query TTL limits
|
||||
DB_MAX_TIME_USERS: 1 * 1000,
|
||||
DB_MAX_TIME_MAILBOXES: 800,
|
||||
DB_MAX_TIME_MESSAGES: 60 * 1000,
|
||||
DB_MAX_TIME_USERS: 3 * 1000,
|
||||
DB_MAX_TIME_MAILBOXES: 3 * 1000,
|
||||
DB_MAX_TIME_MESSAGES: 2 * 60 * 1000,
|
||||
|
||||
// what is the max username part after wildcard
|
||||
MAX_ALLOWED_WILDCARD_LENGTH: 32,
|
||||
|
|
|
@ -18,6 +18,25 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
|||
update.destination
|
||||
);
|
||||
|
||||
db.users.collection('users').findOne(
|
||||
{
|
||||
_id: session.user.id
|
||||
},
|
||||
{
|
||||
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||
},
|
||||
(err, userData) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (!userData) {
|
||||
return callback(new Error('User not found'));
|
||||
}
|
||||
|
||||
if (userData.quota && userData.storageUsed > userData.quota) {
|
||||
return callback(false, 'OVERQUOTA');
|
||||
}
|
||||
|
||||
db.database.collection('mailboxes').findOne(
|
||||
{
|
||||
_id: mailbox
|
||||
|
@ -266,4 +285,6 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
|||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue