Fix phone number format
This commit is contained in:
parent
ee777a3363
commit
25a7d70c07
13
main.js
13
main.js
@ -34,12 +34,15 @@ var initialsynccomplete = false;
|
||||
|
||||
/**
|
||||
* From https://github.com/stevekinney/node-phone-formatter
|
||||
* @param {type} phoneNumber
|
||||
* @param {type} formatString
|
||||
* @param {type} options
|
||||
* @returns {unresolved}
|
||||
* @param {string} phoneNumber
|
||||
* @param {string} formatString
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatPhoneNumber(phoneNumber, formatString) {
|
||||
phoneNumber = phoneNumber.replace(
|
||||
/^[\+\d{1,3}\-\s]*\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,
|
||||
"$1$2$3"
|
||||
);
|
||||
for (var i = 0, l = phoneNumber.length; i < l; i++) {
|
||||
formatString = formatString.replace("N", phoneNumber[i]);
|
||||
}
|
||||
@ -133,7 +136,7 @@ function createOrJoinSMSRoom(tel, ournumber, callback) {
|
||||
room_alias_name: "SMS_" + tel + "_" + ournumber,
|
||||
visibility: "private",
|
||||
invite: settings.inviteusers,
|
||||
name: formatPhoneNumber(tel, "(NNN) NNN-NNNN"),
|
||||
name: formatPhoneNumber(tel, "1 (NNN) NNN-NNNN"),
|
||||
topic: "SMS conversation with " + tel + " (using " + ournumber + ")"
|
||||
}).then((room) => {
|
||||
logger.debug("Room" + roomName + " created with ID " + room.room_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user