From 843980c7f64c4ad7eb67bf3b337fe29ab9e2b847 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 26 Nov 2024 20:25:25 -0500 Subject: [PATCH] #361 (#362) * #361 * fix typo in db upgrade script --------- Co-authored-by: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> --- db/jambones-sql.sql | 5 +++-- db/jambones.sqs | 27 +++++++++++++++++---------- db/upgrade-jambonz-db.js | 6 ++++++ lib/models/voip-carrier.js | 4 ++++ test/tts-cache.js | 12 ++++++++++-- test/voip-carriers.js | 4 +++- 6 files changed, 43 insertions(+), 15 deletions(-) diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index 431b83a1..d33afa69 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -162,7 +162,7 @@ regex VARCHAR(32) NOT NULL COMMENT 'regex-based pattern match against dialed num description VARCHAR(1024), priority INTEGER NOT NULL COMMENT 'lower priority routes are attempted first', PRIMARY KEY (lcr_route_sid) -) COMMENT='An ordered list of digit patterns in an LCR table. The patterns are tested in sequence until one matches'; +) COMMENT='An ordered list of digit patterns in an LCR table. The pat'; CREATE TABLE lcr ( @@ -173,7 +173,7 @@ default_carrier_set_entry_sid CHAR(36) COMMENT 'default carrier/route to use whe service_provider_sid CHAR(36), account_sid CHAR(36), PRIMARY KEY (lcr_sid) -) COMMENT='An LCR (least cost routing) table that is used by a service provider or account to make decisions about routing outbound calls when multiple carriers are available.'; +) COMMENT='An LCR (least cost routing) table that is used by a service '; CREATE TABLE password_settings ( @@ -416,6 +416,7 @@ register_from_user VARCHAR(128), register_from_domain VARCHAR(255), register_public_ip_in_contact BOOLEAN NOT NULL DEFAULT false, register_status VARCHAR(4096), +dtmf_type ENUM('rfc2833','tones','info') NOT NULL DEFAULT 'rfc2833', PRIMARY KEY (voip_carrier_sid) ) COMMENT='A Carrier or customer PBX that can send or receive calls'; diff --git a/db/jambones.sqs b/db/jambones.sqs index daf22d34..49fef393 100644 --- a/db/jambones.sqs +++ b/db/jambones.sqs @@ -551,7 +551,7 @@ 293.00 - 540.00 + 560.00 6 @@ -737,6 +737,13 @@ + + + + + + + @@ -1280,8 +1287,8 @@ - 31.00 - 983.00 + 25.00 + 997.00 254.00 @@ -3144,17 +3151,17 @@ - + - + - - - - - + + + + + diff --git a/db/upgrade-jambonz-db.js b/db/upgrade-jambonz-db.js index a275cde6..5ad31458 100644 --- a/db/upgrade-jambonz-db.js +++ b/db/upgrade-jambonz-db.js @@ -204,6 +204,11 @@ const sql = { 'ALTER TABLE accounts ADD COLUMN enable_debug_log BOOLEAN NOT NULL DEFAULT false', 'ALTER TABLE google_custom_voices ADD COLUMN use_voice_cloning_key BOOLEAN DEFAULT false', 'ALTER TABLE google_custom_voices ADD COLUMN voice_cloning_key MEDIUMTEXT', + ], + 9003: [ + 'ALTER TABLE google_custom_voices ADD COLUMN voice_cloning_key MEDIUMTEXT', + 'ALTER TABLE google_custom_voices ADD COLUMN use_voice_cloning_key BOOLEAN DEFAULT false', + 'ALTER TABLE voip_carriers ADD COLUMN dtmf_type ENUM(\'rfc2833\',\'tones\',\'info\') NOT NULL DEFAULT \'rfc2833\'', ] }; @@ -238,6 +243,7 @@ const doIt = async() => { if (val < 8005) upgrades.push(...sql['8005']); if (val < 9000) upgrades.push(...sql['9000']); if (val < 9002) upgrades.push(...sql['9002']); + if (val < 9003) upgrades.push(...sql['9003']); // perform all upgrades logger.info({upgrades}, 'applying schema upgrades..'); diff --git a/lib/models/voip-carrier.js b/lib/models/voip-carrier.js index 7da1a7ad..c99d3696 100644 --- a/lib/models/voip-carrier.js +++ b/lib/models/voip-carrier.js @@ -136,6 +136,10 @@ VoipCarrier.fields = [ { name: 'register_status', type: 'string' + }, + { + name: 'dtmf_type', + type: 'string' } ]; diff --git a/test/tts-cache.js b/test/tts-cache.js index 73043976..71c5cdaf 100644 --- a/test/tts-cache.js +++ b/test/tts-cache.js @@ -24,16 +24,24 @@ function makeSynthKey({account_sid = '', vendor, language, voice, engine = '', t test('tts-cache', async(t) => { const app = require('../app'); try { + // clear cache to start + let result = await request.delete('/TtsCache', { + auth: authAdmin, + resolveWithFullResponse: true, + }); + t.ok(result.statusCode === 204, 'successfully purged cache for start of test'); + // create caches const minRecords = 8; for (const i in Array(minRecords).fill(0)) { await client.set(makeSynthKey({vendor: i, language: i, voice: i, engine: i, text: i}), i); } - let result = await request.get('/TtsCache', { + result = await request.get('/TtsCache', { auth: authAdmin, json: true, }); + //console.log(result); t.ok(result.size === minRecords, 'get cache correctly'); @@ -41,7 +49,7 @@ test('tts-cache', async(t) => { auth: authAdmin, resolveWithFullResponse: true, }); - t.ok(result.statusCode === 204, 'successfully deleted application after removing phone number'); + t.ok(result.statusCode === 204, 'successfully purged cache'); result = await request.get('/TtsCache', { auth: authAdmin, diff --git a/test/voip-carriers.js b/test/voip-carriers.js index 68b95689..efeab066 100644 --- a/test/voip-carriers.js +++ b/test/voip-carriers.js @@ -207,7 +207,8 @@ test('voip carrier tests', async(t) => { json: true, body: { name: 'twilio', - e164_leading_plus: true + e164_leading_plus: true, + dtmf_type: 'tones' } }); t.ok(result.statusCode === 201, 'successfully created voip carrier for a service provider'); @@ -221,6 +222,7 @@ test('voip carrier tests', async(t) => { }); //console.log(result.body); t.ok(result.statusCode === 200, 'successfully retrieved voip carrier for a service provider'); + //console.log(result.body); sid = result.body[0].voip_carrier_sid; await deleteObjectBySid(request, '/VoipCarriers', sid);