Skip to content

Commit

Permalink
changes to enable/disable direct calling from chrome extension (#253)
Browse files Browse the repository at this point in the history
* changes to enable/disable direct calling from chrome extension

* changes to db upgrade script

* fix upgrade db script

---------

Co-authored-by: Quan HL <quan.luuhoang8@gmail.com>
  • Loading branch information
davehorton and xquanluu authored Nov 6, 2023
1 parent f725d5f commit e6168d0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 14 deletions.
11 changes: 8 additions & 3 deletions db/jambones-sql.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* SQLEditor (MySQL (2))*/

SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS account_static_ips;
Expand Down Expand Up @@ -138,6 +139,9 @@ account_sid CHAR(36) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT 1,
username VARCHAR(64),
password VARCHAR(1024),
allow_direct_app_calling BOOLEAN NOT NULL DEFAULT 1,
allow_direct_queue_calling BOOLEAN NOT NULL DEFAULT 1,
allow_direct_user_calling BOOLEAN NOT NULL DEFAULT 1,
PRIMARY KEY (client_sid)
);

Expand All @@ -158,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
(
Expand All @@ -169,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
(
Expand Down Expand Up @@ -729,4 +733,5 @@ ALTER TABLE accounts ADD FOREIGN KEY queue_event_hook_sid_idxfk (queue_event_hoo
ALTER TABLE accounts ADD FOREIGN KEY device_calling_application_sid_idxfk (device_calling_application_sid) REFERENCES applications (application_sid);

ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid);
SET FOREIGN_KEY_CHECKS=1;

SET FOREIGN_KEY_CHECKS=1;
39 changes: 30 additions & 9 deletions db/jambones.sqs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,8 +2251,8 @@
<y>1496.00</y>
</location>
<size>
<width>228.00</width>
<height>120.00</height>
<width>282.00</width>
<height>180.00</height>
</size>
<zorder>36</zorder>
<SQLField>
Expand Down Expand Up @@ -2297,6 +2297,27 @@
<notNull><![CDATA[0]]></notNull>
<uid><![CDATA[2963DB28-7248-4D58-92E6-F21F2EB9E680]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[allow_direct_app_calling]]></name>
<type><![CDATA[BOOLEAN]]></type>
<defaultValue><![CDATA[1]]></defaultValue>
<notNull><![CDATA[1]]></notNull>
<uid><![CDATA[EA252940-708B-4BD3-B211-5EC59AA540D3]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[allow_direct_queue_calling]]></name>
<type><![CDATA[BOOLEAN]]></type>
<defaultValue><![CDATA[1]]></defaultValue>
<notNull><![CDATA[1]]></notNull>
<uid><![CDATA[76CE0DFC-7CC6-46EE-82C6-2CF16C7EAD4D]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[allow_direct_user_calling]]></name>
<type><![CDATA[BOOLEAN]]></type>
<defaultValue><![CDATA[1]]></defaultValue>
<notNull><![CDATA[1]]></notNull>
<uid><![CDATA[206E169C-E5F6-4774-8D4A-5BECF25E49A3]]></uid>
</SQLField>
<labelWindowIndex><![CDATA[2]]></labelWindowIndex>
<ui.treeExpanded><![CDATA[1]]></ui.treeExpanded>
<uid><![CDATA[C2CDB45C-3F50-40B3-B8CE-2F093EB0D517]]></uid>
Expand Down Expand Up @@ -3076,17 +3097,17 @@
<overviewPanelHidden><![CDATA[0]]></overviewPanelHidden>
<pageBoundariesVisible><![CDATA[0]]></pageBoundariesVisible>
<PageGridVisible><![CDATA[0]]></PageGridVisible>
<RightSidebarWidth><![CDATA[1405.000000]]></RightSidebarWidth>
<RightSidebarWidth><![CDATA[1924.000000]]></RightSidebarWidth>
<sidebarIndex><![CDATA[2]]></sidebarIndex>
<snapToGrid><![CDATA[0]]></snapToGrid>
<SourceSidebarWidth><![CDATA[312.000000]]></SourceSidebarWidth>
<SourceSidebarWidth><![CDATA[0.000000]]></SourceSidebarWidth>
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
<windowHeight><![CDATA[1055.000000]]></windowHeight>
<windowLocationX><![CDATA[1728.000000]]></windowLocationX>
<windowLocationY><![CDATA[37.000000]]></windowLocationY>
<windowScrollOrigin><![CDATA[{1397, 626}]]></windowScrollOrigin>
<windowWidth><![CDATA[1682.000000]]></windowWidth>
<windowHeight><![CDATA[985.000000]]></windowHeight>
<windowLocationX><![CDATA[-1307.000000]]></windowLocationX>
<windowLocationY><![CDATA[1008.000000]]></windowLocationY>
<windowScrollOrigin><![CDATA[{1.5, 786}]]></windowScrollOrigin>
<windowWidth><![CDATA[2201.000000]]></windowWidth>
</SQLDocumentInfo>
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
<defaultLabelExpanded><![CDATA[1]]></defaultLabelExpanded>
Expand Down
5 changes: 4 additions & 1 deletion db/upgrade-jambonz-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ const sql = {
`,
'CREATE INDEX google_custom_voice_sid_idx ON google_custom_voices (google_custom_voice_sid)',
'CREATE INDEX speech_credential_sid_idx ON google_custom_voices (speech_credential_sid)',
'ALTER TABLE google_custom_voices ADD FOREIGN KEY speech_credential_sid_idxfk (speech_credential_sid) REFERENCES speech_credentials (speech_credential_sid) ON DELETE CASCADE'
'ALTER TABLE google_custom_voices ADD FOREIGN KEY speech_credential_sid_idxfk (speech_credential_sid) REFERENCES speech_credentials (speech_credential_sid) ON DELETE CASCADE',
'ALTER TABLE clients ADD COLUMN allow_direct_queue_calling BOOLEAN NOT NULL DEFAULT 1',
'ALTER TABLE clients ADD COLUMN allow_direct_user_calling BOOLEAN NOT NULL DEFAULT 1',
'ALTER TABLE clients ADD COLUMN allow_direct_app_calling BOOLEAN NOT NULL DEFAULT 1'
]
};

Expand Down
12 changes: 12 additions & 0 deletions lib/models/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ Client.fields = [
{
name: 'password',
type: 'string'
},
{
name: 'allow_direct_app_calling',
type: 'number'
},
{
name: 'allow_direct_queue_calling',
type: 'number'
},
{
name: 'allow_direct_user_calling',
type: 'number'
}
];

Expand Down
6 changes: 5 additions & 1 deletion test/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ test('client test', async(t) => {
account_sid,
username: 'client1',
password: 'sdf12412',
is_active: 1
is_active: 1,
allow_direct_app_calling: 0,
allow_direct_queue_calling: 1,
allow_direct_user_calling: 1,
}
});
t.ok(result.statusCode === 201, 'successfully created Client');
Expand Down Expand Up @@ -99,6 +102,7 @@ test('client test', async(t) => {
t.ok(result.username === 'client1', 'successfully retrieved Client by sid');
t.ok(result.is_active === 1 , 'successfully retrieved Client by sid');
t.ok(result.password === 'sXXXXXXX' , 'successfully retrieved Client by sid');
t.ok(result.allow_direct_app_calling === 0 , 'successfully retrieved Client by sid');

/* update the entity */
result = await request.put(`/Clients/${sid}`, {
Expand Down

0 comments on commit e6168d0

Please sign in to comment.