-
Notifications
You must be signed in to change notification settings - Fork 215
Issue#708 Add PhoneNumber Regex for SMS/Voice and USSD #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I;m assigning to @maria-farooq |
Hi @croufay i reviewed other 2 PRs
This one i think should be reviewed by @gvagenas Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay there are no test cases and no documentation. I could provide the test cases but I don't know what to test for.
} finally { | ||
}//} | ||
//check if there is a Regex match only if parameter is a String aka phone Number | ||
if(!(parameter instanceof Sid)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay why you check if object parameter is not an instance of Sid? What is the point here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay what is your comment on that?
}//} | ||
//check if there is a Regex match only if parameter is a String aka phone Number | ||
if(!(parameter instanceof Sid)){ | ||
inboundPhoneNumber = parameter.toString().replace("+1", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay why you always remove the +1 sign? What if we have +1512*
, what if we have +331554*
?
The +
sign should be removed after we check the DB and there is no match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gvagenas, that shouldn't be a problem because the first part always checks for exact match. ex. +331554*, If there is no exact match, it does a regex match. You have to remove the + sign as it has a special meaning and it will cause the regex search to fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay here you don't remove just the +
sign but the +1
so I guess you have to fix that, right?
Also, you mentioned that the first part always checks for exact match. ex. +331554*, If there is no exact match, it does a regex match
, I don't get that. From the code I can see that if the parameter contains *
or #
you try a REGEX search by first removing the +1
, can you please point me to the part of the code you refer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//check if there is a Regex match only if parameter is a String aka phone Number | ||
if(!(parameter instanceof Sid)){ | ||
inboundPhoneNumber = parameter.toString().replace("+1", ""); | ||
logger.warn(" Inbound phoneNumber : " + inboundPhoneNumber ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay no need for WARN log here. Just make it INFO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can update this to INFO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @croufay
String phoneRegexPattern = null; | ||
try { | ||
List<IncomingPhoneNumber> listPhones = getAllIncomingPhoneNumbers(); | ||
for (IncomingPhoneNumber listPhone : listPhones){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay I don't get the reason to go through all the stored numbers to build the Regex pattern. Can you elaborate? This doesn't seem to be an efficient way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gvagenas, that is true but I didn't want to mess with the exact match we already have in place. Another thing is that the exact match is done using predefined SQL that we have defined in the https://github.com/RestComm/Restcomm-Connect/blob/master/restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/incoming-phone-numbers.xml
The other option would be the parse the Regex using mysql but that might be problematic if mysql or mariadb version changed as we have seen when we do DB upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay can you please explain the steps of your implementation here, I think I am missing the reason and I don't understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@croufay we need a design document here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to avoid iterating over ALL IncomingPhoneNumbers we should add a new column at the IncomingPhoneNumbers table to flag REGEX true/false when we create a DID.
There must be a validation method to tell if the number is DID, USSD ShortCode or Regex
@gvagenas , the test case are similar to what we already do to match any numbers. We just need to add a few of the scenarios below ^*77...33#$ = matches any number that starts with *77 and and the three dots matches any character and it must end with a # sign ^[12]2233#$ = matches any number that starts with 1 or 2 and ends with 2233# ^[]76[]88[456]#$ = matches any number that starts with 76884# or 76886# or 76886# 7777|8888 = matches 7777 or 8888 [45]234[23] = matches 42342, 42343, 52342 and 52343, All tested with Voice, SMS or USSD where relevant. |
@croufay please provide test cases for the REGEX rules we support here. You can copy CallLifeCycleTest or TestDialVerb* and the DB file it uses, to provide REGEX rules in DB instead of full numbers. |
Provide java regex validation at Admin UI and IncomingPhoneNumber REST API |
For the testsuite you should create a new test class similar to CallLifecycleTest, create a new DB based on |
@croufay the PR is ready to merge, code is ok, tests are passing, all good. |
Great, thanks @croufay , I will merge today |
Issue#708 Add PhoneNumber Regex for SMS/Voice and Ussd
The code does a normal exact match and if that fails, it checks if there is a relevant Regex match
example regex
tested
^*77...33#$ = matches any number that starts with *77 and and the three dots matches any character and it must end with a # sign
^[12]2233#$ = matches any number that starts with 1 or 2 and ends with 2233#
^[]76[]88[456]#$ = matches any number that starts with 76884# or 76886# or 76886#
7777|8888 = matches 7777 or 8888
[45]234[23] = matches 42342, 42343, 52342 and 52343,
All tested with Voice, SMS or USSD where relevant.