Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / services / xdr / utils.js
index cf9f31b..9261f79 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x40d9=['diffTime','diff','sumTime','now','isAfter','isBefore','moment','bluebird','client','http','xdr','info','debug','stringify','error','stack','request','then','catch','internal','name','interface','GETUSER|','result','length','FOUND','getUserByInternal','getUserByInterface','getVoiceQueueByName','acw','acwTimeout','GETVOICEQUEUEBYNAME|','addTime','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x1c21b0,_0x20a651){var _0x3bdc02=function(_0x175ac3){while(--_0x175ac3){_0x1c21b0['push'](_0x1c21b0['shift']());}};_0x3bdc02(++_0x20a651);}(_0x40d9,0x1e7));var _0x940d=function(_0x386adf,_0x174b7a){_0x386adf=_0x386adf-0x0;var _0x1e44a6=_0x40d9[_0x386adf];return _0x1e44a6;};'use strict';var jayson=require('jayson/promise');var moment=require(_0x940d('0x0'));var BPromise=require(_0x940d('0x1'));var client=jayson[_0x940d('0x2')][_0x940d('0x3')]({'port':0x2329});var logger=require('../../config/logger')(_0x940d('0x4'));exports[_0x940d('0x5')]=function(_0x1e1b84){logger[_0x940d('0x5')](_0x1e1b84);};exports[_0x940d('0x6')]=function(_0x19b087){logger[_0x940d('0x6')](JSON[_0x940d('0x7')](_0x19b087));};exports['error']=function(_0x1beba9){logger[_0x940d('0x8')](_0x1beba9[_0x940d('0x9')]);};exports[_0x940d('0xa')]=function(_0x2b168a,_0x31f8dc){return client['request'](_0x2b168a,{'body':_0x31f8dc})[_0x940d('0xb')](function(_0x5d6183){logger['debug'](JSON[_0x940d('0x7')](_0x5d6183));})[_0x940d('0xc')](function(_0x13c5c7){logger[_0x940d('0x8')](_0x13c5c7[_0x940d('0x9')]);});};function getUser(_0x46a6fe){return client[_0x940d('0xa')]('GetUser',{'options':{'raw':!![],'attributes':['id',_0x940d('0xd'),_0x940d('0xe'),_0x940d('0xf')],'where':_0x46a6fe,'limit':0x1}})[_0x940d('0xb')](function(_0x43f6e5){logger[_0x940d('0x5')](_0x940d('0x10')+JSON[_0x940d('0x7')](_0x46a6fe)+'|'+(_0x43f6e5[_0x940d('0x11')][_0x940d('0x12')]?_0x940d('0x13'):'NOTFOUND'));return _0x43f6e5[_0x940d('0x11')][_0x940d('0x12')]?_0x43f6e5['result'][0x0]:null;});}exports[_0x940d('0x14')]=function(_0x1e06fb){return new BPromise(function(_0x5acdd9,_0x509602){if(_0x1e06fb){return getUser({'internal':_0x1e06fb})[_0x940d('0xb')](function(_0x5a5c39){return _0x5acdd9(_0x5a5c39);})[_0x940d('0xc')](function(_0x1d8ed){logger[_0x940d('0x8')](_0x1d8ed[_0x940d('0x9')]);return _0x5acdd9(null);});}else{return _0x5acdd9(null);}});};exports[_0x940d('0x15')]=function(_0x5d6e06){return new BPromise(function(_0x316782,_0x2382fe){if(_0x5d6e06){return getUser({'interface':_0x5d6e06})['then'](function(_0x4aea36){return _0x316782(_0x4aea36);})[_0x940d('0xc')](function(_0x1dca6d){logger[_0x940d('0x8')](_0x1dca6d[_0x940d('0x9')]);return _0x316782(null);});}else{return _0x316782(null);}});};exports['getUserByName']=function(_0x3be46c){return new BPromise(function(_0x627e31,_0x1e693b){if(_0x3be46c){return getUser({'name':_0x3be46c})[_0x940d('0xb')](function(_0x3ad9e9){return _0x627e31(_0x3ad9e9);})[_0x940d('0xc')](function(_0x18f499){logger[_0x940d('0x8')](_0x18f499[_0x940d('0x9')]);return _0x627e31(null);});}else{return _0x627e31(null);}});};exports[_0x940d('0x16')]=function(_0x256f67){return new BPromise(function(_0x2ad0b0,_0x1f6adb){if(_0x256f67){return client['request']('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0x940d('0xe'),'type',_0x940d('0x17'),_0x940d('0x18')],'where':{'name':_0x256f67},'limit':0x1}})[_0x940d('0xb')](function(_0x336b88){logger[_0x940d('0x5')](_0x940d('0x19')+_0x256f67+'|'+(_0x336b88['result']['length']?'FOUND':'NOTFOUND'));return _0x2ad0b0(_0x336b88[_0x940d('0x11')][_0x940d('0x12')]?_0x336b88[_0x940d('0x11')][0x0]:null);})[_0x940d('0xc')](function(_0x8140df){logger['error'](_0x8140df[_0x940d('0x9')]);return _0x2ad0b0(null);});}else{return _0x2ad0b0(null);}});};exports[_0x940d('0x1a')]=function(_0x17312f,_0x33428c){return moment(_0x17312f)[_0x940d('0x1b')](_0x33428c,_0x940d('0x1c'))[_0x940d('0x1d')](_0x940d('0x1e'));};exports['subtractTime']=function(_0x2afad1,_0x55f4a8){return moment(_0x2afad1)['subtract'](_0x55f4a8,_0x940d('0x1c'))[_0x940d('0x1d')](_0x940d('0x1e'));};exports[_0x940d('0x1f')]=function(_0x71dcc3,_0x5c2fba){return moment(_0x71dcc3)[_0x940d('0x20')](moment(_0x5c2fba),_0x940d('0x1c'));};exports[_0x940d('0x21')]=function(_0x191cc0,_0xf15d1a){return parseInt(_0x191cc0,0xa)+parseInt(_0xf15d1a,0xa);};exports[_0x940d('0x22')]=function(){return moment()[_0x940d('0x1d')](_0x940d('0x1e'));};exports['isAfter']=function(_0x1eb897,_0x1b87cd){if(_0x1b87cd){return moment(_0x1eb897)[_0x940d('0x23')](_0x1b87cd);}else{return!![];}};exports[_0x940d('0x24')]=function(_0x471053,_0x5d9438){if(_0x5d9438){return moment(_0x471053)[_0x940d('0x24')](_0x5d9438);}else if(_0x471053){return!![];}else{return![];}};
\ No newline at end of file
+var _0xa4d7=['acw','GETVOICEQUEUEBYNAME|','NOTFOUND','addTime','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtractTime','diffTime','sumTime','isAfter','isBefore','jayson/promise','moment','bluebird','client','../../config/logger','info','debug','stringify','error','stack','request','then','GetUser','internal','name','interface','result','length','FOUND','catch','getUserByInterface','getUserByName','getVoiceQueueByName','GetVoiceQueue','type'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0xa4d7,0x1d5));var _0x7a4d=function(_0x2c799c,_0x137021){_0x2c799c=_0x2c799c-0x0;var _0x951167=_0xa4d7[_0x2c799c];return _0x951167;};'use strict';var jayson=require(_0x7a4d('0x0'));var moment=require(_0x7a4d('0x1'));var BPromise=require(_0x7a4d('0x2'));var client=jayson[_0x7a4d('0x3')]['http']({'port':0x2329});var logger=require(_0x7a4d('0x4'))('xdr');exports[_0x7a4d('0x5')]=function(_0x3a8184){logger[_0x7a4d('0x5')](_0x3a8184);};exports[_0x7a4d('0x6')]=function(_0x2da3c8){logger['debug'](JSON[_0x7a4d('0x7')](_0x2da3c8));};exports['error']=function(_0x107d39){logger[_0x7a4d('0x8')](_0x107d39[_0x7a4d('0x9')]);};exports[_0x7a4d('0xa')]=function(_0x57e091,_0x191841){return client[_0x7a4d('0xa')](_0x57e091,{'body':_0x191841})[_0x7a4d('0xb')](function(_0x272317){logger[_0x7a4d('0x6')](JSON[_0x7a4d('0x7')](_0x272317));})['catch'](function(_0x2859b7){logger[_0x7a4d('0x8')](_0x2859b7[_0x7a4d('0x9')]);});};function getUser(_0x3f2e31){return client['request'](_0x7a4d('0xc'),{'options':{'raw':!![],'attributes':['id',_0x7a4d('0xd'),_0x7a4d('0xe'),_0x7a4d('0xf')],'where':_0x3f2e31,'limit':0x1}})[_0x7a4d('0xb')](function(_0x16cfdc){logger[_0x7a4d('0x5')]('GETUSER|'+JSON['stringify'](_0x3f2e31)+'|'+(_0x16cfdc[_0x7a4d('0x10')][_0x7a4d('0x11')]?_0x7a4d('0x12'):'NOTFOUND'));return _0x16cfdc[_0x7a4d('0x10')][_0x7a4d('0x11')]?_0x16cfdc[_0x7a4d('0x10')][0x0]:null;});}exports['getUserByInternal']=function(_0x24bcdb){return new BPromise(function(_0x1f1ef9,_0x360360){if(_0x24bcdb){return getUser({'internal':_0x24bcdb})[_0x7a4d('0xb')](function(_0x3dac11){return _0x1f1ef9(_0x3dac11);})[_0x7a4d('0x13')](function(_0x1fb965){logger[_0x7a4d('0x8')](_0x1fb965[_0x7a4d('0x9')]);return _0x1f1ef9(null);});}else{return _0x1f1ef9(null);}});};exports[_0x7a4d('0x14')]=function(_0x381f7f){return new BPromise(function(_0x57adbc,_0x59ee47){if(_0x381f7f){return getUser({'interface':_0x381f7f})[_0x7a4d('0xb')](function(_0x39fcbf){return _0x57adbc(_0x39fcbf);})[_0x7a4d('0x13')](function(_0x20bed2){logger[_0x7a4d('0x8')](_0x20bed2['stack']);return _0x57adbc(null);});}else{return _0x57adbc(null);}});};exports[_0x7a4d('0x15')]=function(_0x4d4b33){return new BPromise(function(_0x2a0823,_0x33872f){if(_0x4d4b33){return getUser({'name':_0x4d4b33})[_0x7a4d('0xb')](function(_0x14d1be){return _0x2a0823(_0x14d1be);})['catch'](function(_0x48e4b2){logger[_0x7a4d('0x8')](_0x48e4b2[_0x7a4d('0x9')]);return _0x2a0823(null);});}else{return _0x2a0823(null);}});};exports[_0x7a4d('0x16')]=function(_0x13aadd){return new BPromise(function(_0x32cf49,_0x5aa252){if(_0x13aadd){return client[_0x7a4d('0xa')](_0x7a4d('0x17'),{'options':{'raw':!![],'attributes':['id','name',_0x7a4d('0x18'),_0x7a4d('0x19'),'acwTimeout'],'where':{'name':_0x13aadd},'limit':0x1}})[_0x7a4d('0xb')](function(_0x2c26de){logger[_0x7a4d('0x5')](_0x7a4d('0x1a')+_0x13aadd+'|'+(_0x2c26de['result'][_0x7a4d('0x11')]?_0x7a4d('0x12'):_0x7a4d('0x1b')));return _0x32cf49(_0x2c26de[_0x7a4d('0x10')]['length']?_0x2c26de[_0x7a4d('0x10')][0x0]:null);})[_0x7a4d('0x13')](function(_0x26a276){logger[_0x7a4d('0x8')](_0x26a276[_0x7a4d('0x9')]);return _0x32cf49(null);});}else{return _0x32cf49(null);}});};exports[_0x7a4d('0x1c')]=function(_0x3e94d9,_0x17d012){return moment(_0x3e94d9)[_0x7a4d('0x1d')](_0x17d012,_0x7a4d('0x1e'))[_0x7a4d('0x1f')](_0x7a4d('0x20'));};exports[_0x7a4d('0x21')]=function(_0x15a76d,_0x1d9574){return moment(_0x15a76d)['subtract'](_0x1d9574,_0x7a4d('0x1e'))[_0x7a4d('0x1f')](_0x7a4d('0x20'));};exports[_0x7a4d('0x22')]=function(_0x123c60,_0x243a2d){return moment(_0x123c60)['diff'](moment(_0x243a2d),_0x7a4d('0x1e'));};exports[_0x7a4d('0x23')]=function(_0x3468d4,_0x172abf){return parseInt(_0x3468d4,0xa)+parseInt(_0x172abf,0xa);};exports['now']=function(){return moment()['format']('YYYY-MM-DD\x20HH:mm:ss');};exports['isAfter']=function(_0xf540d5,_0x5cf847){if(_0x5cf847){return moment(_0xf540d5)[_0x7a4d('0x24')](_0x5cf847);}else{return!![];}};exports[_0x7a4d('0x25')]=function(_0x2fad0f,_0x44bf92){if(_0x44bf92){return moment(_0x2fad0f)[_0x7a4d('0x25')](_0x44bf92);}else if(_0x2fad0f){return!![];}else{return![];}};
\ No newline at end of file