Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / services / xdr / utils.js
index eec3c31..9930b16 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x144a=['then','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]','getVoiceQueueByName','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]','addTime','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','diffTime','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','http','../../config/logger','xdr','info','inspect','debug','error','request','catch','[utils][request]\x20name:%s','GetUser','internal','name','interface'];(function(_0x177e14,_0x401d6b){var _0x4dcdfe=function(_0x2c0158){while(--_0x2c0158){_0x177e14['push'](_0x177e14['shift']());}};_0x4dcdfe(++_0x401d6b);}(_0x144a,0xe7));var _0xa144=function(_0x30804f,_0x226d94){_0x30804f=_0x30804f-0x0;var _0x235ebf=_0x144a[_0x30804f];return _0x235ebf;};'use strict';var BPromise=require(_0xa144('0x0'));var jayson=require(_0xa144('0x1'));var moment=require(_0xa144('0x2'));var util=require(_0xa144('0x3'));var client=jayson[_0xa144('0x4')][_0xa144('0x5')]({'port':0x2329});var logger=require(_0xa144('0x6'))(_0xa144('0x7'));exports[_0xa144('0x8')]=function(_0x1109b4,_0x3d3555){logger[_0xa144('0x8')](_0x1109b4,_0x3d3555?util[_0xa144('0x9')](_0x3d3555,{'showHidden':![],'depth':null}):'');};exports[_0xa144('0xa')]=function(_0x27aebd,_0x30964d){logger[_0xa144('0xa')](_0x27aebd,_0x30964d?util[_0xa144('0x9')](_0x30964d,{'showHidden':![],'depth':null}):'');};exports['error']=function(_0x2afb2d,_0xe845ad){logger[_0xa144('0xb')](_0x2afb2d,_0xe845ad?util[_0xa144('0x9')](_0xe845ad,{'showHidden':![],'depth':null}):'');};exports[_0xa144('0xc')]=function(_0x440aa2,_0x45e2ea){return client['request'](_0x440aa2,{'body':_0x45e2ea})['then'](function(_0x449b73){logger[_0xa144('0xa')]('[utils][request]\x20name:%s',_0x440aa2,_0x449b73?util['inspect'](_0x449b73,{'showHidden':![],'depth':null}):'');})[_0xa144('0xd')](function(_0x29700a){logger[_0xa144('0xb')](_0xa144('0xe'),_0x440aa2,_0x29700a?util['inspect'](_0x29700a,{'showHidden':![],'depth':null}):'');});};function getUser(_0x1fd80b){return client[_0xa144('0xc')](_0xa144('0xf'),{'options':{'raw':!![],'attributes':['id',_0xa144('0x10'),_0xa144('0x11'),_0xa144('0x12')],'where':_0x1fd80b,'limit':0x1}})[_0xa144('0x13')](function(_0x521510){logger[_0xa144('0xa')]('[utils][getUser]\x20where:%s',JSON[_0xa144('0x14')](_0x1fd80b),_0x521510?util[_0xa144('0x9')](_0x521510,{'showHidden':![],'depth':null}):'');return _0x521510[_0xa144('0x15')][_0xa144('0x16')]?_0x521510[_0xa144('0x15')][0x0]:null;});}exports[_0xa144('0x17')]=function(_0x37d7ca){return new BPromise(function(_0x37cdaa,_0x8eafbf){if(_0x37d7ca){return getUser({'internal':_0x37d7ca})['then'](function(_0x2cba05){logger['info'](_0xa144('0x18'),_0x37d7ca,_0x2cba05?_0xa144('0x19'):_0xa144('0x1a'));return _0x37cdaa(_0x2cba05);})['catch'](function(_0x4eafb4){logger['error'](_0xa144('0x1b'),_0x4eafb4?util[_0xa144('0x9')](_0x4eafb4,{'showHidden':![],'depth':null}):'');return _0x37cdaa(null);});}return _0x37cdaa(null);});};exports['getUserByInterface']=function(_0x2aa390){return new BPromise(function(_0x2d526e,_0x3fbe){if(_0x2aa390){return getUser({'interface':_0x2aa390})['then'](function(_0x896974){logger[_0xa144('0x8')](_0xa144('0x1c'),_0x2aa390,_0x896974?'found':'notfound');return _0x2d526e(_0x896974);})[_0xa144('0xd')](function(_0x3b7c73){logger[_0xa144('0xb')](_0xa144('0x1d'),_0x3b7c73?util[_0xa144('0x9')](_0x3b7c73,{'showHidden':![],'depth':null}):'');return _0x2d526e(null);});}return _0x2d526e(null);});};exports[_0xa144('0x1e')]=function(_0x180b97){return new BPromise(function(_0x53836a,_0x2d5ffb){if(_0x180b97){return getUser({'name':_0x180b97})[_0xa144('0x13')](function(_0x52c8c8){logger['info']('[utils][getUserByName]\x20name:%s\x20%s',_0x180b97,_0x52c8c8?'found':_0xa144('0x1a'));return _0x53836a(_0x52c8c8);})[_0xa144('0xd')](function(_0x4feddf){logger['error'](_0xa144('0x1f'),_0x4feddf?util[_0xa144('0x9')](_0x4feddf,{'showHidden':![],'depth':null}):'');return _0x53836a(null);});}return _0x53836a(null);});};exports[_0xa144('0x20')]=function(_0xb7d8b8){return new BPromise(function(_0x2beac8,_0x54f6e2){if(_0xb7d8b8){return client[_0xa144('0xc')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0xa144('0x11'),_0xa144('0x21'),_0xa144('0x22'),_0xa144('0x23')],'where':{'name':_0xb7d8b8},'limit':0x1}})[_0xa144('0x13')](function(_0x47476b){logger[_0xa144('0xa')](_0xa144('0x24'),_0xb7d8b8,_0x47476b?util[_0xa144('0x9')](_0x47476b,{'showHidden':![],'depth':null}):'');logger[_0xa144('0x8')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0xb7d8b8,_0x47476b?_0xa144('0x19'):_0xa144('0x1a'));return _0x2beac8(_0x47476b['result'][_0xa144('0x16')]?_0x47476b['result'][0x0]:null);})[_0xa144('0xd')](function(_0x6a119e){logger[_0xa144('0xb')](_0xa144('0x25'),_0x6a119e?util['inspect'](_0x6a119e,{'showHidden':![],'depth':null}):'');return _0x2beac8(null);});}return _0x2beac8(null);});};exports[_0xa144('0x26')]=function(_0x5d6f15,_0x4e43a4){return moment(_0x5d6f15)[_0xa144('0x27')](_0x4e43a4,_0xa144('0x28'))[_0xa144('0x29')](_0xa144('0x2a'));};exports[_0xa144('0x2b')]=function(_0x3ce77d,_0x1beeb4){return moment(_0x3ce77d)[_0xa144('0x2c')](_0x1beeb4,'seconds')[_0xa144('0x29')](_0xa144('0x2a'));};exports[_0xa144('0x2d')]=function(_0x495f0c,_0x124218){return moment(_0x495f0c)['diff'](moment(_0x124218),'seconds');};exports[_0xa144('0x2e')]=function(_0xe6c4c3,_0x7e9cd9){return parseInt(_0xe6c4c3,0xa)+parseInt(_0x7e9cd9,0xa);};exports[_0xa144('0x2f')]=function(){return moment()['format'](_0xa144('0x2a'));};exports[_0xa144('0x30')]=function(_0x17aee8,_0x2cd0ab){if(_0x2cd0ab){return moment(_0x17aee8)[_0xa144('0x30')](_0x2cd0ab);}return!![];};exports['isBefore']=function(_0x1577b4,_0x41cf2c){if(_0x41cf2c){return moment(_0x1577b4)[_0xa144('0x31')](_0x41cf2c);}else if(_0x1577b4){return!![];}return![];};
\ No newline at end of file
+var _0x377e=['debug','error','request','then','[utils][request]\x20name:%s','catch','GetUser','internal','name','interface','[utils][getUser]\x20where:%s','result','length','getUserByInternal','found','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','notfound','[utils][getUserByInterface]','getUserByName','info','[utils][getUserByName]\x20name:%s\x20%s','[utils][getUserByName]','getVoiceQueueByName','GetVoiceQueue','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','addTime','add','seconds','YYYY-MM-DD\x20HH:mm:ss','subtract','format','diff','isAfter','isBefore','bluebird','moment','client','http','../../config/logger','xdr','inspect'];(function(_0x476161,_0x2089ff){var _0x5e69d9=function(_0x16c768){while(--_0x16c768){_0x476161['push'](_0x476161['shift']());}};_0x5e69d9(++_0x2089ff);}(_0x377e,0x1d9));var _0xe377=function(_0x2db82d,_0x2576f7){_0x2db82d=_0x2db82d-0x0;var _0x424948=_0x377e[_0x2db82d];return _0x424948;};'use strict';var BPromise=require(_0xe377('0x0'));var jayson=require('jayson/promise');var moment=require(_0xe377('0x1'));var util=require('util');var client=jayson[_0xe377('0x2')][_0xe377('0x3')]({'port':0x2329});var logger=require(_0xe377('0x4'))(_0xe377('0x5'));exports['info']=function(_0x3bf895,_0x37dcf6){logger['info'](_0x3bf895,_0x37dcf6?util[_0xe377('0x6')](_0x37dcf6,{'showHidden':![],'depth':null}):'');};exports[_0xe377('0x7')]=function(_0x119693,_0x4392dc){logger['debug'](_0x119693,_0x4392dc?util[_0xe377('0x6')](_0x4392dc,{'showHidden':![],'depth':null}):'');};exports[_0xe377('0x8')]=function(_0x446245,_0x4aea70){logger[_0xe377('0x8')](_0x446245,_0x4aea70?util[_0xe377('0x6')](_0x4aea70,{'showHidden':![],'depth':null}):'');};exports[_0xe377('0x9')]=function(_0x31d58c,_0x3d4f59){return client['request'](_0x31d58c,{'body':_0x3d4f59})[_0xe377('0xa')](function(_0x48aad3){logger[_0xe377('0x7')](_0xe377('0xb'),_0x31d58c,_0x48aad3?util[_0xe377('0x6')](_0x48aad3,{'showHidden':![],'depth':null}):'');})[_0xe377('0xc')](function(_0x559b27){logger[_0xe377('0x8')](_0xe377('0xb'),_0x31d58c,_0x559b27?util['inspect'](_0x559b27,{'showHidden':![],'depth':null}):'');});};function getUser(_0x5d0e4c){return client[_0xe377('0x9')](_0xe377('0xd'),{'options':{'raw':!![],'attributes':['id',_0xe377('0xe'),_0xe377('0xf'),_0xe377('0x10')],'where':_0x5d0e4c,'limit':0x1}})[_0xe377('0xa')](function(_0x16d1f3){logger['debug'](_0xe377('0x11'),JSON['stringify'](_0x5d0e4c),_0x16d1f3?util[_0xe377('0x6')](_0x16d1f3,{'showHidden':![],'depth':null}):'');return _0x16d1f3[_0xe377('0x12')][_0xe377('0x13')]?_0x16d1f3[_0xe377('0x12')][0x0]:null;});}exports[_0xe377('0x14')]=function(_0x87ace4){return new BPromise(function(_0x50167f,_0x490eed){if(_0x87ace4){return getUser({'internal':_0x87ace4})['then'](function(_0x1f9f32){logger['info']('[utils][getUserByInternal]\x20internal:%s\x20%s',_0x87ace4,_0x1f9f32?_0xe377('0x15'):'notfound');return _0x50167f(_0x1f9f32);})[_0xe377('0xc')](function(_0x1000bd){logger[_0xe377('0x8')](_0xe377('0x16'),_0x1000bd?util[_0xe377('0x6')](_0x1000bd,{'showHidden':![],'depth':null}):'');return _0x50167f(null);});}return _0x50167f(null);});};exports[_0xe377('0x17')]=function(_0x107b5d){return new BPromise(function(_0x1df703,_0x557172){if(_0x107b5d){return getUser({'interface':_0x107b5d})[_0xe377('0xa')](function(_0x180029){logger['info'](_0xe377('0x18'),_0x107b5d,_0x180029?_0xe377('0x15'):_0xe377('0x19'));return _0x1df703(_0x180029);})[_0xe377('0xc')](function(_0x49a2ca){logger[_0xe377('0x8')](_0xe377('0x1a'),_0x49a2ca?util['inspect'](_0x49a2ca,{'showHidden':![],'depth':null}):'');return _0x1df703(null);});}return _0x1df703(null);});};exports[_0xe377('0x1b')]=function(_0x8e494){return new BPromise(function(_0x1df952,_0x297f4f){if(_0x8e494){return getUser({'name':_0x8e494})['then'](function(_0x3df3cc){logger[_0xe377('0x1c')](_0xe377('0x1d'),_0x8e494,_0x3df3cc?_0xe377('0x15'):_0xe377('0x19'));return _0x1df952(_0x3df3cc);})['catch'](function(_0x1b2edc){logger[_0xe377('0x8')](_0xe377('0x1e'),_0x1b2edc?util[_0xe377('0x6')](_0x1b2edc,{'showHidden':![],'depth':null}):'');return _0x1df952(null);});}return _0x1df952(null);});};exports[_0xe377('0x1f')]=function(_0x8f4082){return new BPromise(function(_0x5ccc5a,_0x149807){if(_0x8f4082){return client[_0xe377('0x9')](_0xe377('0x20'),{'options':{'raw':!![],'attributes':['id',_0xe377('0xf'),_0xe377('0x21'),_0xe377('0x22'),_0xe377('0x23')],'where':{'name':_0x8f4082},'limit':0x1}})['then'](function(_0x39dc0b){logger[_0xe377('0x7')](_0xe377('0x24'),_0x8f4082,_0x39dc0b?util[_0xe377('0x6')](_0x39dc0b,{'showHidden':![],'depth':null}):'');logger[_0xe377('0x1c')](_0xe377('0x25'),_0x8f4082,_0x39dc0b?'found':_0xe377('0x19'));return _0x5ccc5a(_0x39dc0b[_0xe377('0x12')][_0xe377('0x13')]?_0x39dc0b[_0xe377('0x12')][0x0]:null);})[_0xe377('0xc')](function(_0x1bbcc1){logger['error'](_0xe377('0x26'),_0x1bbcc1?util[_0xe377('0x6')](_0x1bbcc1,{'showHidden':![],'depth':null}):'');return _0x5ccc5a(null);});}return _0x5ccc5a(null);});};exports[_0xe377('0x27')]=function(_0x1403cf,_0x279b75){return moment(_0x1403cf)[_0xe377('0x28')](_0x279b75,_0xe377('0x29'))['format'](_0xe377('0x2a'));};exports['subtractTime']=function(_0x107eef,_0x5c27d6){return moment(_0x107eef)[_0xe377('0x2b')](_0x5c27d6,'seconds')[_0xe377('0x2c')](_0xe377('0x2a'));};exports['diffTime']=function(_0x3b1c55,_0x510a7a){return moment(_0x3b1c55)[_0xe377('0x2d')](moment(_0x510a7a),'seconds');};exports['sumTime']=function(_0x19e4da,_0x3697a9){return parseInt(_0x19e4da,0xa)+parseInt(_0x3697a9,0xa);};exports['now']=function(){return moment()['format'](_0xe377('0x2a'));};exports[_0xe377('0x2e')]=function(_0x3c507b,_0x5bd88e){if(_0x5bd88e){return moment(_0x3c507b)[_0xe377('0x2e')](_0x5bd88e);}return!![];};exports['isBefore']=function(_0x119799,_0x11189f){if(_0x11189f){return moment(_0x119799)[_0xe377('0x2f')](_0x11189f);}else if(_0x119799){return!![];}return![];};
\ No newline at end of file