Whoop
This commit is contained in:
parent
11a4da2584
commit
c28352875d
22
index.js
22
index.js
|
@ -84,14 +84,9 @@ const getExtCount = () => {
|
||||||
const createExtension = (ext, name, uid) => {
|
const createExtension = (ext, name, uid) => {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
await conn.query(`
|
await conn.query(`DELETE FROM devices WHERE id NOT IN (SELECT extension FROM users);`)
|
||||||
DELETE FROM devices
|
await conn.query(`DELETE FROM sip WHERE id NOT IN (SELECT extension FROM users);`);
|
||||||
WHERE id NOT IN (SELECT extension FROM users);
|
|
||||||
DELETE FROM sip
|
|
||||||
WHERE id NOT IN (SELECT extension FROM users);
|
|
||||||
`).then((result) => {
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
|
||||||
pbxClient.request(funcs.minifyQuery(funcs.generateQuery('lookup', {
|
pbxClient.request(funcs.minifyQuery(funcs.generateQuery('lookup', {
|
||||||
ext: ext
|
ext: ext
|
||||||
}))).then((result) => {
|
}))).then((result) => {
|
||||||
|
@ -617,14 +612,9 @@ dcClient.on('ready', async () => {
|
||||||
// This will delete any devices that don't have a corresponding user
|
// This will delete any devices that don't have a corresponding user
|
||||||
// This is a safety measure to prevent orphaned devices (it breaks the API entirely if there are any)
|
// This is a safety measure to prevent orphaned devices (it breaks the API entirely if there are any)
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
await conn.query(`
|
await conn.query(`DELETE FROM devices WHERE id NOT IN (SELECT extension FROM users);`)
|
||||||
DELETE FROM devices
|
await conn.query(`DELETE FROM sip WHERE id NOT IN (SELECT extension FROM users);`);
|
||||||
WHERE id NOT IN (SELECT extension FROM users);
|
|
||||||
DELETE FROM sip
|
|
||||||
WHERE id NOT IN (SELECT extension FROM users);
|
|
||||||
`).then((result) => {
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -769,6 +759,10 @@ sshConn.on('ready', () => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
await conn.query(`DELETE FROM devices WHERE id NOT IN (SELECT extension FROM users);`)
|
||||||
|
await conn.query(`DELETE FROM sip WHERE id NOT IN (SELECT extension FROM users);`);
|
||||||
|
conn.end();
|
||||||
|
|
||||||
dcClient.on("guildMemberRemove", (member) => {
|
dcClient.on("guildMemberRemove", (member) => {
|
||||||
// Delete the extension if the user leaves the server
|
// Delete the extension if the user leaves the server
|
||||||
|
|
Loading…
Reference in a new issue