Built motion from commit 25580385.|2.6.2
[motion2.git] / server / services / xdr / utils.js
index 11e7226..69e4b37 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2a07=['GetVoiceQueue','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','diffTime','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','../../config/logger','xdr','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','name','interface','[utils][getUser]\x20where:%s','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','getUserByName','[utils][getUserByName]\x20name:%s\x20%s','[utils][getUserByName]','getVoiceQueueByName'];(function(_0x2e2e41,_0x3a7848){var _0x266226=function(_0x458e0a){while(--_0x458e0a){_0x2e2e41['push'](_0x2e2e41['shift']());}};_0x266226(++_0x3a7848);}(_0x2a07,0x74));var _0x72a0=function(_0x26a44e,_0x18c43f){_0x26a44e=_0x26a44e-0x0;var _0x566fc4=_0x2a07[_0x26a44e];return _0x566fc4;};'use strict';var BPromise=require(_0x72a0('0x0'));var jayson=require(_0x72a0('0x1'));var moment=require(_0x72a0('0x2'));var util=require(_0x72a0('0x3'));var client=jayson[_0x72a0('0x4')]['http']({'port':0x2329});var logger=require(_0x72a0('0x5'))(_0x72a0('0x6'));exports[_0x72a0('0x7')]=function(_0x45b155,_0x431f65){logger[_0x72a0('0x7')](_0x45b155,_0x431f65?util[_0x72a0('0x8')](_0x431f65,{'showHidden':![],'depth':null}):'');};exports[_0x72a0('0x9')]=function(_0x193e3b,_0x287b06){logger[_0x72a0('0x9')](_0x193e3b,_0x287b06?util[_0x72a0('0x8')](_0x287b06,{'showHidden':![],'depth':null}):'');};exports[_0x72a0('0xa')]=function(_0x1d32e9,_0x55b3e9){logger[_0x72a0('0xa')](_0x1d32e9,_0x55b3e9?util['inspect'](_0x55b3e9,{'showHidden':![],'depth':null}):'');};exports[_0x72a0('0xb')]=function(_0x1109f7,_0x54abf6){return client[_0x72a0('0xb')](_0x1109f7,{'body':_0x54abf6})[_0x72a0('0xc')](function(_0x1b85b1){logger[_0x72a0('0x9')](_0x72a0('0xd'),_0x1109f7,_0x1b85b1?util['inspect'](_0x1b85b1,{'showHidden':![],'depth':null}):'');})[_0x72a0('0xe')](function(_0x335b9f){logger[_0x72a0('0xa')](_0x72a0('0xd'),_0x1109f7,_0x335b9f?util[_0x72a0('0x8')](_0x335b9f,{'showHidden':![],'depth':null}):'');});};function getUser(_0x324cbd){return client[_0x72a0('0xb')]('GetUser',{'options':{'raw':!![],'attributes':['id','internal',_0x72a0('0xf'),_0x72a0('0x10')],'where':_0x324cbd,'limit':0x1}})[_0x72a0('0xc')](function(_0x1d1133){logger[_0x72a0('0x9')](_0x72a0('0x11'),JSON['stringify'](_0x324cbd),_0x1d1133?util[_0x72a0('0x8')](_0x1d1133,{'showHidden':![],'depth':null}):'');return _0x1d1133[_0x72a0('0x12')][_0x72a0('0x13')]?_0x1d1133[_0x72a0('0x12')][0x0]:null;});}exports[_0x72a0('0x14')]=function(_0x54495e){return new BPromise(function(_0x100d8f,_0x42e9ec){if(_0x54495e){return getUser({'internal':_0x54495e})[_0x72a0('0xc')](function(_0x5b63c8){logger[_0x72a0('0x7')](_0x72a0('0x15'),_0x54495e,_0x5b63c8?_0x72a0('0x16'):_0x72a0('0x17'));return _0x100d8f(_0x5b63c8);})['catch'](function(_0x3bc78b){logger['error'](_0x72a0('0x18'),_0x3bc78b?util[_0x72a0('0x8')](_0x3bc78b,{'showHidden':![],'depth':null}):'');return _0x100d8f(null);});}return _0x100d8f(null);});};exports[_0x72a0('0x19')]=function(_0x5c7479){return new BPromise(function(_0x35da77,_0x1849d1){if(_0x5c7479){return getUser({'interface':_0x5c7479})[_0x72a0('0xc')](function(_0x3d1965){logger['info'](_0x72a0('0x1a'),_0x5c7479,_0x3d1965?_0x72a0('0x16'):_0x72a0('0x17'));return _0x35da77(_0x3d1965);})[_0x72a0('0xe')](function(_0x3022b0){logger[_0x72a0('0xa')]('[utils][getUserByInterface]',_0x3022b0?util['inspect'](_0x3022b0,{'showHidden':![],'depth':null}):'');return _0x35da77(null);});}return _0x35da77(null);});};exports[_0x72a0('0x1b')]=function(_0x2d8b68){return new BPromise(function(_0x123df4,_0x1504ed){if(_0x2d8b68){return getUser({'name':_0x2d8b68})[_0x72a0('0xc')](function(_0x27ca5a){logger[_0x72a0('0x7')](_0x72a0('0x1c'),_0x2d8b68,_0x27ca5a?_0x72a0('0x16'):_0x72a0('0x17'));return _0x123df4(_0x27ca5a);})['catch'](function(_0x304b92){logger[_0x72a0('0xa')](_0x72a0('0x1d'),_0x304b92?util[_0x72a0('0x8')](_0x304b92,{'showHidden':![],'depth':null}):'');return _0x123df4(null);});}return _0x123df4(null);});};exports[_0x72a0('0x1e')]=function(_0x177a3a){return new BPromise(function(_0x432179,_0x12eda2){if(_0x177a3a){return client[_0x72a0('0xb')](_0x72a0('0x1f'),{'options':{'raw':!![],'attributes':['id','name',_0x72a0('0x20'),_0x72a0('0x21'),_0x72a0('0x22')],'where':{'name':_0x177a3a},'limit':0x1}})[_0x72a0('0xc')](function(_0x13c04){logger[_0x72a0('0x9')](_0x72a0('0x23'),_0x177a3a,_0x13c04?util['inspect'](_0x13c04,{'showHidden':![],'depth':null}):'');logger[_0x72a0('0x7')](_0x72a0('0x24'),_0x177a3a,_0x13c04?_0x72a0('0x16'):_0x72a0('0x17'));return _0x432179(_0x13c04[_0x72a0('0x12')][_0x72a0('0x13')]?_0x13c04[_0x72a0('0x12')][0x0]:null);})[_0x72a0('0xe')](function(_0x5e93f8){logger[_0x72a0('0xa')](_0x72a0('0x25'),_0x5e93f8?util[_0x72a0('0x8')](_0x5e93f8,{'showHidden':![],'depth':null}):'');return _0x432179(null);});}return _0x432179(null);});};exports['addTime']=function(_0x2ae61c,_0x4ada83){return moment(_0x2ae61c)[_0x72a0('0x26')](_0x4ada83,_0x72a0('0x27'))[_0x72a0('0x28')](_0x72a0('0x29'));};exports[_0x72a0('0x2a')]=function(_0xbcb2a4,_0x20f023){return moment(_0xbcb2a4)[_0x72a0('0x2b')](_0x20f023,_0x72a0('0x27'))[_0x72a0('0x28')](_0x72a0('0x29'));};exports[_0x72a0('0x2c')]=function(_0x5b6326,_0x265d96){return moment(_0x5b6326)['diff'](moment(_0x265d96),_0x72a0('0x27'));};exports[_0x72a0('0x2d')]=function(_0x446222,_0x1a9597){return parseInt(_0x446222,0xa)+parseInt(_0x1a9597,0xa);};exports[_0x72a0('0x2e')]=function(){return moment()[_0x72a0('0x28')](_0x72a0('0x29'));};exports[_0x72a0('0x2f')]=function(_0xe2687c,_0x4c1f43){if(_0x4c1f43){return moment(_0xe2687c)['isAfter'](_0x4c1f43);}return!![];};exports[_0x72a0('0x30')]=function(_0x1d9403,_0x332051){if(_0x332051){return moment(_0x1d9403)[_0x72a0('0x30')](_0x332051);}else if(_0x1d9403){return!![];}return![];};
\ No newline at end of file
+var _0x19d1=['client','xdr','info','inspect','debug','error','request','then','catch','GetUser','internal','name','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]\x20name:%s\x20%s','getVoiceQueueByName','GetVoiceQueue','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','add','seconds','format','subtractTime','subtract','YYYY-MM-DD\x20HH:mm:ss','diffTime','sumTime','isAfter','isBefore','jayson/promise'];(function(_0x24d726,_0x4c5428){var _0x41965d=function(_0x20481a){while(--_0x20481a){_0x24d726['push'](_0x24d726['shift']());}};_0x41965d(++_0x4c5428);}(_0x19d1,0xd6));var _0x119d=function(_0x1a96bb,_0x25bd16){_0x1a96bb=_0x1a96bb-0x0;var _0x59206a=_0x19d1[_0x1a96bb];return _0x59206a;};'use strict';var BPromise=require('bluebird');var jayson=require(_0x119d('0x0'));var moment=require('moment');var util=require('util');var client=jayson[_0x119d('0x1')]['http']({'port':0x2329});var logger=require('../../config/logger')(_0x119d('0x2'));exports[_0x119d('0x3')]=function(_0x5e9cfc,_0x52ce16){logger['info'](_0x5e9cfc,_0x52ce16?util[_0x119d('0x4')](_0x52ce16,{'showHidden':![],'depth':null}):'');};exports[_0x119d('0x5')]=function(_0x3df733,_0x34127c){logger[_0x119d('0x5')](_0x3df733,_0x34127c?util[_0x119d('0x4')](_0x34127c,{'showHidden':![],'depth':null}):'');};exports[_0x119d('0x6')]=function(_0x56a310,_0x364a87){logger[_0x119d('0x6')](_0x56a310,_0x364a87?util[_0x119d('0x4')](_0x364a87,{'showHidden':![],'depth':null}):'');};exports[_0x119d('0x7')]=function(_0x5548df,_0x5f24c7){return client[_0x119d('0x7')](_0x5548df,{'body':_0x5f24c7})[_0x119d('0x8')](function(_0x131a18){logger[_0x119d('0x5')]('[utils][request]\x20name:%s',_0x5548df,_0x131a18?util[_0x119d('0x4')](_0x131a18,{'showHidden':![],'depth':null}):'');})[_0x119d('0x9')](function(_0x44e281){logger['error']('[utils][request]\x20name:%s',_0x5548df,_0x44e281?util[_0x119d('0x4')](_0x44e281,{'showHidden':![],'depth':null}):'');});};function getUser(_0x42cdef){return client[_0x119d('0x7')](_0x119d('0xa'),{'options':{'raw':!![],'attributes':['id',_0x119d('0xb'),_0x119d('0xc'),'interface'],'where':_0x42cdef,'limit':0x1}})[_0x119d('0x8')](function(_0x5022c2){logger['debug'](_0x119d('0xd'),JSON[_0x119d('0xe')](_0x42cdef),_0x5022c2?util[_0x119d('0x4')](_0x5022c2,{'showHidden':![],'depth':null}):'');return _0x5022c2[_0x119d('0xf')][_0x119d('0x10')]?_0x5022c2[_0x119d('0xf')][0x0]:null;});}exports[_0x119d('0x11')]=function(_0x5ed1a6){return new BPromise(function(_0x465cb2,_0x544784){if(_0x5ed1a6){return getUser({'internal':_0x5ed1a6})[_0x119d('0x8')](function(_0x5896c1){logger[_0x119d('0x3')](_0x119d('0x12'),_0x5ed1a6,_0x5896c1?_0x119d('0x13'):_0x119d('0x14'));return _0x465cb2(_0x5896c1);})[_0x119d('0x9')](function(_0x509635){logger['error'](_0x119d('0x15'),_0x509635?util[_0x119d('0x4')](_0x509635,{'showHidden':![],'depth':null}):'');return _0x465cb2(null);});}return _0x465cb2(null);});};exports[_0x119d('0x16')]=function(_0x5020bf){return new BPromise(function(_0x27db0a,_0x25db82){if(_0x5020bf){return getUser({'interface':_0x5020bf})[_0x119d('0x8')](function(_0x58245b){logger['info'](_0x119d('0x17'),_0x5020bf,_0x58245b?_0x119d('0x13'):'notfound');return _0x27db0a(_0x58245b);})[_0x119d('0x9')](function(_0x5e07aa){logger[_0x119d('0x6')](_0x119d('0x18'),_0x5e07aa?util[_0x119d('0x4')](_0x5e07aa,{'showHidden':![],'depth':null}):'');return _0x27db0a(null);});}return _0x27db0a(null);});};exports[_0x119d('0x19')]=function(_0x1a04e4){return new BPromise(function(_0x4fd794,_0x28a56e){if(_0x1a04e4){return getUser({'name':_0x1a04e4})[_0x119d('0x8')](function(_0x38ba40){logger[_0x119d('0x3')](_0x119d('0x1a'),_0x1a04e4,_0x38ba40?_0x119d('0x13'):_0x119d('0x14'));return _0x4fd794(_0x38ba40);})['catch'](function(_0x11bcb2){logger[_0x119d('0x6')]('[utils][getUserByName]',_0x11bcb2?util[_0x119d('0x4')](_0x11bcb2,{'showHidden':![],'depth':null}):'');return _0x4fd794(null);});}return _0x4fd794(null);});};exports[_0x119d('0x1b')]=function(_0xbf08bc){return new BPromise(function(_0x569358,_0x573d50){if(_0xbf08bc){return client[_0x119d('0x7')](_0x119d('0x1c'),{'options':{'raw':!![],'attributes':['id',_0x119d('0xc'),'type',_0x119d('0x1d'),_0x119d('0x1e')],'where':{'name':_0xbf08bc},'limit':0x1}})[_0x119d('0x8')](function(_0x29cab8){logger[_0x119d('0x5')]('[utils][getVoiceQueueByName]\x20name:%s',_0xbf08bc,_0x29cab8?util[_0x119d('0x4')](_0x29cab8,{'showHidden':![],'depth':null}):'');logger['info'](_0x119d('0x1f'),_0xbf08bc,_0x29cab8?'found':_0x119d('0x14'));return _0x569358(_0x29cab8[_0x119d('0xf')][_0x119d('0x10')]?_0x29cab8[_0x119d('0xf')][0x0]:null);})[_0x119d('0x9')](function(_0x3991fe){logger[_0x119d('0x6')](_0x119d('0x20'),_0x3991fe?util[_0x119d('0x4')](_0x3991fe,{'showHidden':![],'depth':null}):'');return _0x569358(null);});}return _0x569358(null);});};exports['addTime']=function(_0x32fd6b,_0x2a85c6){return moment(_0x32fd6b)[_0x119d('0x21')](_0x2a85c6,_0x119d('0x22'))[_0x119d('0x23')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x119d('0x24')]=function(_0xb2421e,_0xc49ec3){return moment(_0xb2421e)[_0x119d('0x25')](_0xc49ec3,_0x119d('0x22'))[_0x119d('0x23')](_0x119d('0x26'));};exports[_0x119d('0x27')]=function(_0x1e062e,_0x5da885){return moment(_0x1e062e)['diff'](moment(_0x5da885),_0x119d('0x22'));};exports[_0x119d('0x28')]=function(_0x59ebc8,_0x41b16a){return parseInt(_0x59ebc8,0xa)+parseInt(_0x41b16a,0xa);};exports['now']=function(){return moment()[_0x119d('0x23')](_0x119d('0x26'));};exports['isAfter']=function(_0x944ac2,_0x208722){if(_0x208722){return moment(_0x944ac2)[_0x119d('0x29')](_0x208722);}return!![];};exports[_0x119d('0x2a')]=function(_0xb782d0,_0x1ea82c){if(_0x1ea82c){return moment(_0xb782d0)[_0x119d('0x2a')](_0x1ea82c);}else if(_0xb782d0){return!![];}return![];};
\ No newline at end of file