Skip to content

Commit

Permalink
fix(Email Trigger (IMAP) Node): Fix connection issue with unexpected …
Browse files Browse the repository at this point in the history
…spaces in host (#6886)
  • Loading branch information
Joffcom authored Aug 10, 2023
1 parent 718e613 commit f3248e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class EmailReadImapV1 implements INodeType {
imap: {
user: credentials.user as string,
password: credentials.password as string,
host: credentials.host as string,
host: (credentials.host as string).trim(),
port: credentials.port as number,
tls: credentials.secure as boolean,
authTimeout: 20000,
Expand All @@ -250,7 +250,7 @@ export class EmailReadImapV1 implements INodeType {
const tlsOptions: IDataObject = {};

if (credentials.secure) {
tlsOptions.servername = credentials.host as string;
tlsOptions.servername = (credentials.host as string).trim();
}
if (!isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions;
Expand Down Expand Up @@ -527,7 +527,7 @@ export class EmailReadImapV1 implements INodeType {
imap: {
user: credentials.user as string,
password: credentials.password as string,
host: credentials.host as string,
host: (credentials.host as string).trim(),
port: credentials.port as number,
tls: credentials.secure as boolean,
authTimeout: 20000,
Expand Down Expand Up @@ -579,7 +579,7 @@ export class EmailReadImapV1 implements INodeType {
}

if (credentials.secure) {
tlsOptions.servername = credentials.host as string;
tlsOptions.servername = (credentials.host as string).trim();
}

if (!isEmpty(tlsOptions)) {
Expand Down
24 changes: 12 additions & 12 deletions packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export async function parseRawEmail(
): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {};
const addidtionalData: IDataObject = {};
const additionalData: IDataObject = {};

for (const header of responseData.headerLines) {
headers[header.key] = header.line;
}

addidtionalData.headers = headers;
addidtionalData.headerLines = undefined;
additionalData.headers = headers;
additionalData.headerLines = undefined;

const binaryData: IBinaryKeyData = {};
if (responseData.attachments) {
Expand All @@ -54,11 +54,11 @@ export async function parseRawEmail(
);
}

addidtionalData.attachments = undefined;
additionalData.attachments = undefined;
}

return {
json: { ...responseData, ...addidtionalData },
json: { ...responseData, ...additionalData },
binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData;
}
Expand Down Expand Up @@ -238,7 +238,7 @@ export class EmailReadImapV2 implements INodeType {
imap: {
user: credentials.user,
password: credentials.password,
host: credentials.host,
host: credentials.host.trim(),
port: credentials.port,
tls: credentials.secure,
authTimeout: 20000,
Expand All @@ -251,7 +251,7 @@ export class EmailReadImapV2 implements INodeType {
}

if (credentials.secure) {
tlsOptions.servername = credentials.host;
tlsOptions.servername = credentials.host.trim();
}
if (!isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions;
Expand Down Expand Up @@ -554,7 +554,7 @@ export class EmailReadImapV2 implements INodeType {
imap: {
user: credentials.user,
password: credentials.password,
host: credentials.host,
host: credentials.host.trim(),
port: credentials.port,
tls: credentials.secure,
authTimeout: 20000,
Expand Down Expand Up @@ -609,7 +609,7 @@ export class EmailReadImapV2 implements INodeType {
}

if (credentials.secure) {
tlsOptions.servername = credentials.host;
tlsOptions.servername = credentials.host.trim();
}

if (!isEmpty(tlsOptions)) {
Expand Down Expand Up @@ -648,7 +648,7 @@ export class EmailReadImapV2 implements INodeType {

let reconnectionInterval: NodeJS.Timeout | undefined;

const handleReconect = async () => {
const handleReconnect = async () => {
this.logger.verbose('Forcing reconnect to IMAP server');
try {
isCurrentlyReconnecting = true;
Expand All @@ -665,12 +665,12 @@ export class EmailReadImapV2 implements INodeType {

if (options.forceReconnect !== undefined) {
reconnectionInterval = setInterval(
handleReconect,
handleReconnect,
(options.forceReconnect as number) * 1000 * 60,
);
}

// When workflow and so node gets set to inactive close the connectoin
// When workflow and so node gets set to inactive close the connection
async function closeFunction() {
closeFunctionWasCalled = true;
if (reconnectionInterval) {
Expand Down

0 comments on commit f3248e4

Please sign in to comment.