Some basic call logging (timestamp, caller, callee)
This commit is contained in:
parent
7c7d96fbfd
commit
a1fdfbf8e0
10
index.js
10
index.js
|
@ -622,6 +622,14 @@ app.get("/api/healthcheck", (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
// logCall function (caller, callee)
|
||||
const logCall = (caller, callee) => {
|
||||
db.run('INSERT INTO callLogs (caller, callee, timestamp) VALUES (?, ?, ?)',
|
||||
[caller, callee, Math.floor(Date.now() / 1000)],
|
||||
(err) => {
|
||||
if (err) console.error('Error logging call:', err);
|
||||
});
|
||||
}
|
||||
|
||||
// Query to get a route
|
||||
app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
||||
|
@ -643,6 +651,7 @@ app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
|||
// Check if the ANI is within the block range
|
||||
// If it is, return `local`
|
||||
console.log(`New Call: ${ani} -> ${number}`);
|
||||
logCall(ani, number);
|
||||
// incriment estCallsMade analytics
|
||||
addAnalytic("estCallsMade");
|
||||
dailyAnalytic("dailyCallsMade");
|
||||
|
@ -677,6 +686,7 @@ app.get('/api/v1', (req, res) => { // Backwards compatibility with TandmX cause
|
|||
// Check if the ANI is within the block range
|
||||
// If it is, return `local`
|
||||
console.log(`New Call: ${ani} -> ${number}`);
|
||||
logCall(ani, number);
|
||||
addAnalytic("estCallsMade");
|
||||
dailyAnalytic("dailyCallsMade");
|
||||
if (ani >= row.block_start && ani <= row.block_start + row.block_length) {
|
||||
|
|
6
migrations/006_gen_callLogs_table.sql
Normal file
6
migrations/006_gen_callLogs_table.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE callLogs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp TEXT NOT NULL,
|
||||
caller TEXT NOT NULL,
|
||||
callee TEXT NOT NULL
|
||||
);
|
Loading…
Reference in a new issue