Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Email Trigger (IMAP) Node): Fix connection issue with unexpected spaces in host #6886

Merged
merged 4 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading