mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-01-07 00:17:37 +08:00
43aa20d92c
Re-added UTF8=ACCESS
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
let imapTools = require('../imap-tools');
|
|
|
|
// tag DELETE "mailbox"
|
|
|
|
module.exports = {
|
|
state: ['Authenticated', 'Selected'],
|
|
|
|
schema: [{
|
|
name: 'mailbox',
|
|
type: 'string'
|
|
}],
|
|
|
|
handler(command, callback) {
|
|
|
|
let mailbox = Buffer.from(command.attributes[0] && command.attributes[0].value || '', 'binary').toString();
|
|
mailbox = imapTools.normalizeMailbox(mailbox, !this.acceptUTF8Enabled);
|
|
|
|
// Check if DELETE method is set
|
|
if (typeof this._server.onDelete !== 'function') {
|
|
return callback(null, {
|
|
response: 'NO',
|
|
message: 'DELETE not implemented'
|
|
});
|
|
}
|
|
|
|
if (!mailbox) {
|
|
// nothing to check for if mailbox is not defined
|
|
return callback(null, {
|
|
response: 'NO',
|
|
code: 'CANNOT',
|
|
message: 'No folder name given'
|
|
});
|
|
}
|
|
|
|
if (mailbox === 'INBOX') {
|
|
// nothing to check for if mailbox is not defined
|
|
return callback(null, {
|
|
response: 'NO',
|
|
code: 'CANNOT',
|
|
message: 'INBOX can not be deleted'
|
|
});
|
|
}
|
|
|
|
this._server.onDelete(mailbox, this.session, (err, success) => {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
|
|
if (success !== true) {
|
|
return callback(null, {
|
|
response: 'NO',
|
|
code: typeof success === 'string' ? success.toUpperCase() : false
|
|
});
|
|
}
|
|
|
|
this._server.notifier.fire(this.session.user.username, mailbox, {
|
|
action: 'DELETE',
|
|
mailbox
|
|
});
|
|
|
|
callback(null, {
|
|
response: 'OK'
|
|
});
|
|
});
|
|
}
|
|
};
|