mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)
This commit is contained in:
@@ -30,6 +30,42 @@ import { simpleParser, Source as ParserSource } from 'mailparser';
|
||||
import _ from 'lodash';
|
||||
import { ICredentialsDataImap, isCredentialsDataImap } from '../../../credentials/Imap.credentials';
|
||||
|
||||
export async function parseRawEmail(
|
||||
this: ITriggerFunctions,
|
||||
messageEncoded: ParserSource,
|
||||
dataPropertyNameDownload: string,
|
||||
): Promise<INodeExecutionData> {
|
||||
const responseData = await simpleParser(messageEncoded);
|
||||
const headers: IDataObject = {};
|
||||
for (const header of responseData.headerLines) {
|
||||
headers[header.key] = header.line;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
responseData.headers = headers;
|
||||
// @ts-ignore
|
||||
responseData.headerLines = undefined;
|
||||
|
||||
const binaryData: IBinaryKeyData = {};
|
||||
if (responseData.attachments) {
|
||||
for (let i = 0; i < responseData.attachments.length; i++) {
|
||||
const attachment = responseData.attachments[i];
|
||||
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
|
||||
attachment.content,
|
||||
attachment.filename,
|
||||
attachment.contentType,
|
||||
);
|
||||
}
|
||||
// @ts-ignore
|
||||
responseData.attachments = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
json: responseData as unknown as IDataObject,
|
||||
binary: Object.keys(binaryData).length ? binaryData : undefined,
|
||||
} as INodeExecutionData;
|
||||
}
|
||||
|
||||
const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Email Trigger (IMAP)',
|
||||
name: 'emailReadImap',
|
||||
@@ -279,8 +315,6 @@ export class EmailReadImapV2 implements INodeType {
|
||||
// Returns the email attachments
|
||||
const getAttachment = async (
|
||||
imapConnection: ImapSimple,
|
||||
// tslint:disable-next-line:no-any
|
||||
|
||||
parts: any[],
|
||||
message: Message,
|
||||
): Promise<IBinaryData[]> => {
|
||||
@@ -571,6 +605,7 @@ export class EmailReadImapV2 implements INodeType {
|
||||
conn.on('error', async (error) => {
|
||||
const errorCode = error.code.toUpperCase();
|
||||
Logger.verbose(`IMAP connection experienced an error: (${errorCode})`, { error });
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
await closeFunction();
|
||||
this.emitError(error);
|
||||
});
|
||||
@@ -619,39 +654,3 @@ export class EmailReadImapV2 implements INodeType {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function parseRawEmail(
|
||||
this: ITriggerFunctions,
|
||||
messageEncoded: ParserSource,
|
||||
dataPropertyNameDownload: string,
|
||||
): Promise<INodeExecutionData> {
|
||||
const responseData = await simpleParser(messageEncoded);
|
||||
const headers: IDataObject = {};
|
||||
for (const header of responseData.headerLines) {
|
||||
headers[header.key] = header.line;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
responseData.headers = headers;
|
||||
// @ts-ignore
|
||||
responseData.headerLines = undefined;
|
||||
|
||||
const binaryData: IBinaryKeyData = {};
|
||||
if (responseData.attachments) {
|
||||
for (let i = 0; i < responseData.attachments.length; i++) {
|
||||
const attachment = responseData.attachments[i];
|
||||
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
|
||||
attachment.content,
|
||||
attachment.filename,
|
||||
attachment.contentType,
|
||||
);
|
||||
}
|
||||
// @ts-ignore
|
||||
responseData.attachments = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
json: responseData as unknown as IDataObject,
|
||||
binary: Object.keys(binaryData).length ? binaryData : undefined,
|
||||
} as INodeExecutionData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user