sanity for template filling
This commit is contained in:
parent
0eb09d66a8
commit
ab7944e866
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user