Compare commits

...

2 commits

Author SHA1 Message Date
Christopher Cookman 952aaced2b Add loop logic as well 2025-10-25 10:22:16 -06:00
Christopher Cookman daceb05d52 Add delete logic 2025-10-25 10:21:46 -06:00

View file

@ -33,10 +33,25 @@ const main = async () => {
} }
} }
} }
console.log("Call forwards:", forwards);
// Search all forwards for any target that is between 700 and 800. If it exists, log to console and run `asterisk -x "database del CF[U/B] <ext>"` to delete it
for (const [key, target] of Object.entries(forwards)) {
const targetExt = parseInt(target, 10);
if (targetExt >= 700 && targetExt < 800) {
console.log(`Deleting forward ${key} to target ${target}`);
const delCommand = `asterisk -x "database del ${key.replace('/', ' ')}"`;
const { error, stdout, stderr } = await runAsterisk(delCommand);
if (error) {
console.error(`Error executing command "${delCommand}": ${error}`);
} else {
console.log(`Successfully deleted forward ${key}`);
}
}
}
} catch (err) { } catch (err) {
console.error(`Unexpected error: ${err}`); console.error(`Unexpected error: ${err}`);
} }
setTimeout(main, 3000); // Run every 60 seconds
}; };
const startup = async () => { const startup = async () => {