From 0a4b4147c6b60a484da8ca7a6431189be4483e4c Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 30 Jul 2020 01:45:32 +0300 Subject: [PATCH] cases: don't break if a case note is an empty string --- backend/src/plugins/Cases/functions/getCaseEmbed.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Cases/functions/getCaseEmbed.ts b/backend/src/plugins/Cases/functions/getCaseEmbed.ts index 914960f9..8f3e13c3 100644 --- a/backend/src/plugins/Cases/functions/getCaseEmbed.ts +++ b/backend/src/plugins/Cases/functions/getCaseEmbed.ts @@ -52,7 +52,12 @@ export async function getCaseEmbed( if (theCase.notes.length) { theCase.notes.forEach((note: any) => { const noteDate = moment(note.created_at); - const chunks = chunkMessageLines(note.body, 1014); + let noteBody = note.body.trim(); + if (noteBody === "") { + noteBody = emptyEmbedValue; + } + + const chunks = chunkMessageLines(noteBody, 1014); for (let i = 0; i < chunks.length; i++) { if (i === 0) {