Also inbound calls kekw
This commit is contained in:
parent
be9aef5950
commit
331cf5d172
7
index.js
7
index.js
|
@ -47,14 +47,15 @@ const cdrPool = mariadb.createPool(config.cdrdb);
|
||||||
|
|
||||||
|
|
||||||
const json2csv = (obj) => { // Specifically for CDR
|
const json2csv = (obj) => { // Specifically for CDR
|
||||||
let csv = "call_date,src,dst,caller_id,duration,context\n";
|
let csv = "call_date,src,dst,caller_id,duration,billsec,context\n";
|
||||||
for (let key in obj) {
|
for (let key in obj) {
|
||||||
data = [
|
data = [
|
||||||
obj[key].call_date,
|
obj[key].calldate,
|
||||||
obj[key].src,
|
obj[key].src,
|
||||||
obj[key].dst,
|
obj[key].dst,
|
||||||
obj[key].clid,
|
obj[key].clid,
|
||||||
obj[key].duration,
|
obj[key].duration,
|
||||||
|
obj[key].billsec,
|
||||||
obj[key].dcontext
|
obj[key].dcontext
|
||||||
];
|
];
|
||||||
csv += data.join(",") + "\n";
|
csv += data.join(",") + "\n";
|
||||||
|
@ -1331,7 +1332,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
if (result.status == "exists") {
|
if (result.status == "exists") {
|
||||||
// The user has an ext, use the cdrdb to get the records
|
// The user has an ext, use the cdrdb to get the records
|
||||||
cdrPool.getConnection().then((conn) => {
|
cdrPool.getConnection().then((conn) => {
|
||||||
conn.query(`SELECT * FROM cdr WHERE src = '${result.result.fetchExtension.user.extension}' AND calldate BETWEEN '${startDate.toISOString()}' AND '${endDate.toISOString()}'`).then((result) => {
|
conn.query(`SELECT * FROM cdr WHERE src = '${result.result.fetchExtension.user.extension}' OR dst = '${result.result.fetchExtension.user.extension}' AND calldate BETWEEN '${startDate.toISOString()}' AND '${endDate.toISOString()}'`).then((result) => {
|
||||||
if (result.length == 0) {
|
if (result.length == 0) {
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
content: "No CDR records found",
|
content: "No CDR records found",
|
||||||
|
|
Loading…
Reference in a new issue