Gwug
This commit is contained in:
parent
28d67ec0af
commit
394aee7262
3
index.js
3
index.js
|
|
@ -36,6 +36,7 @@ Object.keys(buttonsCfg).forEach(category => {
|
||||||
//console.log('Generated contexts:', contexts);
|
//console.log('Generated contexts:', contexts);
|
||||||
|
|
||||||
function trigCall(pageType, phone, variables = {}) {
|
function trigCall(pageType, phone, variables = {}) {
|
||||||
|
console.log(variables)
|
||||||
// If contexts[pageType] does not exist, return an error
|
// If contexts[pageType] does not exist, return an error
|
||||||
if (!contexts[pageType]) {
|
if (!contexts[pageType]) {
|
||||||
throw new Error(`Invalid page type: ${pageType}`);
|
throw new Error(`Invalid page type: ${pageType}`);
|
||||||
|
|
@ -61,7 +62,7 @@ function originateCall(number, context, delay, timeout, cid, variables = {}) {
|
||||||
// Add variables if provided
|
// Add variables if provided
|
||||||
if (variables && typeof variables === 'object') {
|
if (variables && typeof variables === 'object') {
|
||||||
const varString = Object.entries(variables)
|
const varString = Object.entries(variables)
|
||||||
.map(([key, value]) => `${key}=${value}`)
|
.map(([key, value]) => `"${key}=${value}"`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
if (varString) {
|
if (varString) {
|
||||||
command += ` ${varString}`;
|
command += ` ${varString}`;
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
router.post("/trigger", global.apiAuth, (req, res) => {
|
router.post("/trigger", global.apiAuth, (req, res) => {
|
||||||
console.log('Triggering call with data:', req.body, {username: req.session ? req.session.fullname || 'Unknown' : 'Unknown'});
|
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);
|
global.trigCall(req.body.pageType, req.body.phone, {username: req.session ? req.session.user.fullname || 'Unknown' : 'Unknown'});
|
||||||
res.status(200).send('Call triggered');
|
res.status(200).send('Call triggered');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue