From 84561d469df257ae4e956754e219f863f10c2c54 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 20 Dec 2025 14:17:33 -0700 Subject: [PATCH] Goobus --- index.js | 69 +++++++++++++++++++++++++++++++++++++------------ views/index.ejs | 61 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 111 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 6fabe5e..59446c2 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,56 @@ const { exec } = require('child_process'); require('dotenv').config(); +const contexts = { + "A1": { + context: 'custom-emergency.9001.1', + timeout: 30000, + cid: 'Live Page' + }, + "E1": { + context: 'custom-emergency.9002.1', + timeout: 30000, + cid: 'Emergency Live Page' + }, + "A2": { + context: 'custom-emergency.9003.1', + timeout: 30000, + cid: 'Announcement 2', + number: '2000' // Direct to page group, no phone needed + }, + "E2": { + context: 'custom-emergency.9004.1', + timeout: 30000, + cid: 'Emergency 2', + number: '2000' // Direct to page group, no phone needed + }, + "A3": { + context: 'custom-emergency.9005.1', + timeout: 30000, + cid: 'Announcement 3', + number: '2000' // Direct to page group, no phone needed + }, + "E3": { + context: 'custom-emergency.9006.1', + timeout: 30000, + cid: 'Emergency 3', + number: '2000' // Direct to page group, no phone needed + } +} + +function trigCall(pageType, phone) { + // If contexts[pageType] does not exist, return an error + if (!contexts[pageType]) { + throw new Error(`Invalid page type: ${pageType}`); + } + const { context, timeout, cid, number } = contexts[pageType]; + const targetNumber = number || phone; + if (!targetNumber) { + throw new Error(`Phone number is required for page type: ${pageType}`); + } + return originateCall(targetNumber, context, 0, timeout, cid); +} + function originateCall(number, context, delay, timeout, cid, variables = {}) { // Build the base command let command = `/usr/bin/ast_originate ${number} ${context} ${delay} ${timeout} ${Buffer.from(cid).toString('base64')}`; @@ -52,25 +102,12 @@ function auth(req, res, next) { next(); } -app.get('/', auth, (req, res) => { +app.get('/', (req, res) => { res.render('index', { session: req.session }); }); -app.get('/login', (req, res) => { - if (req.session && req.session.authenticated) { - return res.redirect('/'); - } - res.render('login'); -}); - -app.post('/login', (req, res) => { - const { username, password } = req.body; - if (username === process.env.USER && password === process.env.PASS) { - req.session.authenticated = true; - req.session.username = username; - return res.redirect('/'); - } - res.redirect('/login'); +app.post('/trig', async (req, res) => { + console.log('Triggering call with data:', req.body); }); app.listen(PORT, HOST, () => { diff --git a/views/index.ejs b/views/index.ejs index b24cf8c..7868a9b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -7,11 +7,66 @@ Funny goofy test page!!!!!1! -

Welcome to the Funny Goofy Test Page <%= session.username %>!

-

This is a simple web page to demonstrate EJS templating with Bootstrap styling.

- +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +

Normal Announcements

Emergency Announcements

+ + + +
+ + + +
+ + + +
+
+ \ No newline at end of file