This commit is contained in:
Christopher Cookman 2026-01-09 00:42:12 -07:00
parent 28d67ec0af
commit 394aee7262
2 changed files with 4 additions and 3 deletions

View file

@ -36,6 +36,7 @@ Object.keys(buttonsCfg).forEach(category => {
//console.log('Generated contexts:', contexts);
function trigCall(pageType, phone, variables = {}) {
console.log(variables)
// If contexts[pageType] does not exist, return an error
if (!contexts[pageType]) {
throw new Error(`Invalid page type: ${pageType}`);
@ -61,7 +62,7 @@ function originateCall(number, context, delay, timeout, cid, variables = {}) {
// Add variables if provided
if (variables && typeof variables === 'object') {
const varString = Object.entries(variables)
.map(([key, value]) => `${key}=${value}`)
.map(([key, value]) => `"${key}=${value}"`)
.join(' ');
if (varString) {
command += ` ${varString}`;

View file

@ -5,8 +5,8 @@ const path = require("path");
const fs = require("fs");
router.post("/trigger", global.apiAuth, (req, res) => {
console.log('Triggering call with data:', req.body, {username: req.session ? req.session.fullname || 'Unknown' : 'Unknown'});
global.trigCall(req.body.pageType, req.body.phone);
console.log('Triggering call with data:', req.body, {username: req.session ? req.session.user.fullname || 'Unknown' : 'Unknown'});
global.trigCall(req.body.pageType, req.body.phone, {username: req.session ? req.session.user.fullname || 'Unknown' : 'Unknown'});
res.status(200).send('Call triggered');
});