Built motion from commit (unavailable).|2.3.1
[motion2.git] / server / services / xdr / utils.js
index c987965..774f108 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdbf5=['jayson/promise','moment','bluebird','client','http','info','debug','stringify','error','stack','catch','request','GetUser','internal','name','interface','then','GETUSER|','result','length','FOUND','NOTFOUND','getUserByInterface','type','acwTimeout','GETVOICEQUEUEBYNAME|','addTime','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','format','diffTime','diff','now','isAfter'];(function(_0x3fa22d,_0x1c4b74){var _0x358103=function(_0x28866e){while(--_0x28866e){_0x3fa22d['push'](_0x3fa22d['shift']());}};_0x358103(++_0x1c4b74);}(_0xdbf5,0x144));var _0x5dbf=function(_0x3f8c37,_0x4bda06){_0x3f8c37=_0x3f8c37-0x0;var _0x2082b5=_0xdbf5[_0x3f8c37];return _0x2082b5;};'use strict';var jayson=require(_0x5dbf('0x0'));var moment=require(_0x5dbf('0x1'));var BPromise=require(_0x5dbf('0x2'));var client=jayson[_0x5dbf('0x3')][_0x5dbf('0x4')]({'port':0x2329});var logger=require('../../config/logger')('xdr');exports['info']=function(_0x35dca2){logger[_0x5dbf('0x5')](_0x35dca2);};exports[_0x5dbf('0x6')]=function(_0x19a64c){logger[_0x5dbf('0x6')](JSON[_0x5dbf('0x7')](_0x19a64c));};exports[_0x5dbf('0x8')]=function(_0xa53f88){logger[_0x5dbf('0x8')](_0xa53f88[_0x5dbf('0x9')]);};exports['request']=function(_0x59105a,_0xd920c9){return client['request'](_0x59105a,{'body':_0xd920c9})['then'](function(_0x256718){logger[_0x5dbf('0x6')](JSON['stringify'](_0x256718));})[_0x5dbf('0xa')](function(_0x104478){logger[_0x5dbf('0x8')](_0x104478[_0x5dbf('0x9')]);});};function getUser(_0x4b31a3){return client[_0x5dbf('0xb')](_0x5dbf('0xc'),{'options':{'raw':!![],'attributes':['id',_0x5dbf('0xd'),_0x5dbf('0xe'),_0x5dbf('0xf')],'where':_0x4b31a3,'limit':0x1}})[_0x5dbf('0x10')](function(_0x3f48e3){logger['info'](_0x5dbf('0x11')+JSON['stringify'](_0x4b31a3)+'|'+(_0x3f48e3[_0x5dbf('0x12')][_0x5dbf('0x13')]?_0x5dbf('0x14'):_0x5dbf('0x15')));return _0x3f48e3[_0x5dbf('0x12')][_0x5dbf('0x13')]?_0x3f48e3[_0x5dbf('0x12')][0x0]:null;});}exports['getUserByInternal']=function(_0x3bae23){return new BPromise(function(_0x50c69c,_0x13380e){if(_0x3bae23){return getUser({'internal':_0x3bae23})[_0x5dbf('0x10')](function(_0x3aef42){return _0x50c69c(_0x3aef42);})['catch'](function(_0x3c7311){logger[_0x5dbf('0x8')](_0x3c7311[_0x5dbf('0x9')]);return _0x50c69c(null);});}else{return _0x50c69c(null);}});};exports[_0x5dbf('0x16')]=function(_0x4a7790){return new BPromise(function(_0x402e10,_0xd571b6){if(_0x4a7790){return getUser({'interface':_0x4a7790})[_0x5dbf('0x10')](function(_0x25f4ca){return _0x402e10(_0x25f4ca);})['catch'](function(_0xe12146){logger[_0x5dbf('0x8')](_0xe12146[_0x5dbf('0x9')]);return _0x402e10(null);});}else{return _0x402e10(null);}});};exports['getUserByName']=function(_0xf21ed3){return new BPromise(function(_0x37ce40,_0x3492be){if(_0xf21ed3){return getUser({'name':_0xf21ed3})[_0x5dbf('0x10')](function(_0x1c6cc8){return _0x37ce40(_0x1c6cc8);})[_0x5dbf('0xa')](function(_0x27d69d){logger[_0x5dbf('0x8')](_0x27d69d[_0x5dbf('0x9')]);return _0x37ce40(null);});}else{return _0x37ce40(null);}});};exports['getVoiceQueueByName']=function(_0x42853c){return new BPromise(function(_0x4dc806,_0x1f7ab3){if(_0x42853c){return client[_0x5dbf('0xb')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0x5dbf('0xe'),_0x5dbf('0x17'),'acw',_0x5dbf('0x18')],'where':{'name':_0x42853c},'limit':0x1}})[_0x5dbf('0x10')](function(_0x44431b){logger['info'](_0x5dbf('0x19')+_0x42853c+'|'+(_0x44431b['result'][_0x5dbf('0x13')]?_0x5dbf('0x14'):_0x5dbf('0x15')));return _0x4dc806(_0x44431b[_0x5dbf('0x12')][_0x5dbf('0x13')]?_0x44431b['result'][0x0]:null);})['catch'](function(_0x2183c2){logger[_0x5dbf('0x8')](_0x2183c2['stack']);return _0x4dc806(null);});}else{return _0x4dc806(null);}});};exports[_0x5dbf('0x1a')]=function(_0x3e55f8,_0x5bbc71){return moment(_0x3e55f8)['add'](_0x5bbc71,_0x5dbf('0x1b'))['format'](_0x5dbf('0x1c'));};exports[_0x5dbf('0x1d')]=function(_0xbe1f2c,_0x336c5a){return moment(_0xbe1f2c)[_0x5dbf('0x1e')](_0x336c5a,_0x5dbf('0x1b'))[_0x5dbf('0x1f')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x5dbf('0x20')]=function(_0x145f08,_0x31804d){return moment(_0x145f08)[_0x5dbf('0x21')](moment(_0x31804d),_0x5dbf('0x1b'));};exports['sumTime']=function(_0x448a46,_0x2bba3a){return parseInt(_0x448a46,0xa)+parseInt(_0x2bba3a,0xa);};exports[_0x5dbf('0x22')]=function(){return moment()[_0x5dbf('0x1f')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x5dbf('0x23')]=function(_0x3430f1,_0x595eba){if(_0x595eba){return moment(_0x3430f1)[_0x5dbf('0x23')](_0x595eba);}else{return!![];}};exports['isBefore']=function(_0x132f31,_0x25910d){if(_0x25910d){return moment(_0x132f31)['isBefore'](_0x25910d);}else if(_0x132f31){return!![];}else{return![];}};
\ No newline at end of file
+var _0xe202=['isAfter','jayson/promise','client','http','../../config/logger','xdr','info','debug','stringify','error','stack','request','then','catch','GetUser','name','interface','result','length','getUserByInterface','GetVoiceQueue','type','acwTimeout','GETVOICEQUEUEBYNAME|','FOUND','NOTFOUND','addTime','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','diffTime','diff','sumTime','now'];(function(_0x4616d9,_0x9f3414){var _0x26fe00=function(_0x57af1c){while(--_0x57af1c){_0x4616d9['push'](_0x4616d9['shift']());}};_0x26fe00(++_0x9f3414);}(_0xe202,0x1bd));var _0x2e20=function(_0x2d19ff,_0x5633dd){_0x2d19ff=_0x2d19ff-0x0;var _0x2d06d7=_0xe202[_0x2d19ff];return _0x2d06d7;};'use strict';var jayson=require(_0x2e20('0x0'));var moment=require('moment');var BPromise=require('bluebird');var client=jayson[_0x2e20('0x1')][_0x2e20('0x2')]({'port':0x2329});var logger=require(_0x2e20('0x3'))(_0x2e20('0x4'));exports[_0x2e20('0x5')]=function(_0x2cd546){logger['info'](_0x2cd546);};exports['debug']=function(_0x3fedf0){logger[_0x2e20('0x6')](JSON[_0x2e20('0x7')](_0x3fedf0));};exports[_0x2e20('0x8')]=function(_0x418c7b){logger['error'](_0x418c7b[_0x2e20('0x9')]);};exports[_0x2e20('0xa')]=function(_0x3c4d4c,_0x55df58){return client[_0x2e20('0xa')](_0x3c4d4c,{'body':_0x55df58})[_0x2e20('0xb')](function(_0xd3e8b4){logger[_0x2e20('0x6')](JSON[_0x2e20('0x7')](_0xd3e8b4));})[_0x2e20('0xc')](function(_0x2b07e8){logger[_0x2e20('0x8')](_0x2b07e8[_0x2e20('0x9')]);});};function getUser(_0x538eb5){return client[_0x2e20('0xa')](_0x2e20('0xd'),{'options':{'raw':!![],'attributes':['id','internal',_0x2e20('0xe'),_0x2e20('0xf')],'where':_0x538eb5,'limit':0x1}})[_0x2e20('0xb')](function(_0x1c7776){logger[_0x2e20('0x5')]('GETUSER|'+JSON[_0x2e20('0x7')](_0x538eb5)+'|'+(_0x1c7776[_0x2e20('0x10')][_0x2e20('0x11')]?'FOUND':'NOTFOUND'));return _0x1c7776['result'][_0x2e20('0x11')]?_0x1c7776[_0x2e20('0x10')][0x0]:null;});}exports['getUserByInternal']=function(_0x21737f){return new BPromise(function(_0x5e3d70,_0x103c8c){if(_0x21737f){return getUser({'internal':_0x21737f})[_0x2e20('0xb')](function(_0x1bfe87){return _0x5e3d70(_0x1bfe87);})[_0x2e20('0xc')](function(_0x4228dd){logger[_0x2e20('0x8')](_0x4228dd[_0x2e20('0x9')]);return _0x5e3d70(null);});}else{return _0x5e3d70(null);}});};exports[_0x2e20('0x12')]=function(_0x47f4a3){return new BPromise(function(_0x4f24a2,_0x52e7ee){if(_0x47f4a3){return getUser({'interface':_0x47f4a3})[_0x2e20('0xb')](function(_0x276e08){return _0x4f24a2(_0x276e08);})[_0x2e20('0xc')](function(_0x9ffc5d){logger[_0x2e20('0x8')](_0x9ffc5d[_0x2e20('0x9')]);return _0x4f24a2(null);});}else{return _0x4f24a2(null);}});};exports['getUserByName']=function(_0x2281c7){return new BPromise(function(_0x40e94c,_0x54af63){if(_0x2281c7){return getUser({'name':_0x2281c7})[_0x2e20('0xb')](function(_0x83bfba){return _0x40e94c(_0x83bfba);})[_0x2e20('0xc')](function(_0x56c509){logger['error'](_0x56c509[_0x2e20('0x9')]);return _0x40e94c(null);});}else{return _0x40e94c(null);}});};exports['getVoiceQueueByName']=function(_0x9581b0){return new BPromise(function(_0x17704d,_0x7429e0){if(_0x9581b0){return client[_0x2e20('0xa')](_0x2e20('0x13'),{'options':{'raw':!![],'attributes':['id',_0x2e20('0xe'),_0x2e20('0x14'),'acw',_0x2e20('0x15')],'where':{'name':_0x9581b0},'limit':0x1}})[_0x2e20('0xb')](function(_0x450bf2){logger[_0x2e20('0x5')](_0x2e20('0x16')+_0x9581b0+'|'+(_0x450bf2[_0x2e20('0x10')][_0x2e20('0x11')]?_0x2e20('0x17'):_0x2e20('0x18')));return _0x17704d(_0x450bf2[_0x2e20('0x10')]['length']?_0x450bf2['result'][0x0]:null);})[_0x2e20('0xc')](function(_0x30ca24){logger[_0x2e20('0x8')](_0x30ca24[_0x2e20('0x9')]);return _0x17704d(null);});}else{return _0x17704d(null);}});};exports[_0x2e20('0x19')]=function(_0x4706df,_0x3d23cd){return moment(_0x4706df)[_0x2e20('0x1a')](_0x3d23cd,_0x2e20('0x1b'))[_0x2e20('0x1c')](_0x2e20('0x1d'));};exports[_0x2e20('0x1e')]=function(_0x110f9c,_0x197eba){return moment(_0x110f9c)[_0x2e20('0x1f')](_0x197eba,_0x2e20('0x1b'))[_0x2e20('0x1c')](_0x2e20('0x1d'));};exports[_0x2e20('0x20')]=function(_0x14a849,_0x4c7988){return moment(_0x14a849)[_0x2e20('0x21')](moment(_0x4c7988),_0x2e20('0x1b'));};exports[_0x2e20('0x22')]=function(_0x3f7809,_0x4a0e1c){return parseInt(_0x3f7809,0xa)+parseInt(_0x4a0e1c,0xa);};exports[_0x2e20('0x23')]=function(){return moment()['format'](_0x2e20('0x1d'));};exports['isAfter']=function(_0x650e78,_0x53e4d2){if(_0x53e4d2){return moment(_0x650e78)[_0x2e20('0x24')](_0x53e4d2);}else{return!![];}};exports['isBefore']=function(_0x173890,_0x47092c){if(_0x47092c){return moment(_0x173890)['isBefore'](_0x47092c);}else if(_0x173890){return!![];}else{return![];}};
\ No newline at end of file