c2e3e5a512461b5e3f8725b6e4c67ddb42164503
[motion-next.git] / server / services / xdr / utils.js
1 const a1228_0x59f5=['isAfter','getUserByInterface','catch','NOTFOUND','length','isBefore','GetUser','type','http','add','moment','GetVoiceQueue','GETUSER|','debug','subtractTime','then','format','getVoiceQueueByName','result','name','request','YYYY-MM-DD\x20HH:mm:ss','FOUND','diff','addTime','stringify','acwTimeout','subtract','getUserByName','seconds','error','info','acw','stack'];(function(_0x354ce2,_0x59f555){const _0x2ec5da=function(_0x4a7800){while(--_0x4a7800){_0x354ce2['push'](_0x354ce2['shift']());}};_0x2ec5da(++_0x59f555);}(a1228_0x59f5,0xce));const a1228_0x2ec5=function(_0x354ce2,_0x59f555){_0x354ce2=_0x354ce2-0x0;let _0x2ec5da=a1228_0x59f5[_0x354ce2];return _0x2ec5da;};const _0x3645f5=a1228_0x2ec5;'use strict';const jayson=require('jayson/promise'),moment=require(_0x3645f5('0x8')),client=jayson['client'][_0x3645f5('0x6')]({'port':0x2329}),logger=require('../../config/logger')('xdr');exports['info']=function(_0x4a7800){const _0x1b5bcd=_0x3645f5;logger[_0x1b5bcd('0x1d')](_0x4a7800);},exports[_0x3645f5('0xb')]=function(_0x5f41e6){logger['debug'](JSON['stringify'](_0x5f41e6));},exports[_0x3645f5('0x1c')]=function(_0x534906){const _0x1bffb3=_0x3645f5;logger[_0x1bffb3('0x1c')](_0x534906[_0x1bffb3('0x1f')]);},exports[_0x3645f5('0x12')]=function(_0x5b5475,_0x303737){const _0xf23a4a=_0x3645f5;return client[_0xf23a4a('0x12')](_0x5b5475,{'body':_0x303737})[_0xf23a4a('0xd')](function(_0x3ce275){const _0x2751ec=_0xf23a4a;logger[_0x2751ec('0xb')](JSON[_0x2751ec('0x17')](_0x3ce275));})[_0xf23a4a('0x0')](function(_0x34d30f){const _0x144425=_0xf23a4a;logger[_0x144425('0x1c')](_0x34d30f[_0x144425('0x1f')]);});};function getUser(_0x328d56){const _0x1938a0=_0x3645f5;return client['request'](_0x1938a0('0x4'),{'options':{'raw':!![],'attributes':['id','internal',_0x1938a0('0x11'),'interface'],'where':_0x328d56,'limit':0x1}})[_0x1938a0('0xd')](function(_0x56e253){const _0x537d7c=_0x1938a0;return logger['info'](_0x537d7c('0xa')+JSON[_0x537d7c('0x17')](_0x328d56)+'|'+(_0x56e253[_0x537d7c('0x10')][_0x537d7c('0x2')]?'FOUND':_0x537d7c('0x1'))),_0x56e253['result'][_0x537d7c('0x2')]?_0x56e253[_0x537d7c('0x10')][0x0]:null;});}exports['getUserByInternal']=function(_0x3ab375){return new Promise(function(_0x811d49){const _0x4eea20=a1228_0x2ec5;return _0x3ab375?getUser({'internal':_0x3ab375})[_0x4eea20('0xd')](function(_0x1db900){return _0x811d49(_0x1db900);})[_0x4eea20('0x0')](function(_0x50ef22){const _0x4cc266=_0x4eea20;return logger[_0x4cc266('0x1c')](_0x50ef22[_0x4cc266('0x1f')]),_0x811d49(null);}):_0x811d49(null);});},exports[_0x3645f5('0x21')]=function(_0x23ec1e){return new Promise(function(_0x273a79){const _0x3c218b=a1228_0x2ec5;return _0x23ec1e?getUser({'interface':_0x23ec1e})[_0x3c218b('0xd')](function(_0x952469){return _0x273a79(_0x952469);})[_0x3c218b('0x0')](function(_0x1fe241){const _0x1b6ae0=_0x3c218b;return logger['error'](_0x1fe241[_0x1b6ae0('0x1f')]),_0x273a79(null);}):_0x273a79(null);});},exports[_0x3645f5('0x1a')]=function(_0x35bb79){return new Promise(function(_0x2decd9){const _0x26676d=a1228_0x2ec5;return _0x35bb79?getUser({'name':_0x35bb79})[_0x26676d('0xd')](function(_0x58ea6e){return _0x2decd9(_0x58ea6e);})[_0x26676d('0x0')](function(_0x2951f3){const _0x112de3=_0x26676d;return logger['error'](_0x2951f3[_0x112de3('0x1f')]),_0x2decd9(null);}):_0x2decd9(null);});},exports[_0x3645f5('0xf')]=function(_0xa1b49d){return new Promise(function(_0x31146d){const _0x252bc6=a1228_0x2ec5;return _0xa1b49d?client[_0x252bc6('0x12')](_0x252bc6('0x9'),{'options':{'raw':!![],'attributes':['id',_0x252bc6('0x11'),_0x252bc6('0x5'),_0x252bc6('0x1e'),_0x252bc6('0x18')],'where':{'name':_0xa1b49d},'limit':0x1}})[_0x252bc6('0xd')](function(_0x5d2476){const _0x274f70=_0x252bc6;return logger[_0x274f70('0x1d')]('GETVOICEQUEUEBYNAME|'+_0xa1b49d+'|'+(_0x5d2476[_0x274f70('0x10')][_0x274f70('0x2')]?_0x274f70('0x14'):'NOTFOUND')),_0x31146d(_0x5d2476[_0x274f70('0x10')][_0x274f70('0x2')]?_0x5d2476['result'][0x0]:null);})[_0x252bc6('0x0')](function(_0x708ab3){const _0x73eb5c=_0x252bc6;return logger['error'](_0x708ab3[_0x73eb5c('0x1f')]),_0x31146d(null);}):_0x31146d(null);});},exports[_0x3645f5('0x16')]=function(_0x58c0e5,_0x1494fb){const _0x8e0e33=_0x3645f5;return moment(_0x58c0e5)[_0x8e0e33('0x7')](_0x1494fb,'seconds')[_0x8e0e33('0xe')](_0x8e0e33('0x13'));},exports[_0x3645f5('0xc')]=function(_0x470a68,_0x46bd5a){const _0x195791=_0x3645f5;return moment(_0x470a68)[_0x195791('0x19')](_0x46bd5a,'seconds')[_0x195791('0xe')]('YYYY-MM-DD\x20HH:mm:ss');},exports['diffTime']=function(_0x13e2da,_0x2265f8){const _0x408c6d=_0x3645f5;return moment(_0x13e2da)[_0x408c6d('0x15')](moment(_0x2265f8),_0x408c6d('0x1b'));},exports['sumTime']=function(_0x173c2a,_0x105a09){return parseInt(_0x173c2a,0xa)+parseInt(_0x105a09,0xa);},exports['now']=function(){const _0x4de842=_0x3645f5;return moment()[_0x4de842('0xe')](_0x4de842('0x13'));},exports[_0x3645f5('0x20')]=function(_0x39ac01,_0x2ea995){return _0x2ea995?moment(_0x39ac01)['isAfter'](_0x2ea995):!![];},exports[_0x3645f5('0x3')]=function(_0x5c2258,_0x2d9980){const _0x185b20=_0x3645f5;if(_0x2d9980)return moment(_0x5c2258)[_0x185b20('0x3')](_0x2d9980);else return _0x5c2258?!![]:![];};