From 5a8d8248df45377c4231e3017870506d5006b39b Mon Sep 17 00:00:00 2001 From: Mike Dial Date: Fri, 10 Nov 2023 09:11:03 -0500 Subject: [PATCH] update getAttachmentUrl to allow download of rai attachments --- src/services/api/handlers/getAttachmentUrl.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/services/api/handlers/getAttachmentUrl.ts b/src/services/api/handlers/getAttachmentUrl.ts index f8f486ee4a..ffe166e46d 100644 --- a/src/services/api/handlers/getAttachmentUrl.ts +++ b/src/services/api/handlers/getAttachmentUrl.ts @@ -48,11 +48,24 @@ export const handler = async (event: APIGatewayEvent) => { }); } + const raiAttachmentList = []; + const rec = results.hits.hits[0]._source; + for (const key in rec.rais) { + const entry = rec.rais[key]; + for (const attachment of entry.request.attachments) { + raiAttachmentList.push(attachment); + } + // for (const attachment of entry.response.attachments) { + // flatAttachments.push(attachment); + // } + } + const allAttachments = [ ...results.hits.hits[0]._source.attachments, ...results.hits.hits[0]._source.raiResponses .map((R) => R.attachments) .flat(), + ...raiAttachmentList, ]; if (