Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / services / xdr / utils.js
index f168b61..016cfe2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2ba6=['add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtract','diff','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','../../config/logger','xdr','info','debug','inspect','error','request','then','[utils][request]\x20name:%s','GetUser','internal','name','interface','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','catch','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','[utils][getUserByName]\x20name:%s\x20%s','getVoiceQueueByName','GetVoiceQueue','type','acw','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]','addTime'];(function(_0x38a4a0,_0x4511cc){var _0x44a772=function(_0x77cade){while(--_0x77cade){_0x38a4a0['push'](_0x38a4a0['shift']());}};_0x44a772(++_0x4511cc);}(_0x2ba6,0x1ea));var _0x62ba=function(_0x18437c,_0x47d616){_0x18437c=_0x18437c-0x0;var _0x3f4276=_0x2ba6[_0x18437c];return _0x3f4276;};'use strict';var BPromise=require(_0x62ba('0x0'));var jayson=require(_0x62ba('0x1'));var moment=require(_0x62ba('0x2'));var util=require(_0x62ba('0x3'));var client=jayson[_0x62ba('0x4')]['http']({'port':0x2329});var logger=require(_0x62ba('0x5'))(_0x62ba('0x6'));exports[_0x62ba('0x7')]=function(_0x362f2c,_0x42eef5){logger[_0x62ba('0x7')](_0x362f2c,_0x42eef5?util['inspect'](_0x42eef5,{'showHidden':![],'depth':null}):'');};exports[_0x62ba('0x8')]=function(_0x24c78a,_0x8a432d){logger['debug'](_0x24c78a,_0x8a432d?util[_0x62ba('0x9')](_0x8a432d,{'showHidden':![],'depth':null}):'');};exports['error']=function(_0xb60414,_0xc1cb24){logger[_0x62ba('0xa')](_0xb60414,_0xc1cb24?util[_0x62ba('0x9')](_0xc1cb24,{'showHidden':![],'depth':null}):'');};exports[_0x62ba('0xb')]=function(_0x1c5e97,_0x22e81e){return client[_0x62ba('0xb')](_0x1c5e97,{'body':_0x22e81e})[_0x62ba('0xc')](function(_0x54366b){logger[_0x62ba('0x8')](_0x62ba('0xd'),_0x1c5e97,_0x54366b?util[_0x62ba('0x9')](_0x54366b,{'showHidden':![],'depth':null}):'');})['catch'](function(_0x4a4aeb){logger[_0x62ba('0xa')](_0x62ba('0xd'),_0x1c5e97,_0x4a4aeb?util[_0x62ba('0x9')](_0x4a4aeb,{'showHidden':![],'depth':null}):'');});};function getUser(_0x2bd312){return client[_0x62ba('0xb')](_0x62ba('0xe'),{'options':{'raw':!![],'attributes':['id',_0x62ba('0xf'),_0x62ba('0x10'),_0x62ba('0x11')],'where':_0x2bd312,'limit':0x1}})[_0x62ba('0xc')](function(_0x4535db){logger[_0x62ba('0x8')]('[utils][getUser]\x20where:%s',JSON[_0x62ba('0x12')](_0x2bd312),_0x4535db?util[_0x62ba('0x9')](_0x4535db,{'showHidden':![],'depth':null}):'');return _0x4535db[_0x62ba('0x13')][_0x62ba('0x14')]?_0x4535db['result'][0x0]:null;});}exports[_0x62ba('0x15')]=function(_0x453010){return new BPromise(function(_0x3e0a33,_0x567a38){if(_0x453010){return getUser({'internal':_0x453010})[_0x62ba('0xc')](function(_0x1ea7ab){logger['info'](_0x62ba('0x16'),_0x453010,_0x1ea7ab?_0x62ba('0x17'):_0x62ba('0x18'));return _0x3e0a33(_0x1ea7ab);})[_0x62ba('0x19')](function(_0xf00b36){logger[_0x62ba('0xa')](_0x62ba('0x1a'),_0xf00b36?util[_0x62ba('0x9')](_0xf00b36,{'showHidden':![],'depth':null}):'');return _0x3e0a33(null);});}return _0x3e0a33(null);});};exports[_0x62ba('0x1b')]=function(_0x44ecb3){return new BPromise(function(_0x439cc6,_0x2f7ab2){if(_0x44ecb3){return getUser({'interface':_0x44ecb3})[_0x62ba('0xc')](function(_0x27a867){logger[_0x62ba('0x7')](_0x62ba('0x1c'),_0x44ecb3,_0x27a867?_0x62ba('0x17'):_0x62ba('0x18'));return _0x439cc6(_0x27a867);})[_0x62ba('0x19')](function(_0x84cd96){logger[_0x62ba('0xa')](_0x62ba('0x1d'),_0x84cd96?util[_0x62ba('0x9')](_0x84cd96,{'showHidden':![],'depth':null}):'');return _0x439cc6(null);});}return _0x439cc6(null);});};exports['getUserByName']=function(_0x3b2230){return new BPromise(function(_0x1055a0,_0x146950){if(_0x3b2230){return getUser({'name':_0x3b2230})[_0x62ba('0xc')](function(_0x183b26){logger['info'](_0x62ba('0x1e'),_0x3b2230,_0x183b26?_0x62ba('0x17'):_0x62ba('0x18'));return _0x1055a0(_0x183b26);})['catch'](function(_0x2d2151){logger[_0x62ba('0xa')]('[utils][getUserByName]',_0x2d2151?util[_0x62ba('0x9')](_0x2d2151,{'showHidden':![],'depth':null}):'');return _0x1055a0(null);});}return _0x1055a0(null);});};exports[_0x62ba('0x1f')]=function(_0x8c0e7a){return new BPromise(function(_0x4d4e57,_0x245629){if(_0x8c0e7a){return client[_0x62ba('0xb')](_0x62ba('0x20'),{'options':{'raw':!![],'attributes':['id',_0x62ba('0x10'),_0x62ba('0x21'),_0x62ba('0x22'),'acwTimeout'],'where':{'name':_0x8c0e7a},'limit':0x1}})[_0x62ba('0xc')](function(_0xe587ef){logger['debug'](_0x62ba('0x23'),_0x8c0e7a,_0xe587ef?util[_0x62ba('0x9')](_0xe587ef,{'showHidden':![],'depth':null}):'');logger[_0x62ba('0x7')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0x8c0e7a,_0xe587ef?'found':_0x62ba('0x18'));return _0x4d4e57(_0xe587ef[_0x62ba('0x13')]['length']?_0xe587ef['result'][0x0]:null);})[_0x62ba('0x19')](function(_0x4b09b0){logger[_0x62ba('0xa')](_0x62ba('0x24'),_0x4b09b0?util[_0x62ba('0x9')](_0x4b09b0,{'showHidden':![],'depth':null}):'');return _0x4d4e57(null);});}return _0x4d4e57(null);});};exports[_0x62ba('0x25')]=function(_0x4e4eec,_0x4cd8fb){return moment(_0x4e4eec)[_0x62ba('0x26')](_0x4cd8fb,_0x62ba('0x27'))[_0x62ba('0x28')](_0x62ba('0x29'));};exports['subtractTime']=function(_0x38a866,_0x5b79df){return moment(_0x38a866)[_0x62ba('0x2a')](_0x5b79df,_0x62ba('0x27'))['format'](_0x62ba('0x29'));};exports['diffTime']=function(_0xe225b2,_0x2cc332){return moment(_0xe225b2)[_0x62ba('0x2b')](moment(_0x2cc332),_0x62ba('0x27'));};exports[_0x62ba('0x2c')]=function(_0x5a307c,_0x5c1c6a){return parseInt(_0x5a307c,0xa)+parseInt(_0x5c1c6a,0xa);};exports[_0x62ba('0x2d')]=function(){return moment()[_0x62ba('0x28')](_0x62ba('0x29'));};exports[_0x62ba('0x2e')]=function(_0x7acf85,_0x9b8efe){if(_0x9b8efe){return moment(_0x7acf85)['isAfter'](_0x9b8efe);}return!![];};exports[_0x62ba('0x2f')]=function(_0x194527,_0x5e21cf){if(_0x5e21cf){return moment(_0x194527)[_0x62ba('0x2f')](_0x5e21cf);}else if(_0x194527){return!![];}return![];};
\ No newline at end of file
+var _0x708c=['found','[utils][getUserByName]','getVoiceQueueByName','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','addTime','add','seconds','format','subtractTime','subtract','YYYY-MM-DD\x20HH:mm:ss','diffTime','sumTime','now','isAfter','isBefore','bluebird','util','http','../../config/logger','xdr','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','GetUser','internal','name','[utils][getUser]\x20where:%s','result','[utils][getUserByInternal]\x20internal:%s\x20%s','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','getUserByName','[utils][getUserByName]\x20name:%s\x20%s'];(function(_0x3bcf82,_0x35c33f){var _0x3a204b=function(_0x180b57){while(--_0x180b57){_0x3bcf82['push'](_0x3bcf82['shift']());}};_0x3a204b(++_0x35c33f);}(_0x708c,0x9b));var _0xc708=function(_0x592e53,_0x1dc3d7){_0x592e53=_0x592e53-0x0;var _0x4ae082=_0x708c[_0x592e53];return _0x4ae082;};'use strict';var BPromise=require(_0xc708('0x0'));var jayson=require('jayson/promise');var moment=require('moment');var util=require(_0xc708('0x1'));var client=jayson['client'][_0xc708('0x2')]({'port':0x2329});var logger=require(_0xc708('0x3'))(_0xc708('0x4'));exports[_0xc708('0x5')]=function(_0x577868,_0x263db5){logger[_0xc708('0x5')](_0x577868,_0x263db5?util[_0xc708('0x6')](_0x263db5,{'showHidden':![],'depth':null}):'');};exports[_0xc708('0x7')]=function(_0x1061bc,_0x303638){logger[_0xc708('0x7')](_0x1061bc,_0x303638?util['inspect'](_0x303638,{'showHidden':![],'depth':null}):'');};exports[_0xc708('0x8')]=function(_0x831f62,_0x40bb7f){logger[_0xc708('0x8')](_0x831f62,_0x40bb7f?util[_0xc708('0x6')](_0x40bb7f,{'showHidden':![],'depth':null}):'');};exports[_0xc708('0x9')]=function(_0x4fd229,_0x5d508a){return client[_0xc708('0x9')](_0x4fd229,{'body':_0x5d508a})[_0xc708('0xa')](function(_0x10f86d){logger[_0xc708('0x7')](_0xc708('0xb'),_0x4fd229,_0x10f86d?util[_0xc708('0x6')](_0x10f86d,{'showHidden':![],'depth':null}):'');})[_0xc708('0xc')](function(_0x5c0be1){logger[_0xc708('0x8')](_0xc708('0xb'),_0x4fd229,_0x5c0be1?util['inspect'](_0x5c0be1,{'showHidden':![],'depth':null}):'');});};function getUser(_0x4d993e){return client[_0xc708('0x9')](_0xc708('0xd'),{'options':{'raw':!![],'attributes':['id',_0xc708('0xe'),_0xc708('0xf'),'interface'],'where':_0x4d993e,'limit':0x1}})['then'](function(_0x34ba8d){logger[_0xc708('0x7')](_0xc708('0x10'),JSON['stringify'](_0x4d993e),_0x34ba8d?util[_0xc708('0x6')](_0x34ba8d,{'showHidden':![],'depth':null}):'');return _0x34ba8d[_0xc708('0x11')]['length']?_0x34ba8d[_0xc708('0x11')][0x0]:null;});}exports['getUserByInternal']=function(_0x1eaea2){return new BPromise(function(_0x287b6f,_0x32cd19){if(_0x1eaea2){return getUser({'internal':_0x1eaea2})[_0xc708('0xa')](function(_0x274c50){logger[_0xc708('0x5')](_0xc708('0x12'),_0x1eaea2,_0x274c50?'found':_0xc708('0x13'));return _0x287b6f(_0x274c50);})[_0xc708('0xc')](function(_0x241244){logger[_0xc708('0x8')](_0xc708('0x14'),_0x241244?util[_0xc708('0x6')](_0x241244,{'showHidden':![],'depth':null}):'');return _0x287b6f(null);});}return _0x287b6f(null);});};exports[_0xc708('0x15')]=function(_0x990cdd){return new BPromise(function(_0x42282a,_0x5f4710){if(_0x990cdd){return getUser({'interface':_0x990cdd})[_0xc708('0xa')](function(_0x19a1ef){logger[_0xc708('0x5')](_0xc708('0x16'),_0x990cdd,_0x19a1ef?'found':'notfound');return _0x42282a(_0x19a1ef);})[_0xc708('0xc')](function(_0x39b5f8){logger['error']('[utils][getUserByInterface]',_0x39b5f8?util['inspect'](_0x39b5f8,{'showHidden':![],'depth':null}):'');return _0x42282a(null);});}return _0x42282a(null);});};exports[_0xc708('0x17')]=function(_0x1f6a68){return new BPromise(function(_0x2544e2,_0x750f26){if(_0x1f6a68){return getUser({'name':_0x1f6a68})[_0xc708('0xa')](function(_0x1f263e){logger['info'](_0xc708('0x18'),_0x1f6a68,_0x1f263e?_0xc708('0x19'):_0xc708('0x13'));return _0x2544e2(_0x1f263e);})[_0xc708('0xc')](function(_0x31b36c){logger['error'](_0xc708('0x1a'),_0x31b36c?util[_0xc708('0x6')](_0x31b36c,{'showHidden':![],'depth':null}):'');return _0x2544e2(null);});}return _0x2544e2(null);});};exports[_0xc708('0x1b')]=function(_0x2de9e0){return new BPromise(function(_0x4e000d,_0x5dc660){if(_0x2de9e0){return client[_0xc708('0x9')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0xc708('0xf'),_0xc708('0x1c'),_0xc708('0x1d'),_0xc708('0x1e')],'where':{'name':_0x2de9e0},'limit':0x1}})[_0xc708('0xa')](function(_0x411352){logger[_0xc708('0x7')](_0xc708('0x1f'),_0x2de9e0,_0x411352?util[_0xc708('0x6')](_0x411352,{'showHidden':![],'depth':null}):'');logger[_0xc708('0x5')](_0xc708('0x20'),_0x2de9e0,_0x411352?_0xc708('0x19'):_0xc708('0x13'));return _0x4e000d(_0x411352[_0xc708('0x11')]['length']?_0x411352[_0xc708('0x11')][0x0]:null);})[_0xc708('0xc')](function(_0x440423){logger[_0xc708('0x8')]('[utils][getVoiceQueueByName]',_0x440423?util[_0xc708('0x6')](_0x440423,{'showHidden':![],'depth':null}):'');return _0x4e000d(null);});}return _0x4e000d(null);});};exports[_0xc708('0x21')]=function(_0x5f44e8,_0x50314c){return moment(_0x5f44e8)[_0xc708('0x22')](_0x50314c,_0xc708('0x23'))[_0xc708('0x24')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0xc708('0x25')]=function(_0x25b17c,_0xf997f2){return moment(_0x25b17c)[_0xc708('0x26')](_0xf997f2,'seconds')[_0xc708('0x24')](_0xc708('0x27'));};exports[_0xc708('0x28')]=function(_0x2cbbfb,_0xedfa40){return moment(_0x2cbbfb)['diff'](moment(_0xedfa40),_0xc708('0x23'));};exports[_0xc708('0x29')]=function(_0x330f6f,_0x3e3121){return parseInt(_0x330f6f,0xa)+parseInt(_0x3e3121,0xa);};exports[_0xc708('0x2a')]=function(){return moment()[_0xc708('0x24')](_0xc708('0x27'));};exports[_0xc708('0x2b')]=function(_0x1f9536,_0xf9138d){if(_0xf9138d){return moment(_0x1f9536)[_0xc708('0x2b')](_0xf9138d);}return!![];};exports['isBefore']=function(_0x503f93,_0x1fea04){if(_0x1fea04){return moment(_0x503f93)[_0xc708('0x2c')](_0x1fea04);}else if(_0x503f93){return!![];}return![];};
\ No newline at end of file