mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-11-10 17:47:07 +08:00
37 lines
843 B
JavaScript
37 lines
843 B
JavaScript
'use strict';
|
|
|
|
const db = require('../db');
|
|
const consts = require('../consts');
|
|
|
|
// DELETE "path/to/mailbox"
|
|
module.exports = (server, mailboxHandler) => (path, session, callback) => {
|
|
server.logger.debug(
|
|
{
|
|
tnx: 'delete',
|
|
cid: session.id
|
|
},
|
|
'[%s] DELETE "%s"',
|
|
session.id,
|
|
path
|
|
);
|
|
|
|
db.database.collection('mailboxes').findOne(
|
|
{
|
|
user: session.user.id,
|
|
path
|
|
},
|
|
{
|
|
maxTimeMS: consts.DB_MAX_TIME_MAILBOXES
|
|
},
|
|
(err, mailbox) => {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
if (!mailbox) {
|
|
return callback(null, 'NONEXISTENT');
|
|
}
|
|
|
|
mailboxHandler.del(session.user.id, mailbox._id, callback);
|
|
}
|
|
);
|
|
};
|