From 053fb5ff7a3a4ce30b35fa6c830787b935ebaf63 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:18:00 +0200 Subject: [PATCH] fix(Microsoft Outlook Node): Download executes more than once per incoming item (#8566) --- .../messageAttachment/download.operation.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/v2/actions/messageAttachment/download.operation.ts b/packages/nodes-base/nodes/Microsoft/Outlook/v2/actions/messageAttachment/download.operation.ts index 3c5d7d81a..7892b24ff 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/v2/actions/messageAttachment/download.operation.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/v2/actions/messageAttachment/download.operation.ts @@ -49,7 +49,7 @@ export async function execute(this: IExecuteFunctions, index: number, items: INo if (attachmentDetails.contentType) { mimeType = attachmentDetails.contentType; } - const fileName = attachmentDetails.name; + const fileName = attachmentDetails.name as string; const response = await microsoftApiRequest.call( this, @@ -74,13 +74,17 @@ export async function execute(this: IExecuteFunctions, index: number, items: INo Object.assign(newItem.binary!, items[index].binary); } - items[index] = newItem; const data = Buffer.from(response.body as string, 'utf8'); - items[index].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( - data as unknown as Buffer, - fileName as string, + newItem.binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data, + fileName, mimeType, ); - return items; + const executionData = this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(newItem), + { itemData: { item: index } }, + ); + + return executionData; }