From 5b2b57dd1dadbab380a2a99c49fc0244f8511edc Mon Sep 17 00:00:00 2001 From: Benedikt Schaber Date: Fri, 27 Jan 2023 02:53:27 +0100 Subject: [PATCH] fix: assert relatedAttachments are present --- client/basic/encode/related.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/basic/encode/related.ts b/client/basic/encode/related.ts index b4b7835..4406480 100644 --- a/client/basic/encode/related.ts +++ b/client/basic/encode/related.ts @@ -6,6 +6,10 @@ import { encodeAttachment } from "./attachment.ts"; type writer = (...args: string[]) => Promise; export function encodeRelated(writeCMD: writer, content: Content) { + if (!content.relatedAttachments) { + throw new Error("Content does not contain relatedAttachments. Cannot encode as related."); + } + const boundaryAddRel = calcBoundary( content.content + "\n" + content.relatedAttachments.map(v => v.content).join("\n"),