Skip to content

Commit 2dbeebb

Browse files
committed
style: added "Source Mailbox" and "Destination Mailbox" labels
1 parent f65b501 commit 2dbeebb

File tree

2 files changed

+70
-66
lines changed

2 files changed

+70
-66
lines changed

nodes/Imap/operations/email/functions/EmailCopy.ts

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,86 @@ import { CopyResponseObject, ImapFlow } from 'imapflow';
22
import { IExecuteFunctions, INodeExecutionData, NodeApiError } from 'n8n-workflow';
33
import { IResourceOperationDef } from '../../../utils/CommonDefinitions';
44
import {
5-
getMailboxPathFromNodeParameter,
6-
parameterSelectMailbox,
5+
getMailboxPathFromNodeParameter,
6+
parameterSelectMailbox,
77
} from '../../../utils/SearchFieldParameters';
88

99
const PARAM_NAME_SOURCE_MAILBOX = 'sourceMailbox';
1010
const PARAM_NAME_DESTINATION_MAILBOX = 'destinationMailbox';
1111

1212
export const copyEmailOperation: IResourceOperationDef = {
13-
operation: {
14-
name: 'Copy',
15-
value: 'copyEmail',
16-
},
17-
parameters: [
18-
{
19-
...parameterSelectMailbox,
20-
description: 'Select the mailbox',
21-
name: PARAM_NAME_SOURCE_MAILBOX,
22-
},
23-
{
24-
displayName: 'Email UID',
25-
name: 'emailUid',
26-
type: 'string',
27-
default: '',
28-
description: 'UID of the email to copy',
29-
hint: 'You can use comma separated list of UIDs to copy multiple emails at once',
30-
},
31-
{
32-
...parameterSelectMailbox,
33-
description: 'Select the destination mailbox',
34-
name: PARAM_NAME_DESTINATION_MAILBOX,
35-
},
36-
],
37-
async executeImapAction(
38-
context: IExecuteFunctions,
39-
itemIndex: number,
40-
client: ImapFlow,
41-
): Promise<INodeExecutionData[] | null> {
42-
var returnData: INodeExecutionData[] = [];
13+
operation: {
14+
name: 'Copy',
15+
value: 'copyEmail',
16+
},
17+
parameters: [
18+
{
19+
...parameterSelectMailbox,
20+
displayName: 'Source Mailbox',
21+
description: 'Select the source mailbox',
22+
name: PARAM_NAME_SOURCE_MAILBOX,
23+
},
24+
{
25+
displayName: 'Email UID',
26+
name: 'emailUid',
27+
type: 'string',
28+
default: '',
29+
description: 'UID of the email to copy',
30+
hint: 'You can use comma separated list of UIDs to copy multiple emails at once',
31+
},
32+
{
33+
...parameterSelectMailbox,
34+
displayName: 'Destination Mailbox',
35+
description: 'Select the destination mailbox',
36+
name: PARAM_NAME_DESTINATION_MAILBOX,
37+
},
38+
],
39+
async executeImapAction(
40+
context: IExecuteFunctions,
41+
itemIndex: number,
42+
client: ImapFlow,
43+
): Promise<INodeExecutionData[] | null> {
44+
var returnData: INodeExecutionData[] = [];
4345

44-
const sourceMailboxPath = getMailboxPathFromNodeParameter(
45-
context,
46-
itemIndex,
47-
PARAM_NAME_SOURCE_MAILBOX,
48-
);
49-
const destinationMailboxPath = getMailboxPathFromNodeParameter(
50-
context,
51-
itemIndex,
52-
PARAM_NAME_DESTINATION_MAILBOX,
53-
);
46+
const sourceMailboxPath = getMailboxPathFromNodeParameter(
47+
context,
48+
itemIndex,
49+
PARAM_NAME_SOURCE_MAILBOX,
50+
);
51+
const destinationMailboxPath = getMailboxPathFromNodeParameter(
52+
context,
53+
itemIndex,
54+
PARAM_NAME_DESTINATION_MAILBOX,
55+
);
5456

55-
const emailUid = context.getNodeParameter('emailUid', itemIndex) as string;
57+
const emailUid = context.getNodeParameter('emailUid', itemIndex) as string;
5658

57-
context.logger?.info(
58-
`Copying email "${emailUid}" from "${sourceMailboxPath}" to "${destinationMailboxPath}"`,
59-
);
59+
context.logger?.info(
60+
`Copying email "${emailUid}" from "${sourceMailboxPath}" to "${destinationMailboxPath}"`,
61+
);
6062

61-
await client.mailboxOpen(sourceMailboxPath, { readOnly: false });
63+
await client.mailboxOpen(sourceMailboxPath, { readOnly: false });
6264

63-
const resp: CopyResponseObject = await client.messageCopy(emailUid, destinationMailboxPath, {
64-
uid: true,
65-
});
65+
const resp: CopyResponseObject = await client.messageCopy(emailUid, destinationMailboxPath, {
66+
uid: true,
67+
});
6668

67-
if (!resp || !resp.uidMap) {
68-
throw new NodeApiError(
69-
context.getNode(),
70-
{},
71-
{
72-
message: 'Unable to copy email, unknown error',
73-
},
74-
);
75-
}
69+
if (!resp || !resp.uidMap) {
70+
throw new NodeApiError(
71+
context.getNode(),
72+
{},
73+
{
74+
message: 'Unable to copy email, unknown error',
75+
},
76+
);
77+
}
7678

77-
var item_json = JSON.parse(JSON.stringify(resp));
79+
var item_json = JSON.parse(JSON.stringify(resp));
7880

79-
returnData.push({
80-
json: item_json,
81-
});
81+
returnData.push({
82+
json: item_json,
83+
});
8284

83-
return returnData;
84-
},
85+
return returnData;
86+
},
8587
};

nodes/Imap/operations/email/functions/EmailMove.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export const moveEmailOperation: IResourceOperationDef = {
1616
parameters: [
1717
{
1818
...parameterSelectMailbox,
19-
description: 'Select the mailbox',
19+
displayName: 'Source Mailbox',
20+
description: 'Select the source mailbox',
2021
name: PARAM_NAME_SOURCE_MAILBOX,
2122
},
2223
{
@@ -29,6 +30,7 @@ export const moveEmailOperation: IResourceOperationDef = {
2930
},
3031
{
3132
...parameterSelectMailbox,
33+
displayName: 'Destination Mailbox',
3234
description: 'Select the destination mailbox',
3335
name: PARAM_NAME_DESTINATION_MAILBOX,
3436
},

0 commit comments

Comments
 (0)