mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-11-11 00:41:37 +08:00
use constant definition instead of hardcoded TTL values
This commit is contained in:
parent
bda1cbd878
commit
8f2fdd8abf
18 changed files with 104 additions and 74 deletions
|
|
@ -82,5 +82,10 @@ module.exports = {
|
||||||
TASK_LOCK_INTERVAL: 1 * 60 * 60 * 1000,
|
TASK_LOCK_INTERVAL: 1 * 60 * 60 * 1000,
|
||||||
TASK_UPDATE_INTERVAL: 10 * 60 * 1000,
|
TASK_UPDATE_INTERVAL: 10 * 60 * 1000,
|
||||||
|
|
||||||
TEMP_PASS_WINDOW: 24 * 3600 * 1000
|
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: 10 * 1000
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const config = require('wild-config');
|
const config = require('wild-config');
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// APPEND mailbox (flags) date message
|
// APPEND mailbox (flags) date message
|
||||||
module.exports = (server, messageHandler, userCache) => (path, flags, date, raw, session, callback) => {
|
module.exports = (server, messageHandler, userCache) => (path, flags, date, raw, session, callback) => {
|
||||||
|
|
@ -20,7 +21,7 @@ module.exports = (server, messageHandler, userCache) => (path, flags, date, raw,
|
||||||
_id: session.user.id
|
_id: session.user.id
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
const ObjectID = require('mongodb').ObjectID;
|
const ObjectID = require('mongodb').ObjectID;
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
const tools = require('../tools');
|
const tools = require('../tools');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// COPY / UID COPY sequence mailbox
|
// COPY / UID COPY sequence mailbox
|
||||||
module.exports = (server, messageHandler) => (mailbox, update, session, callback) => {
|
module.exports = (server, messageHandler) => (mailbox, update, session, callback) => {
|
||||||
|
|
@ -22,7 +23,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
_id: mailbox
|
_id: mailbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -38,7 +39,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
path: update.destination
|
path: update.destination
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, targetData) => {
|
(err, targetData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -55,7 +56,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
uid: tools.checkRangeQuery(update.messages)
|
uid: tools.checkRangeQuery(update.messages)
|
||||||
}) // no projection as we need to copy the entire message
|
}) // no projection as we need to copy the entire message
|
||||||
.sort([['uid', 1]])
|
.sort([['uid', 1]])
|
||||||
.maxTimeMS(5000);
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
|
||||||
|
|
||||||
let copiedMessages = 0;
|
let copiedMessages = 0;
|
||||||
let copiedStorage = 0;
|
let copiedStorage = 0;
|
||||||
|
|
@ -78,7 +79,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
projection: {
|
projection: {
|
||||||
storageUsed: true
|
storageUsed: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(...args) => {
|
(...args) => {
|
||||||
let r = args && args[1];
|
let r = args && args[1];
|
||||||
|
|
@ -145,7 +146,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
modifyIndex: true
|
modifyIndex: true
|
||||||
},
|
},
|
||||||
returnOriginal: true,
|
returnOriginal: true,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, item) => {
|
(err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// DELETE "path/to/mailbox"
|
// DELETE "path/to/mailbox"
|
||||||
module.exports = (server, mailboxHandler) => (path, session, callback) => {
|
module.exports = (server, mailboxHandler) => (path, session, callback) => {
|
||||||
|
|
@ -20,7 +21,7 @@ module.exports = (server, mailboxHandler) => (path, session, callback) => {
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailbox) => {
|
(err, mailbox) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
const tools = require('../tools');
|
const tools = require('../tools');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// EXPUNGE deletes all messages in selected mailbox marked with \Delete
|
// EXPUNGE deletes all messages in selected mailbox marked with \Delete
|
||||||
module.exports = (server, messageHandler) => (mailbox, update, session, callback) => {
|
module.exports = (server, messageHandler) => (mailbox, update, session, callback) => {
|
||||||
|
|
@ -21,7 +22,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
_id: mailbox
|
_id: mailbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -80,7 +81,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
|
||||||
.collection('messages')
|
.collection('messages')
|
||||||
.find(query)
|
.find(query)
|
||||||
.sort([['uid', 1]])
|
.sort([['uid', 1]])
|
||||||
.maxTimeMS(5000);
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
|
||||||
|
|
||||||
let processNext = () => {
|
let processNext = () => {
|
||||||
cursor.next((err, messageData) => {
|
cursor.next((err, messageData) => {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi
|
||||||
_id: mailbox
|
_id: mailbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -125,7 +125,7 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi
|
||||||
.find(query)
|
.find(query)
|
||||||
.project(projection)
|
.project(projection)
|
||||||
.sort([['uid', 1]])
|
.sort([['uid', 1]])
|
||||||
.maxTimeMS(5000);
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
|
||||||
|
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
let totalBytes = 0;
|
let totalBytes = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
module.exports = server => (path, session, callback) => {
|
module.exports = server => (path, session, callback) => {
|
||||||
server.logger.debug(
|
server.logger.debug(
|
||||||
|
|
@ -19,7 +20,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailbox) => {
|
(err, mailbox) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -34,7 +35,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
_id: session.user.id
|
_id: session.user.id
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, user) => {
|
(err, user) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
module.exports = server => (quotaRoot, session, callback) => {
|
module.exports = server => (quotaRoot, session, callback) => {
|
||||||
server.logger.debug(
|
server.logger.debug(
|
||||||
|
|
@ -22,7 +23,7 @@ module.exports = server => (quotaRoot, session, callback) => {
|
||||||
_id: session.user.id
|
_id: session.user.id
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, user) => {
|
(err, user) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// LIST "" "*"
|
// LIST "" "*"
|
||||||
// Returns all folders, query is informational
|
// Returns all folders, query is informational
|
||||||
|
|
@ -21,6 +22,6 @@ module.exports = server =>
|
||||||
.find({
|
.find({
|
||||||
user: session.user.id
|
user: session.user.id
|
||||||
})
|
})
|
||||||
.maxTimeMS(500)
|
.maxTimeMS(consts.DB_MAX_TIME_MAILBOXES)
|
||||||
.toArray(callback);
|
.toArray(callback);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// LSUB "" "*"
|
// LSUB "" "*"
|
||||||
// Returns all subscribed folders, query is informational
|
// Returns all subscribed folders, query is informational
|
||||||
|
|
@ -21,6 +22,6 @@ module.exports = server => (query, session, callback) => {
|
||||||
user: session.user.id,
|
user: session.user.id,
|
||||||
subscribed: true
|
subscribed: true
|
||||||
})
|
})
|
||||||
.maxTimeMS(500)
|
.maxTimeMS(consts.DB_MAX_TIME_MAILBOXES)
|
||||||
.toArray(callback);
|
.toArray(callback);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// SELECT/EXAMINE
|
// SELECT/EXAMINE
|
||||||
module.exports = server => (path, session, callback) => {
|
module.exports = server => (path, session, callback) => {
|
||||||
|
|
@ -19,7 +20,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailbox) => {
|
(err, mailbox) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -38,7 +39,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
uid: true
|
uid: true
|
||||||
})
|
})
|
||||||
//.sort([['uid', 1]])
|
//.sort([['uid', 1]])
|
||||||
.maxTimeMS(5000)
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
||||||
.toArray((err, messages) => {
|
.toArray((err, messages) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// RENAME "path/to/mailbox" "new/path"
|
// RENAME "path/to/mailbox" "new/path"
|
||||||
// NB! RENAME affects child and hierarchy mailboxes as well, this example does not do this
|
// NB! RENAME affects child and hierarchy mailboxes as well, this example does not do this
|
||||||
|
|
@ -22,7 +23,7 @@ module.exports = (server, mailboxHandler) => (path, newname, session, callback)
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailbox) => {
|
(err, mailbox) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
const tools = require('../tools');
|
const tools = require('../tools');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of matching UID values
|
* Returns an array of matching UID values
|
||||||
|
|
@ -12,7 +13,7 @@ module.exports = server => (mailbox, options, session, callback) => {
|
||||||
_id: mailbox
|
_id: mailbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -359,7 +360,7 @@ module.exports = server => (mailbox, options, session, callback) => {
|
||||||
uid: true,
|
uid: true,
|
||||||
modseq: true
|
modseq: true
|
||||||
})
|
})
|
||||||
.maxTimeMS(5000);
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
|
||||||
|
|
||||||
let highestModseq = 0;
|
let highestModseq = 0;
|
||||||
let uidList = [];
|
let uidList = [];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// STATUS (X Y X)
|
// STATUS (X Y X)
|
||||||
module.exports = server => (path, session, callback) => {
|
module.exports = server => (path, session, callback) => {
|
||||||
|
|
@ -19,7 +20,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -39,7 +40,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
$lt: mailboxData.uidNext
|
$lt: mailboxData.uidNext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.maxTimeMS(5000)
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
||||||
.count((err, total) => {
|
.count((err, total) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
@ -55,7 +56,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
$lt: mailboxData.uidNext
|
$lt: mailboxData.uidNext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.maxTimeMS(5000)
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
||||||
.count((err, unseen) => {
|
.count((err, unseen) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ module.exports = server => (mailbox, update, session, callback) => {
|
||||||
_id: mailbox
|
_id: mailbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, mailboxData) => {
|
(err, mailboxData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -53,7 +53,7 @@ module.exports = server => (mailbox, update, session, callback) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
returnOriginal: false,
|
returnOriginal: false,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, item) => {
|
(err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -96,7 +96,7 @@ module.exports = server => (mailbox, update, session, callback) => {
|
||||||
flags: true,
|
flags: true,
|
||||||
modseq: true
|
modseq: true
|
||||||
})
|
})
|
||||||
.maxTimeMS(5000)
|
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
||||||
.sort([['uid', 1]]);
|
.sort([['uid', 1]]);
|
||||||
|
|
||||||
let shouldExpunge = false;
|
let shouldExpunge = false;
|
||||||
|
|
@ -453,7 +453,7 @@ function updateMailboxFlags(mailbox, update, callback) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// SUBSCRIBE "path/to/mailbox"
|
// SUBSCRIBE "path/to/mailbox"
|
||||||
module.exports = server => (path, session, callback) => {
|
module.exports = server => (path, session, callback) => {
|
||||||
|
|
@ -24,7 +25,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, item) => {
|
(err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
|
const consts = require('../consts');
|
||||||
|
|
||||||
// UNSUBSCRIBE "path/to/mailbox"
|
// UNSUBSCRIBE "path/to/mailbox"
|
||||||
module.exports = server => (path, session, callback) => {
|
module.exports = server => (path, session, callback) => {
|
||||||
|
|
@ -24,7 +25,7 @@ module.exports = server => (path, session, callback) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
||||||
},
|
},
|
||||||
(err, item) => {
|
(err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class UserHandler {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
projection,
|
projection,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -90,7 +90,7 @@ class UserHandler {
|
||||||
this.users.collection('domainaliases').findOne(
|
this.users.collection('domainaliases').findOne(
|
||||||
{ alias: domain },
|
{ alias: domain },
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, aliasData) => {
|
(err, aliasData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -108,7 +108,7 @@ class UserHandler {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
projection,
|
projection,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
|
|
@ -144,7 +144,7 @@ class UserHandler {
|
||||||
query,
|
query,
|
||||||
{
|
{
|
||||||
projection,
|
projection,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -163,7 +163,7 @@ class UserHandler {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
projection,
|
projection,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -245,7 +245,7 @@ class UserHandler {
|
||||||
data.query,
|
data.query,
|
||||||
{
|
{
|
||||||
projection: fields,
|
projection: fields,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -462,7 +462,7 @@ class UserHandler {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
disabledScopes: true
|
disabledScopes: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -757,7 +757,7 @@ class UserHandler {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
() => false
|
() => false
|
||||||
);
|
);
|
||||||
|
|
@ -814,7 +814,7 @@ class UserHandler {
|
||||||
.find({
|
.find({
|
||||||
user: userData._id
|
user: userData._id
|
||||||
})
|
})
|
||||||
.maxTimeMS(500)
|
.maxTimeMS(consts.DB_MAX_TIME_USERS)
|
||||||
.toArray((err, asps) => {
|
.toArray((err, asps) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.code = 'InternalDatabaseError';
|
err.code = 'InternalDatabaseError';
|
||||||
|
|
@ -895,7 +895,7 @@ class UserHandler {
|
||||||
$set: aspUpdates
|
$set: aspUpdates
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
authSuccess(
|
authSuccess(
|
||||||
|
|
@ -955,7 +955,7 @@ class UserHandler {
|
||||||
oldPasswords: true,
|
oldPasswords: true,
|
||||||
disabled: true
|
disabled: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1129,7 +1129,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
_id: true
|
_id: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1177,7 +1177,7 @@ class UserHandler {
|
||||||
user
|
user
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, asp) => {
|
(err, asp) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1227,7 +1227,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
unameview: true
|
unameview: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1286,7 +1286,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
_id: true
|
_id: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1546,7 +1546,10 @@ class UserHandler {
|
||||||
{
|
{
|
||||||
$set: updates
|
$set: updates
|
||||||
},
|
},
|
||||||
{ returnOriginal: false, maxTimeMS: 500 },
|
{
|
||||||
|
returnOriginal: false,
|
||||||
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
// try to rollback
|
// try to rollback
|
||||||
|
|
@ -1695,7 +1698,9 @@ class UserHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ maxTimeMS: 500 },
|
{
|
||||||
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -1733,7 +1738,7 @@ class UserHandler {
|
||||||
enabled2fa: true,
|
enabled2fa: true,
|
||||||
seed: true
|
seed: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1787,7 +1792,7 @@ class UserHandler {
|
||||||
pendingSeedChanged: new Date()
|
pendingSeedChanged: new Date()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ maxTimeMS: 500 },
|
{ maxTimeMS: consts.DB_MAX_TIME_USERS },
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -1837,7 +1842,7 @@ class UserHandler {
|
||||||
pendingSeed: true,
|
pendingSeed: true,
|
||||||
pendingSeedChanged: true
|
pendingSeedChanged: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -1930,7 +1935,7 @@ class UserHandler {
|
||||||
pendingSeed: userData.pendingSeed
|
pendingSeed: userData.pendingSeed
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{ maxTimeMS: consts.DB_MAX_TIME_USERS },
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -1972,7 +1977,7 @@ class UserHandler {
|
||||||
username: true,
|
username: true,
|
||||||
seed: true
|
seed: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2021,7 +2026,7 @@ class UserHandler {
|
||||||
_id: user
|
_id: user
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{ maxTimeMS: consts.DB_MAX_TIME_USERS },
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2085,7 +2090,7 @@ class UserHandler {
|
||||||
enabled2fa: true,
|
enabled2fa: true,
|
||||||
seed: true
|
seed: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2161,7 +2166,7 @@ class UserHandler {
|
||||||
enabled2fa: true,
|
enabled2fa: true,
|
||||||
username: true
|
username: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2205,7 +2210,7 @@ class UserHandler {
|
||||||
_id: user
|
_id: user
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{ maxTimeMS: consts.DB_MAX_TIME_USERS },
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2246,7 +2251,7 @@ class UserHandler {
|
||||||
enabled2fa: true,
|
enabled2fa: true,
|
||||||
username: true
|
username: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2278,7 +2283,9 @@ class UserHandler {
|
||||||
_id: user
|
_id: user
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{
|
||||||
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2330,7 +2337,7 @@ class UserHandler {
|
||||||
enabled2fa: true,
|
enabled2fa: true,
|
||||||
seed: true
|
seed: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2431,7 +2438,7 @@ class UserHandler {
|
||||||
username: true,
|
username: true,
|
||||||
u2f: true
|
u2f: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2488,7 +2495,7 @@ class UserHandler {
|
||||||
_id: user
|
_id: user
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{ maxTimeMS: consts.DB_MAX_TIME_USERS },
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2531,7 +2538,7 @@ class UserHandler {
|
||||||
username: true,
|
username: true,
|
||||||
u2f: true
|
u2f: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2585,7 +2592,9 @@ class UserHandler {
|
||||||
_id: user
|
_id: user
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
{ maxTimeMS: 500 },
|
{
|
||||||
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2626,7 +2635,7 @@ class UserHandler {
|
||||||
username: true,
|
username: true,
|
||||||
u2f: true
|
u2f: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2674,7 +2683,7 @@ class UserHandler {
|
||||||
username: true,
|
username: true,
|
||||||
u2f: true
|
u2f: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -2777,7 +2786,9 @@ class UserHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ maxTimeMS: 500 },
|
{
|
||||||
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
log.error('DB', 'UPDATEFAIL id=%s error=%s', user, err.message);
|
||||||
|
|
@ -2942,7 +2953,7 @@ class UserHandler {
|
||||||
password: true,
|
password: true,
|
||||||
oldPasswords: true
|
oldPasswords: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3013,7 +3024,7 @@ class UserHandler {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
returnOriginal: false,
|
returnOriginal: false,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3149,7 +3160,7 @@ class UserHandler {
|
||||||
upsert: true,
|
upsert: true,
|
||||||
projection: { _id: true },
|
projection: { _id: true },
|
||||||
returnOriginal: false,
|
returnOriginal: false,
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, r) => {
|
(err, r) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3170,7 +3181,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
_id: true
|
_id: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, userData) => {
|
(err, userData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3282,7 +3293,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
user: true
|
user: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3298,7 +3309,7 @@ class UserHandler {
|
||||||
this.users.collection('domainaliases').findOne(
|
this.users.collection('domainaliases').findOne(
|
||||||
{ alias: domain },
|
{ alias: domain },
|
||||||
{
|
{
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, aliasData) => {
|
(err, aliasData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -3319,7 +3330,7 @@ class UserHandler {
|
||||||
projection: {
|
projection: {
|
||||||
user: true
|
user: true
|
||||||
},
|
},
|
||||||
maxTimeMS: 500
|
maxTimeMS: consts.DB_MAX_TIME_USERS
|
||||||
},
|
},
|
||||||
(err, addressData) => {
|
(err, addressData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue