Compare View

switch
from
...
to
 
Commits (5)

Changes

Showing 7 changed files Side-by-side Diff

lib/command-handler/adddownline.js
... ... @@ -49,6 +49,7 @@ function execute(tokens, params, cb) {
49 49 coreParams.generate_password = 1;
50 50 }
51 51  
  52 + /*
52 53 if (typeof coreParams.new_terminal_name === 'string' && coreParams.new_terminal_name.indexOf('@') < 0) {
53 54 let suffix = '';
54 55 if (common.isPhoneNumber(coreParams.new_terminal_name)) {
... ... @@ -62,6 +63,11 @@ function execute(tokens, params, cb) {
62 63 coreParams.new_terminal_name += suffix;
63 64 }
64 65 }
  66 + */
  67 +
  68 + if (typeof coreParams.new_terminal_name === 'string' && common.isPhoneNumber(coreParams.new_terminal_name) && coreParams.new_terminal_name.indexOf('0') === 0) {
  69 + coreParams.new_terminal_name = coreParams.new_terminal_name.replace(/^0/, '62');
  70 + }
65 71  
66 72 coreapi(coreEndpoint, coreParams, 'GET', cb);
67 73 }
lib/command-handler/addterminal.js
1 1 "use strict";
2 2  
  3 +const common = require('../common');
3 4 const commandError = require('./error');
4 5 const coreapi = require('../coreapi');
5 6  
... ... @@ -30,6 +31,10 @@ function execute(tokens, params, cb) {
30 31 password: tokens.length < 5 ? tokens[2] : tokens[3]
31 32 };
32 33  
  34 + if (typeof coreParams.terminal_name === 'string' && common.isPhoneNumber(coreParams.terminal_name) && coreParams.indexOf('0') === 0) {
  35 + coreParams.terminal_name = coreParams.terminal_name.replace(/^0/, '62');
  36 + }
  37 +
33 38 coreapi(coreEndpoint, coreParams, 'GET', cb);
34 39 }
35 40  
... ... @@ -14,7 +14,7 @@ function isPhoneNumber(terminalName) {
14 14 return false;
15 15 }
16 16  
17   - if (!terminalName) return false;
  17 + if (terminalName.trim().length < 7) return false;
18 18  
19 19 return Boolean(terminalName.replace(/^\+/, '').match(/^\d+$/));
20 20 }
lib/default-command.js
... ... @@ -155,8 +155,10 @@ module.exports = {
155 155 listterminal: [
156 156 'listmsisdn',
157 157 'listterminal',
  158 + 'listterm',
158 159 'lsmsisdn',
159 160 'lsterminal',
  161 + 'lsterm',
160 162 'msisdn',
161 163 'msisdnlist',
162 164 'msisdnls',
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.10.2",
  3 + "version": "0.10.3",
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.10.2",
  3 + "version": "0.10.3",
4 4 "description": "Komodo Common Messaging Center",
5 5 "main": "index.js",
6 6 "scripts": {
... ... @@ -17,17 +17,22 @@ describe(&#39;#common&#39;, () =&gt; {
17 17  
18 18 describe('#isPhoneNumber', () => {
19 19 it('should detect correctly', () => {
20   - common.isPhoneNumber('0818').should.be.ok();
21   - common.isPhoneNumber('62818').should.be.ok();
22   - common.isPhoneNumber('+62818').should.be.ok();
  20 + common.isPhoneNumber('0818').should.not.be.ok();
  21 + common.isPhoneNumber('62818').should.not.be.ok();
  22 + common.isPhoneNumber('+62818').should.not.be.ok();
  23 +
  24 + common.isPhoneNumber('081808180').should.be.ok();
  25 + common.isPhoneNumber('62818818').should.be.ok();
  26 + common.isPhoneNumber('+62818818').should.be.ok();
  27 +
23 28 common.isPhoneNumber('ada').should.not.be.ok();
24 29 });
25 30 });
26 31  
27 32 describe('#indonesiaIntlNumberToZeroPrefix', () => {
28 33 it('should transform correctly', () => {
29   - common.indonesiaIntlNumberToZeroPrefix('+62818').should.equal('0818');
30   - common.indonesiaIntlNumberToZeroPrefix('0818').should.equal('0818');
  34 + common.indonesiaIntlNumberToZeroPrefix('+6281812341234').should.equal('081812341234', '+6281812341234');
  35 + common.indonesiaIntlNumberToZeroPrefix('081808180').should.equal('081808180', '081808180');
31 36 common.indonesiaIntlNumberToZeroPrefix('ada').should.equal('ada');
32 37 });
33 38 })