renameMailbox method
Renames the specified mailbox
box the mailbox that should be renamed
newName the desired future name of the mailbox
Implementation
Future<Mailbox> renameMailbox(Mailbox box, String newName) async {
final path = '"${box.encodedPath}"';
final cmd = Command(
'RENAME $path ${_encodeMailboxPath(newName)}',
writeTimeout: defaultWriteTimeout,
responseTimeout: defaultResponseTimeout,
);
final response = await sendCommand<Mailbox?>(
cmd,
NoopParser(this, _selectedMailbox ?? box),
);
// if (box.name.toUpperCase() == 'INBOX') {
/* Renaming INBOX is permitted, and has special behavior. It moves
all messages in INBOX to a new mailbox with the given name,
leaving INBOX empty. If the server implementation supports
inferior hierarchical names of INBOX, these are unaffected by a
rename of INBOX.
*/
// question: do we need to create a new mailbox
// and return that one instead?
// }
return response ?? box;
}