From 2ad4ecbd97e132aec21c3a6cc8d9dfffecf29d9f Mon Sep 17 00:00:00 2001 From: isaac2600hz Date: Thu, 27 Oct 2022 16:58:51 -0500 Subject: [PATCH 1/5] Add a function that checks for UTF-8 character in numbers --- app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.js b/app.js index c0c71939..42f4e7c9 100644 --- a/app.js +++ b/app.js @@ -102,6 +102,17 @@ define(function(require) { var self = this; }, + filterNumbersToDisplay: function(number) { + var isAlphanumericExtensionsEnabled = monster.util.isFeatureAvailable('smartpbx.users.settings.utfExtensions.show'); + if (isAlphanumericExtensionsEnabled) { + return true; + } + var regex = /\D/; + var isValidPhoneNumber = monster.util.getFormatPhoneNumber(number).isValid; + var isAlphanumericExtension = !isValidPhoneNumber && regex.test(number); + return !isAlphanumericExtension; + }, + loadGlobalData: function(callback) { var self = this; From d3838a7cd7843962b32a1e4934f805996bcb2fe0 Mon Sep 17 00:00:00 2001 From: isaac2600hz Date: Thu, 27 Oct 2022 17:00:42 -0500 Subject: [PATCH 2/5] Check for UTF-8 character in extensions --- submodules/users/users.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/submodules/users/users.js b/submodules/users/users.js index e46ba118..5d1a5322 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -448,14 +448,16 @@ define(function(require) { var extensions = _ .chain(numbers) .filter(function(number) { - return _.size(number) < 7; + if (_.size(number) < 7) { + return self.filterNumbersToDisplay(number); + } + return false; }) .concat(extra.listExtensions) .value(), phoneNumbers = _.filter(numbers, function(number) { return _.size(number) >= 7; }); - return { listExtensions: extensions, listCallerId: phoneNumbers, @@ -3872,7 +3874,9 @@ define(function(require) { response.assignedNumbers.push(numberElement); } else { - response.extensions.push(number); + if (self.filterNumbersToDisplay(number)) { + response.extensions.push(number); + } } }); } From 9e2e1f52a0f71ec5ff75bd2efc8678c96732c6e6 Mon Sep 17 00:00:00 2001 From: isaac2600hz Date: Mon, 31 Oct 2022 14:26:12 -0600 Subject: [PATCH 3/5] Delete phone number verification --- app.js | 5 ++--- submodules/users/users.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 42f4e7c9..fe011c0e 100644 --- a/app.js +++ b/app.js @@ -102,14 +102,13 @@ define(function(require) { var self = this; }, - filterNumbersToDisplay: function(number) { + isExtensionDisplayable: function(number) { var isAlphanumericExtensionsEnabled = monster.util.isFeatureAvailable('smartpbx.users.settings.utfExtensions.show'); if (isAlphanumericExtensionsEnabled) { return true; } var regex = /\D/; - var isValidPhoneNumber = monster.util.getFormatPhoneNumber(number).isValid; - var isAlphanumericExtension = !isValidPhoneNumber && regex.test(number); + var isAlphanumericExtension = regex.test(number); return !isAlphanumericExtension; }, diff --git a/submodules/users/users.js b/submodules/users/users.js index 5d1a5322..64cacf9b 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -449,7 +449,7 @@ define(function(require) { .chain(numbers) .filter(function(number) { if (_.size(number) < 7) { - return self.filterNumbersToDisplay(number); + return self.isExtensionDisplayable(number); } return false; }) @@ -3874,7 +3874,7 @@ define(function(require) { response.assignedNumbers.push(numberElement); } else { - if (self.filterNumbersToDisplay(number)) { + if (self.isExtensionDisplayable(number)) { response.extensions.push(number); } } From 9a19b413b093f0c9fd147af744b7513d21830ca6 Mon Sep 17 00:00:00 2001 From: isaac2600hz Date: Tue, 1 Nov 2022 12:38:57 -0600 Subject: [PATCH 4/5] Fix code to follow 2600hz coding standards --- app.js | 8 +++++--- submodules/users/users.js | 13 ++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index fe011c0e..838db77d 100644 --- a/app.js +++ b/app.js @@ -103,12 +103,14 @@ define(function(require) { }, isExtensionDisplayable: function(number) { - var isAlphanumericExtensionsEnabled = monster.util.isFeatureAvailable('smartpbx.users.settings.utfExtensions.show'); + var isAlphanumericExtensionsEnabled = monster.util.isFeatureAvailable('smartpbx.users.settings.utfExtensions.show'), + regex = /\D/, + isAlphanumericExtension = regex.test(number); + if (isAlphanumericExtensionsEnabled) { return true; } - var regex = /\D/; - var isAlphanumericExtension = regex.test(number); + return !isAlphanumericExtension; }, diff --git a/submodules/users/users.js b/submodules/users/users.js index 64cacf9b..a406e63c 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -445,10 +445,11 @@ define(function(require) { }); }, mainUserCallflowsPerUserId), getNumbersExtra = function(numbers, extra) { - var extensions = _ + var EXTENSION_MAX_LENGTH = 7, + extensions = _ .chain(numbers) .filter(function(number) { - if (_.size(number) < 7) { + if (_.size(number) < EXTENSION_MAX_LENGTH) { return self.isExtensionDisplayable(number); } return false; @@ -456,7 +457,7 @@ define(function(require) { .concat(extra.listExtensions) .value(), phoneNumbers = _.filter(numbers, function(number) { - return _.size(number) >= 7; + return _.size(number) >= EXTENSION_MAX_LENGTH; }); return { listExtensions: extensions, @@ -3873,10 +3874,8 @@ define(function(require) { numberElement.isLocal = numberElement.features.indexOf('local') > -1; response.assignedNumbers.push(numberElement); - } else { - if (self.isExtensionDisplayable(number)) { - response.extensions.push(number); - } + } else if (self.isExtensionDisplayable(number)) { + response.extensions.push(number); } }); } From 59f9a596bf8f44f1d1a19bbeabe061458d7f228a Mon Sep 17 00:00:00 2001 From: isaac2600hz Date: Thu, 3 Nov 2022 11:34:36 -0600 Subject: [PATCH 5/5] Fix code to follow 2600hz coding standards --- app.js | 6 +----- submodules/users/users.js | 9 +++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 838db77d..f164c22d 100644 --- a/app.js +++ b/app.js @@ -107,11 +107,7 @@ define(function(require) { regex = /\D/, isAlphanumericExtension = regex.test(number); - if (isAlphanumericExtensionsEnabled) { - return true; - } - - return !isAlphanumericExtension; + return isAlphanumericExtensionsEnabled || !isAlphanumericExtension; }, loadGlobalData: function(callback) { diff --git a/submodules/users/users.js b/submodules/users/users.js index a406e63c..8cbd0e2b 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -445,19 +445,16 @@ define(function(require) { }); }, mainUserCallflowsPerUserId), getNumbersExtra = function(numbers, extra) { - var EXTENSION_MAX_LENGTH = 7, + var extensionMaxLength = 7, extensions = _ .chain(numbers) .filter(function(number) { - if (_.size(number) < EXTENSION_MAX_LENGTH) { - return self.isExtensionDisplayable(number); - } - return false; + return _.size(number) < extensionMaxLength && self.isExtensionDisplayable(number); }) .concat(extra.listExtensions) .value(), phoneNumbers = _.filter(numbers, function(number) { - return _.size(number) >= EXTENSION_MAX_LENGTH; + return _.size(number) >= extensionMaxLength; }); return { listExtensions: extensions,