Skip to content

Commit

Permalink
fix for sms/email cross-memoizing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Jun 13, 2024
1 parent e2f8b2b commit 6b6caa6
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions services/api/src/utils/messaging/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6b6caa6

Please sign in to comment.