Built motion from commit a679711e.|2.6.15
[motion2.git] / server / services / xdr / utils.js
index d40553c..b895288 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdf74=['type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','addTime','format','YYYY-MM-DD\x20HH:mm:ss','subtract','seconds','diffTime','diff','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','util','client','http','../../config/logger','xdr','info','inspect','debug','request','then','[utils][request]\x20name:%s','GetUser','internal','name','interface','[utils][getUser]\x20where:%s','stringify','result','length','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','catch','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]\x20name:%s\x20%s','error','[utils][getUserByName]','getVoiceQueueByName'];(function(_0x514bd1,_0x25ea3e){var _0x58a281=function(_0x25567a){while(--_0x25567a){_0x514bd1['push'](_0x514bd1['shift']());}};_0x58a281(++_0x25ea3e);}(_0xdf74,0x197));var _0x4df7=function(_0x545090,_0x5eaac6){_0x545090=_0x545090-0x0;var _0x1d5326=_0xdf74[_0x545090];return _0x1d5326;};'use strict';var BPromise=require(_0x4df7('0x0'));var jayson=require(_0x4df7('0x1'));var moment=require('moment');var util=require(_0x4df7('0x2'));var client=jayson[_0x4df7('0x3')][_0x4df7('0x4')]({'port':0x2329});var logger=require(_0x4df7('0x5'))(_0x4df7('0x6'));exports[_0x4df7('0x7')]=function(_0x26e85f,_0x58bd49){logger[_0x4df7('0x7')](_0x26e85f,_0x58bd49?util[_0x4df7('0x8')](_0x58bd49,{'showHidden':![],'depth':null}):'');};exports[_0x4df7('0x9')]=function(_0x365037,_0x4c2142){logger[_0x4df7('0x9')](_0x365037,_0x4c2142?util[_0x4df7('0x8')](_0x4c2142,{'showHidden':![],'depth':null}):'');};exports['error']=function(_0x187fba,_0x429973){logger['error'](_0x187fba,_0x429973?util[_0x4df7('0x8')](_0x429973,{'showHidden':![],'depth':null}):'');};exports['request']=function(_0x337220,_0x15f8b4){return client[_0x4df7('0xa')](_0x337220,{'body':_0x15f8b4})[_0x4df7('0xb')](function(_0x581357){logger['debug'](_0x4df7('0xc'),_0x337220,_0x581357?util[_0x4df7('0x8')](_0x581357,{'showHidden':![],'depth':null}):'');})['catch'](function(_0x4a9643){logger['error'](_0x4df7('0xc'),_0x337220,_0x4a9643?util[_0x4df7('0x8')](_0x4a9643,{'showHidden':![],'depth':null}):'');});};function getUser(_0x1ebbb4){return client[_0x4df7('0xa')](_0x4df7('0xd'),{'options':{'raw':!![],'attributes':['id',_0x4df7('0xe'),_0x4df7('0xf'),_0x4df7('0x10')],'where':_0x1ebbb4,'limit':0x1}})[_0x4df7('0xb')](function(_0x4fda56){logger[_0x4df7('0x9')](_0x4df7('0x11'),JSON[_0x4df7('0x12')](_0x1ebbb4),_0x4fda56?util['inspect'](_0x4fda56,{'showHidden':![],'depth':null}):'');return _0x4fda56[_0x4df7('0x13')][_0x4df7('0x14')]?_0x4fda56['result'][0x0]:null;});}exports['getUserByInternal']=function(_0x12cb59){return new BPromise(function(_0x529db9,_0x54f6c8){if(_0x12cb59){return getUser({'internal':_0x12cb59})[_0x4df7('0xb')](function(_0x3a050f){logger[_0x4df7('0x7')](_0x4df7('0x15'),_0x12cb59,_0x3a050f?_0x4df7('0x16'):_0x4df7('0x17'));return _0x529db9(_0x3a050f);})['catch'](function(_0x24740a){logger['error'](_0x4df7('0x18'),_0x24740a?util[_0x4df7('0x8')](_0x24740a,{'showHidden':![],'depth':null}):'');return _0x529db9(null);});}return _0x529db9(null);});};exports[_0x4df7('0x19')]=function(_0x2e8db6){return new BPromise(function(_0x4bdb4d,_0x21df52){if(_0x2e8db6){return getUser({'interface':_0x2e8db6})[_0x4df7('0xb')](function(_0x3c4051){logger[_0x4df7('0x7')](_0x4df7('0x1a'),_0x2e8db6,_0x3c4051?_0x4df7('0x16'):'notfound');return _0x4bdb4d(_0x3c4051);})[_0x4df7('0x1b')](function(_0x5ce457){logger['error'](_0x4df7('0x1c'),_0x5ce457?util[_0x4df7('0x8')](_0x5ce457,{'showHidden':![],'depth':null}):'');return _0x4bdb4d(null);});}return _0x4bdb4d(null);});};exports[_0x4df7('0x1d')]=function(_0x3d3284){return new BPromise(function(_0x43d4b4,_0x34bd36){if(_0x3d3284){return getUser({'name':_0x3d3284})[_0x4df7('0xb')](function(_0x4cdf6e){logger['info'](_0x4df7('0x1e'),_0x3d3284,_0x4cdf6e?'found':_0x4df7('0x17'));return _0x43d4b4(_0x4cdf6e);})['catch'](function(_0x343e73){logger[_0x4df7('0x1f')](_0x4df7('0x20'),_0x343e73?util[_0x4df7('0x8')](_0x343e73,{'showHidden':![],'depth':null}):'');return _0x43d4b4(null);});}return _0x43d4b4(null);});};exports[_0x4df7('0x21')]=function(_0xa58366){return new BPromise(function(_0x29d555,_0x5e7155){if(_0xa58366){return client[_0x4df7('0xa')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id','name',_0x4df7('0x22'),_0x4df7('0x23'),_0x4df7('0x24')],'where':{'name':_0xa58366},'limit':0x1}})[_0x4df7('0xb')](function(_0x216f18){logger['debug'](_0x4df7('0x25'),_0xa58366,_0x216f18?util[_0x4df7('0x8')](_0x216f18,{'showHidden':![],'depth':null}):'');logger['info']('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0xa58366,_0x216f18?'found':_0x4df7('0x17'));return _0x29d555(_0x216f18['result'][_0x4df7('0x14')]?_0x216f18[_0x4df7('0x13')][0x0]:null);})[_0x4df7('0x1b')](function(_0x2bfd29){logger[_0x4df7('0x1f')]('[utils][getVoiceQueueByName]',_0x2bfd29?util[_0x4df7('0x8')](_0x2bfd29,{'showHidden':![],'depth':null}):'');return _0x29d555(null);});}return _0x29d555(null);});};exports[_0x4df7('0x26')]=function(_0x326bde,_0x144502){return moment(_0x326bde)['add'](_0x144502,'seconds')[_0x4df7('0x27')](_0x4df7('0x28'));};exports['subtractTime']=function(_0x372b4a,_0x3da26f){return moment(_0x372b4a)[_0x4df7('0x29')](_0x3da26f,_0x4df7('0x2a'))[_0x4df7('0x27')](_0x4df7('0x28'));};exports[_0x4df7('0x2b')]=function(_0x27cfa2,_0x41a80a){return moment(_0x27cfa2)[_0x4df7('0x2c')](moment(_0x41a80a),_0x4df7('0x2a'));};exports[_0x4df7('0x2d')]=function(_0x55e983,_0x1e9a9b){return parseInt(_0x55e983,0xa)+parseInt(_0x1e9a9b,0xa);};exports[_0x4df7('0x2e')]=function(){return moment()[_0x4df7('0x27')]('YYYY-MM-DD\x20HH:mm:ss');};exports['isAfter']=function(_0x740a4d,_0xd5d271){if(_0xd5d271){return moment(_0x740a4d)[_0x4df7('0x2f')](_0xd5d271);}return!![];};exports['isBefore']=function(_0x5c6132,_0x36a94a){if(_0x36a94a){return moment(_0x5c6132)[_0x4df7('0x30')](_0x36a94a);}else if(_0x5c6132){return!![];}return![];};
\ No newline at end of file
+var _0x867e=['GetVoiceQueue','type','acw','[utils][getVoiceQueueByName]','add','seconds','YYYY-MM-DD\x20HH:mm:ss','subtract','format','diff','now','isAfter','isBefore','bluebird','jayson/promise','moment','client','../../config/logger','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','internal','name','[utils][getUser]\x20where:%s','length','result','getUserByInternal','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]'];(function(_0x2a538a,_0x2c5c72){var _0x3dbe25=function(_0x27b5de){while(--_0x27b5de){_0x2a538a['push'](_0x2a538a['shift']());}};_0x3dbe25(++_0x2c5c72);}(_0x867e,0x1c5));var _0xe867=function(_0xcffe4,_0x772be4){_0xcffe4=_0xcffe4-0x0;var _0x3ab98c=_0x867e[_0xcffe4];return _0x3ab98c;};'use strict';var BPromise=require(_0xe867('0x0'));var jayson=require(_0xe867('0x1'));var moment=require(_0xe867('0x2'));var util=require('util');var client=jayson[_0xe867('0x3')]['http']({'port':0x2329});var logger=require(_0xe867('0x4'))('xdr');exports[_0xe867('0x5')]=function(_0xa59225,_0x36a967){logger[_0xe867('0x5')](_0xa59225,_0x36a967?util[_0xe867('0x6')](_0x36a967,{'showHidden':![],'depth':null}):'');};exports[_0xe867('0x7')]=function(_0x20609b,_0x395784){logger[_0xe867('0x7')](_0x20609b,_0x395784?util[_0xe867('0x6')](_0x395784,{'showHidden':![],'depth':null}):'');};exports[_0xe867('0x8')]=function(_0x3a852b,_0x2b0ff4){logger['error'](_0x3a852b,_0x2b0ff4?util['inspect'](_0x2b0ff4,{'showHidden':![],'depth':null}):'');};exports['request']=function(_0x166941,_0x1a8da8){return client[_0xe867('0x9')](_0x166941,{'body':_0x1a8da8})[_0xe867('0xa')](function(_0x2846fd){logger[_0xe867('0x7')](_0xe867('0xb'),_0x166941,_0x2846fd?util[_0xe867('0x6')](_0x2846fd,{'showHidden':![],'depth':null}):'');})[_0xe867('0xc')](function(_0x7d193){logger[_0xe867('0x8')](_0xe867('0xb'),_0x166941,_0x7d193?util[_0xe867('0x6')](_0x7d193,{'showHidden':![],'depth':null}):'');});};function getUser(_0x208254){return client['request']('GetUser',{'options':{'raw':!![],'attributes':['id',_0xe867('0xd'),_0xe867('0xe'),'interface'],'where':_0x208254,'limit':0x1}})[_0xe867('0xa')](function(_0x92abf0){logger['debug'](_0xe867('0xf'),JSON['stringify'](_0x208254),_0x92abf0?util[_0xe867('0x6')](_0x92abf0,{'showHidden':![],'depth':null}):'');return _0x92abf0['result'][_0xe867('0x10')]?_0x92abf0[_0xe867('0x11')][0x0]:null;});}exports[_0xe867('0x12')]=function(_0x329763){return new BPromise(function(_0x455aae,_0x4c624d){if(_0x329763){return getUser({'internal':_0x329763})['then'](function(_0x594580){logger[_0xe867('0x5')]('[utils][getUserByInternal]\x20internal:%s\x20%s',_0x329763,_0x594580?_0xe867('0x13'):_0xe867('0x14'));return _0x455aae(_0x594580);})[_0xe867('0xc')](function(_0x21a471){logger[_0xe867('0x8')](_0xe867('0x15'),_0x21a471?util[_0xe867('0x6')](_0x21a471,{'showHidden':![],'depth':null}):'');return _0x455aae(null);});}return _0x455aae(null);});};exports[_0xe867('0x16')]=function(_0x5aeda6){return new BPromise(function(_0xecbca9,_0x594e0d){if(_0x5aeda6){return getUser({'interface':_0x5aeda6})['then'](function(_0x138dec){logger[_0xe867('0x5')](_0xe867('0x17'),_0x5aeda6,_0x138dec?'found':'notfound');return _0xecbca9(_0x138dec);})['catch'](function(_0x226e92){logger[_0xe867('0x8')](_0xe867('0x18'),_0x226e92?util[_0xe867('0x6')](_0x226e92,{'showHidden':![],'depth':null}):'');return _0xecbca9(null);});}return _0xecbca9(null);});};exports[_0xe867('0x19')]=function(_0xecad84){return new BPromise(function(_0x583c39,_0x21cd0a){if(_0xecad84){return getUser({'name':_0xecad84})[_0xe867('0xa')](function(_0x3c1385){logger[_0xe867('0x5')]('[utils][getUserByName]\x20name:%s\x20%s',_0xecad84,_0x3c1385?_0xe867('0x13'):_0xe867('0x14'));return _0x583c39(_0x3c1385);})[_0xe867('0xc')](function(_0x301997){logger[_0xe867('0x8')](_0xe867('0x1a'),_0x301997?util[_0xe867('0x6')](_0x301997,{'showHidden':![],'depth':null}):'');return _0x583c39(null);});}return _0x583c39(null);});};exports['getVoiceQueueByName']=function(_0x29c190){return new BPromise(function(_0x41d7ae,_0x214a80){if(_0x29c190){return client[_0xe867('0x9')](_0xe867('0x1b'),{'options':{'raw':!![],'attributes':['id',_0xe867('0xe'),_0xe867('0x1c'),_0xe867('0x1d'),'acwTimeout'],'where':{'name':_0x29c190},'limit':0x1}})[_0xe867('0xa')](function(_0x14d4b6){logger[_0xe867('0x7')]('[utils][getVoiceQueueByName]\x20name:%s',_0x29c190,_0x14d4b6?util[_0xe867('0x6')](_0x14d4b6,{'showHidden':![],'depth':null}):'');logger[_0xe867('0x5')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0x29c190,_0x14d4b6?_0xe867('0x13'):'notfound');return _0x41d7ae(_0x14d4b6['result'][_0xe867('0x10')]?_0x14d4b6['result'][0x0]:null);})[_0xe867('0xc')](function(_0x44e8bb){logger['error'](_0xe867('0x1e'),_0x44e8bb?util[_0xe867('0x6')](_0x44e8bb,{'showHidden':![],'depth':null}):'');return _0x41d7ae(null);});}return _0x41d7ae(null);});};exports['addTime']=function(_0x2034e7,_0x45e712){return moment(_0x2034e7)[_0xe867('0x1f')](_0x45e712,_0xe867('0x20'))['format'](_0xe867('0x21'));};exports['subtractTime']=function(_0x4d1609,_0x4452f7){return moment(_0x4d1609)[_0xe867('0x22')](_0x4452f7,'seconds')[_0xe867('0x23')](_0xe867('0x21'));};exports['diffTime']=function(_0x170ab0,_0x34dd29){return moment(_0x170ab0)[_0xe867('0x24')](moment(_0x34dd29),_0xe867('0x20'));};exports['sumTime']=function(_0x1ce2f6,_0x41e26b){return parseInt(_0x1ce2f6,0xa)+parseInt(_0x41e26b,0xa);};exports[_0xe867('0x25')]=function(){return moment()[_0xe867('0x23')](_0xe867('0x21'));};exports[_0xe867('0x26')]=function(_0x1a9d8f,_0x380307){if(_0x380307){return moment(_0x1a9d8f)['isAfter'](_0x380307);}return!![];};exports['isBefore']=function(_0x42db02,_0x4043d2){if(_0x4043d2){return moment(_0x42db02)[_0xe867('0x27')](_0x4043d2);}else if(_0x42db02){return!![];}return![];};
\ No newline at end of file