Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / services / xdr / utils.js
index 69e4b37..b53857e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x0f25=['diffTime','isAfter','isBefore','bluebird','jayson/promise','util','client','http','../../config/logger','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','GetUser','name','interface','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','[utils][getUserByInternal]','[utils][getUserByInterface]\x20interface:%s\x20%s','notfound','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]','type','acw','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]','addTime','add','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','format'];(function(_0x4005fe,_0x1fc3c1){var _0x50022d=function(_0x2ce718){while(--_0x2ce718){_0x4005fe['push'](_0x4005fe['shift']());}};_0x50022d(++_0x1fc3c1);}(_0x0f25,0xdf));var _0x50f2=function(_0x47579b,_0x4ea44e){_0x47579b=_0x47579b-0x0;var _0x4e47f5=_0x0f25[_0x47579b];return _0x4e47f5;};'use strict';var BPromise=require(_0x50f2('0x0'));var jayson=require(_0x50f2('0x1'));var moment=require('moment');var util=require(_0x50f2('0x2'));var client=jayson[_0x50f2('0x3')][_0x50f2('0x4')]({'port':0x2329});var logger=require(_0x50f2('0x5'))('xdr');exports['info']=function(_0x19e72e,_0x101e24){logger[_0x50f2('0x6')](_0x19e72e,_0x101e24?util[_0x50f2('0x7')](_0x101e24,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0x8')]=function(_0x379d0b,_0x19e3ce){logger[_0x50f2('0x8')](_0x379d0b,_0x19e3ce?util[_0x50f2('0x7')](_0x19e3ce,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0x9')]=function(_0x519b84,_0x58ce92){logger[_0x50f2('0x9')](_0x519b84,_0x58ce92?util[_0x50f2('0x7')](_0x58ce92,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0xa')]=function(_0x134bb4,_0xaca1fd){return client[_0x50f2('0xa')](_0x134bb4,{'body':_0xaca1fd})[_0x50f2('0xb')](function(_0x31cb73){logger[_0x50f2('0x8')](_0x50f2('0xc'),_0x134bb4,_0x31cb73?util[_0x50f2('0x7')](_0x31cb73,{'showHidden':![],'depth':null}):'');})[_0x50f2('0xd')](function(_0x2c513f){logger[_0x50f2('0x9')](_0x50f2('0xc'),_0x134bb4,_0x2c513f?util['inspect'](_0x2c513f,{'showHidden':![],'depth':null}):'');});};function getUser(_0x437fb7){return client[_0x50f2('0xa')](_0x50f2('0xe'),{'options':{'raw':!![],'attributes':['id','internal',_0x50f2('0xf'),_0x50f2('0x10')],'where':_0x437fb7,'limit':0x1}})['then'](function(_0x5c6c2b){logger['debug'](_0x50f2('0x11'),JSON[_0x50f2('0x12')](_0x437fb7),_0x5c6c2b?util[_0x50f2('0x7')](_0x5c6c2b,{'showHidden':![],'depth':null}):'');return _0x5c6c2b[_0x50f2('0x13')][_0x50f2('0x14')]?_0x5c6c2b[_0x50f2('0x13')][0x0]:null;});}exports[_0x50f2('0x15')]=function(_0xedbb5a){return new BPromise(function(_0x3caca9,_0x36a5f7){if(_0xedbb5a){return getUser({'internal':_0xedbb5a})['then'](function(_0x173ce6){logger[_0x50f2('0x6')](_0x50f2('0x16'),_0xedbb5a,_0x173ce6?_0x50f2('0x17'):'notfound');return _0x3caca9(_0x173ce6);})[_0x50f2('0xd')](function(_0x1779cb){logger['error'](_0x50f2('0x18'),_0x1779cb?util[_0x50f2('0x7')](_0x1779cb,{'showHidden':![],'depth':null}):'');return _0x3caca9(null);});}return _0x3caca9(null);});};exports['getUserByInterface']=function(_0x4b6eda){return new BPromise(function(_0x2592bd,_0x234703){if(_0x4b6eda){return getUser({'interface':_0x4b6eda})[_0x50f2('0xb')](function(_0x54a53d){logger['info'](_0x50f2('0x19'),_0x4b6eda,_0x54a53d?_0x50f2('0x17'):_0x50f2('0x1a'));return _0x2592bd(_0x54a53d);})['catch'](function(_0x5523bd){logger[_0x50f2('0x9')](_0x50f2('0x1b'),_0x5523bd?util[_0x50f2('0x7')](_0x5523bd,{'showHidden':![],'depth':null}):'');return _0x2592bd(null);});}return _0x2592bd(null);});};exports[_0x50f2('0x1c')]=function(_0x549f7f){return new BPromise(function(_0x4a4577,_0x4b26ad){if(_0x549f7f){return getUser({'name':_0x549f7f})[_0x50f2('0xb')](function(_0x13da77){logger[_0x50f2('0x6')]('[utils][getUserByName]\x20name:%s\x20%s',_0x549f7f,_0x13da77?'found':_0x50f2('0x1a'));return _0x4a4577(_0x13da77);})[_0x50f2('0xd')](function(_0x29ce54){logger[_0x50f2('0x9')](_0x50f2('0x1d'),_0x29ce54?util['inspect'](_0x29ce54,{'showHidden':![],'depth':null}):'');return _0x4a4577(null);});}return _0x4a4577(null);});};exports['getVoiceQueueByName']=function(_0xbb398c){return new BPromise(function(_0x5c6703,_0x24df1f){if(_0xbb398c){return client[_0x50f2('0xa')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0x50f2('0xf'),_0x50f2('0x1e'),_0x50f2('0x1f'),'acwTimeout'],'where':{'name':_0xbb398c},'limit':0x1}})[_0x50f2('0xb')](function(_0x55cf78){logger[_0x50f2('0x8')](_0x50f2('0x20'),_0xbb398c,_0x55cf78?util[_0x50f2('0x7')](_0x55cf78,{'showHidden':![],'depth':null}):'');logger[_0x50f2('0x6')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0xbb398c,_0x55cf78?_0x50f2('0x17'):_0x50f2('0x1a'));return _0x5c6703(_0x55cf78[_0x50f2('0x13')]['length']?_0x55cf78[_0x50f2('0x13')][0x0]:null);})[_0x50f2('0xd')](function(_0x4ba4c2){logger[_0x50f2('0x9')](_0x50f2('0x21'),_0x4ba4c2?util[_0x50f2('0x7')](_0x4ba4c2,{'showHidden':![],'depth':null}):'');return _0x5c6703(null);});}return _0x5c6703(null);});};exports[_0x50f2('0x22')]=function(_0x320807,_0x2e7e7e){return moment(_0x320807)[_0x50f2('0x23')](_0x2e7e7e,_0x50f2('0x24'))['format'](_0x50f2('0x25'));};exports[_0x50f2('0x26')]=function(_0x2801eb,_0xde6926){return moment(_0x2801eb)[_0x50f2('0x27')](_0xde6926,'seconds')[_0x50f2('0x28')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x50f2('0x29')]=function(_0x253d6b,_0x2dd13a){return moment(_0x253d6b)['diff'](moment(_0x2dd13a),_0x50f2('0x24'));};exports['sumTime']=function(_0x51b501,_0x5ed302){return parseInt(_0x51b501,0xa)+parseInt(_0x5ed302,0xa);};exports['now']=function(){return moment()[_0x50f2('0x28')](_0x50f2('0x25'));};exports[_0x50f2('0x2a')]=function(_0x31b6ff,_0x4b8eb4){if(_0x4b8eb4){return moment(_0x31b6ff)['isAfter'](_0x4b8eb4);}return!![];};exports[_0x50f2('0x2b')]=function(_0x200004,_0x31bd7a){if(_0x31bd7a){return moment(_0x200004)['isBefore'](_0x31bd7a);}else if(_0x200004){return!![];}return![];};
\ No newline at end of file