From ab7944e866e364659508e6e140c0ee7d8b79388c Mon Sep 17 00:00:00 2001 From: Ritul Date: Fri, 27 Mar 2026 13:26:02 +0530 Subject: [PATCH] sanity for template filling --- client/src/utils/runtimeContext.js | 3 --- server/routes/businesses.js | 11 +++-------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/client/src/utils/runtimeContext.js b/client/src/utils/runtimeContext.js index fed9ead..d547af4 100644 --- a/client/src/utils/runtimeContext.js +++ b/client/src/utils/runtimeContext.js @@ -1,8 +1,5 @@ const COMPANY_ID_QUERY_KEYS = [ - 'companyId', - 'company_id', 'blt-gtw-fc-cid', - 'bltt-gtw-f-c-cid', ]; const COMPANY_ID_STORAGE_KEY = 'sms_runtime_company_id'; diff --git a/server/routes/businesses.js b/server/routes/businesses.js index c46fe2e..53497eb 100644 --- a/server/routes/businesses.js +++ b/server/routes/businesses.js @@ -129,10 +129,6 @@ function normalizeSenderId(value) { return normalizeText(value).toUpperCase(); } -function renderTemplateWithUsername(template, username) { - return String(template || '').replace(/\{#var#\}/g, normalizeText(username)); -} - function isValidCurlCommand(rawCurl) { return normalizeText(rawCurl).toLowerCase().startsWith('curl'); } @@ -419,15 +415,15 @@ router.delete('/:businessId', async (req, res) => { // POST /api/businesses/resolve-template router.post('/resolve-template', async (req, res) => { try { + console.log('[ResolveTemplate] Incoming payload:', JSON.stringify(req.body, null, 2)); + const companyId = getCompanyId(req); const applicationId = getApplicationId(req); const event = normalizeText(req.body?.event); - const username = normalizeText(req.body?.username); if (!companyId) return res.status(400).json({ error: 'companyId is required' }); if (!applicationId) return res.status(400).json({ error: 'applicationId is required' }); if (!event) return res.status(400).json({ error: 'event is required' }); - if (!username) return res.status(400).json({ error: 'username is required' }); const business = await findBusinessByApplicationId(companyId, applicationId); if (!business) { @@ -447,9 +443,8 @@ router.post('/resolve-template', async (req, res) => { companyId, applicationId, event: eventSlug, - username, templateId: normalizeText(tmpl.templateId), - template: renderTemplateWithUsername(tmpl.selectedTemplate, username), + template: tmpl.selectedTemplate, }); } catch (err) { sendRouteError(res, err);