n8n-nodes-imap-ai
Version:
Simplified IMAP node for n8n with AI-agent support. Clean and modular email and mailbox management for automation workflows.
54 lines • 2.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.moveMailboxOperation = void 0;
const SearchFieldParameters_1 = require("../../../utils/SearchFieldParameters");
exports.moveMailboxOperation = {
operation: {
name: 'Move',
value: 'moveMailbox',
description: 'Move mailbox folders to reorganize folder structure and improve email organization. Perfect for AI agents to restructure folders, group related folders, or implement new organizational hierarchies.',
},
parameters: [
{
displayName: 'New Parent Folder',
name: 'newParentFolder',
type: 'string',
default: "={{ $fromAI('new_parent_folder', 'Path of the new parent folder where the mailbox should be moved') }}",
description: 'Specify the new parent folder path. AI agents can reorganize folders into logical hierarchies.',
placeholder: 'Projects | Archive | Clients | Support',
required: true,
},
{
...SearchFieldParameters_1.parameterSelectMailbox,
description: 'Select the mailbox to move. AI agents can restructure folder hierarchies for better organization.',
},
],
async executeImapAction(context, itemIndex, client) {
var _a;
const returnData = [];
const currentMailboxPath = (0, SearchFieldParameters_1.getMailboxPathFromNodeParameter)(context, itemIndex);
const newParentFolder = context.getNodeParameter('newParentFolder', itemIndex);
const folderName = currentMailboxPath.split('/').pop() || currentMailboxPath;
const newMailboxPath = newParentFolder ? `${newParentFolder}/${folderName}` : folderName;
(_a = context.logger) === null || _a === void 0 ? void 0 : _a.info(`Moving mailbox from "${currentMailboxPath}" to "${newMailboxPath}"`);
const result = await client.mailboxRename(currentMailboxPath, newMailboxPath);
const item_json = {
operation: 'moveMailbox',
originalPath: currentMailboxPath,
newPath: newMailboxPath,
newParentFolder: newParentFolder,
folderName: folderName,
success: true,
movedAt: new Date().toISOString(),
message: `Successfully moved mailbox from "${currentMailboxPath}" to "${newMailboxPath}"`,
};
if (result) {
Object.assign(item_json, { serverResponse: result });
}
returnData.push({
json: item_json,
});
return returnData;
},
};
//# sourceMappingURL=MailboxMove.js.map