From 6b6caa6ca3107f1ef6d7759c027a8e5f774a870e Mon Sep 17 00:00:00 2001 From: Andrew Plummer Date: Thu, 13 Jun 2024 22:17:44 +0900 Subject: [PATCH] fix for sms/email cross-memoizing --- services/api/src/utils/messaging/utils.js | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/services/api/src/utils/messaging/utils.js b/services/api/src/utils/messaging/utils.js index 97b62e05..4e605af1 100644 --- a/services/api/src/utils/messaging/utils.js +++ b/services/api/src/utils/messaging/utils.js @@ -32,21 +32,26 @@ function escapeHtml(str) { // Templates -const loadTemplate = memoize(async (name, dir) => { - if (name) { - const raw = await loadTemplateFile(path.join(dir, name)); - const { body, attributes: meta } = frontmatter(raw); - return { - body, - meta, - }; - } else { - return { - body: '{{&body}}', - meta: {}, - }; +const loadTemplate = memoize( + async (name, dir) => { + if (name) { + const raw = await loadTemplateFile(path.join(dir, name)); + const { body, attributes: meta } = frontmatter(raw); + return { + body, + meta, + }; + } else { + return { + body: '{{&body}}', + meta: {}, + }; + } + }, + (name, dir) => { + return path.join(dir, name || ''); } -}); +); async function loadTemplateFile(file) { const ext = path.extname(file);