mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Email Trigger (IMAP) Node): Handle attachments correctly (#9410)
This commit is contained in:
committed by
GitHub
parent
bf549301df
commit
68a6c81729
@@ -285,7 +285,7 @@ export class EmailReadImapV1 implements INodeType {
|
||||
|
||||
// Returns the email text
|
||||
|
||||
const getText = async (parts: any[], message: Message, subtype: string) => {
|
||||
const getText = async (parts: any[], message: Message, subtype: string): Promise<string> => {
|
||||
if (!message.attributes.struct) {
|
||||
return '';
|
||||
}
|
||||
@@ -296,12 +296,14 @@ export class EmailReadImapV1 implements INodeType {
|
||||
);
|
||||
});
|
||||
|
||||
if (textParts.length === 0) {
|
||||
const part = textParts[0];
|
||||
if (!part) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
return await connection.getPartData(message, textParts[0]);
|
||||
const partData = await connection.getPartData(message, part);
|
||||
return partData.toString();
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
@@ -330,7 +332,7 @@ export class EmailReadImapV1 implements INodeType {
|
||||
.then(async (partData) => {
|
||||
// Return it in the format n8n expects
|
||||
return await this.helpers.prepareBinaryData(
|
||||
Buffer.from(partData),
|
||||
partData.buffer,
|
||||
attachmentPart.disposition.params.filename as string,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user