wildduck/lib/handlers/on-delete.js
2017-12-10 01:19:50 +02:00

33 lines
733 B
JavaScript

'use strict';
const db = require('../db');
// 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
},
(err, mailbox) => {
if (err) {
return callback(err);
}
if (!mailbox) {
return callback(null, 'NONEXISTENT');
}
mailboxHandler.del(session.user.id, mailbox._id, callback);
}
);
};