Guh, node 16 not

This commit is contained in:
Christopher Cookman 2023-10-01 16:33:54 -06:00
parent 931ed3c475
commit 98179d9d7d
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -94,10 +94,12 @@ watcher.on("add", async (event, path) => {
if (watched.includes(path)) return;
watched.push(path);
// extract file name from path
let filename = path.split("/").pop();
// extract mailbox from path (path looks like /var/spool/asterisk/voicemail/default/1000/INBOX/file.wav)
let mailbox = path.split("/")[6];
// extract file name from path, needs to be node 16 compatible, path.split is not
let filename = path.substring(path.lastIndexOf("/") + 1);
// extract mailbox from path (path looks like /var/spool/asterisk/voicemail/default/1000/INBOX/file.wav), needs to be node 16 compatible, path.split is not
let mailbox = path.substring(path.lastIndexOf("/", path.lastIndexOf("/") - 1) + 1, path.lastIndexOf("/"));
if(mailbox !== "INBOX") return; // ignore anything that isn't in the inbox
// if its a txt file (voicemail info), open it and get relavent info
// make a json object with the callerid, duration, origdate, and origmailbox from the txt file