43fbaf5cd72494411e5455cda874d9edae14d2be
[motion-next.git] / server / services / xdr / utils.js
1 const a1230_0x4eda=['stringify','seconds','debug','moment','stack','YYYY-MM-DD\x20HH:mm:ss','add','name','client','diff','xdr','sumTime','FOUND','acw','getUserByName','isBefore','info','addTime','getVoiceQueueByName','GetUser','GetVoiceQueue','error','request','type','subtractTime','result','GETVOICEQUEUEBYNAME|','then','getUserByInterface','../../config/logger','catch','NOTFOUND','format','subtract','interface','GETUSER|','isAfter','http','length'];(function(_0x4c0e4f,_0x4eda34){const _0x1c660c=function(_0x369b7b){while(--_0x369b7b){_0x4c0e4f['push'](_0x4c0e4f['shift']());}};_0x1c660c(++_0x4eda34);}(a1230_0x4eda,0xb4));const a1230_0x1c66=function(_0x4c0e4f,_0x4eda34){_0x4c0e4f=_0x4c0e4f-0x0;let _0x1c660c=a1230_0x4eda[_0x4c0e4f];return _0x1c660c;};const _0x5a27ae=a1230_0x1c66;'use strict';const jayson=require('jayson/promise'),moment=require(_0x5a27ae('0x12')),client=jayson[_0x5a27ae('0x17')][_0x5a27ae('0xd')]({'port':0x2329}),logger=require(_0x5a27ae('0x5'))(_0x5a27ae('0x19'));exports[_0x5a27ae('0x1f')]=function(_0x369b7b){const _0x59e286=_0x5a27ae;logger[_0x59e286('0x1f')](_0x369b7b);},exports[_0x5a27ae('0x11')]=function(_0x51ac87){const _0x435fba=_0x5a27ae;logger[_0x435fba('0x11')](JSON[_0x435fba('0xf')](_0x51ac87));},exports['error']=function(_0x3d1274){const _0x99a490=_0x5a27ae;logger[_0x99a490('0x24')](_0x3d1274[_0x99a490('0x13')]);},exports[_0x5a27ae('0x25')]=function(_0x3b4579,_0x6aefaa){const _0x1a1246=_0x5a27ae;return client[_0x1a1246('0x25')](_0x3b4579,{'body':_0x6aefaa})['then'](function(_0x48728a){const _0x4215d0=_0x1a1246;logger[_0x4215d0('0x11')](JSON[_0x4215d0('0xf')](_0x48728a));})['catch'](function(_0x16319a){const _0xe830b2=_0x1a1246;logger[_0xe830b2('0x24')](_0x16319a[_0xe830b2('0x13')]);});};function getUser(_0x1981e5){const _0x41f57a=_0x5a27ae;return client['request'](_0x41f57a('0x22'),{'options':{'raw':!![],'attributes':['id','internal',_0x41f57a('0x16'),_0x41f57a('0xa')],'where':_0x1981e5,'limit':0x1}})[_0x41f57a('0x3')](function(_0x265f4e){const _0x4f3b74=_0x41f57a;return logger['info'](_0x4f3b74('0xb')+JSON[_0x4f3b74('0xf')](_0x1981e5)+'|'+(_0x265f4e['result']['length']?_0x4f3b74('0x1b'):_0x4f3b74('0x7'))),_0x265f4e[_0x4f3b74('0x1')][_0x4f3b74('0xe')]?_0x265f4e['result'][0x0]:null;});}exports['getUserByInternal']=function(_0x429bd8){return new Promise(function(_0x7f06a4){const _0x4f985d=a1230_0x1c66;return _0x429bd8?getUser({'internal':_0x429bd8})[_0x4f985d('0x3')](function(_0x7be28d){return _0x7f06a4(_0x7be28d);})[_0x4f985d('0x6')](function(_0x2a748e){const _0x44e0de=_0x4f985d;return logger[_0x44e0de('0x24')](_0x2a748e['stack']),_0x7f06a4(null);}):_0x7f06a4(null);});},exports[_0x5a27ae('0x4')]=function(_0x224f76){return new Promise(function(_0x27c2a0){const _0x59cd4a=a1230_0x1c66;return _0x224f76?getUser({'interface':_0x224f76})['then'](function(_0x2eb10a){return _0x27c2a0(_0x2eb10a);})[_0x59cd4a('0x6')](function(_0xbc13bd){const _0x15952b=_0x59cd4a;return logger[_0x15952b('0x24')](_0xbc13bd[_0x15952b('0x13')]),_0x27c2a0(null);}):_0x27c2a0(null);});},exports[_0x5a27ae('0x1d')]=function(_0x3d8d30){return new Promise(function(_0x47547c){const _0x32693a=a1230_0x1c66;return _0x3d8d30?getUser({'name':_0x3d8d30})[_0x32693a('0x3')](function(_0x45cdb5){return _0x47547c(_0x45cdb5);})[_0x32693a('0x6')](function(_0x440bea){const _0xd4932b=_0x32693a;return logger[_0xd4932b('0x24')](_0x440bea['stack']),_0x47547c(null);}):_0x47547c(null);});},exports[_0x5a27ae('0x21')]=function(_0x42ffd3){return new Promise(function(_0x2bdcb3){const _0x455c6f=a1230_0x1c66;return _0x42ffd3?client[_0x455c6f('0x25')](_0x455c6f('0x23'),{'options':{'raw':!![],'attributes':['id',_0x455c6f('0x16'),_0x455c6f('0x26'),_0x455c6f('0x1c'),'acwTimeout'],'where':{'name':_0x42ffd3},'limit':0x1}})[_0x455c6f('0x3')](function(_0x15f902){const _0x4026c3=_0x455c6f;return logger[_0x4026c3('0x1f')](_0x4026c3('0x2')+_0x42ffd3+'|'+(_0x15f902[_0x4026c3('0x1')][_0x4026c3('0xe')]?_0x4026c3('0x1b'):'NOTFOUND')),_0x2bdcb3(_0x15f902['result'][_0x4026c3('0xe')]?_0x15f902[_0x4026c3('0x1')][0x0]:null);})['catch'](function(_0x3514df){const _0x402bf8=_0x455c6f;return logger[_0x402bf8('0x24')](_0x3514df[_0x402bf8('0x13')]),_0x2bdcb3(null);}):_0x2bdcb3(null);});},exports[_0x5a27ae('0x20')]=function(_0x5db36e,_0x4806d3){const _0x3282a3=_0x5a27ae;return moment(_0x5db36e)[_0x3282a3('0x15')](_0x4806d3,_0x3282a3('0x10'))[_0x3282a3('0x8')](_0x3282a3('0x14'));},exports[_0x5a27ae('0x0')]=function(_0x3b7ebb,_0x643fc3){const _0x1aa752=_0x5a27ae;return moment(_0x3b7ebb)[_0x1aa752('0x9')](_0x643fc3,_0x1aa752('0x10'))[_0x1aa752('0x8')](_0x1aa752('0x14'));},exports['diffTime']=function(_0x4de8f0,_0x57fca5){const _0x3be68c=_0x5a27ae;return moment(_0x4de8f0)[_0x3be68c('0x18')](moment(_0x57fca5),_0x3be68c('0x10'));},exports[_0x5a27ae('0x1a')]=function(_0x37030b,_0x10ddc2){return parseInt(_0x37030b,0xa)+parseInt(_0x10ddc2,0xa);},exports['now']=function(){const _0x2ed889=_0x5a27ae;return moment()[_0x2ed889('0x8')](_0x2ed889('0x14'));},exports['isAfter']=function(_0x1c698d,_0x2f5a59){const _0x618988=_0x5a27ae;return _0x2f5a59?moment(_0x1c698d)[_0x618988('0xc')](_0x2f5a59):!![];},exports[_0x5a27ae('0x1e')]=function(_0x4d8234,_0x3fdf6c){const _0x2d5289=_0x5a27ae;if(_0x3fdf6c)return moment(_0x4d8234)[_0x2d5289('0x1e')](_0x3fdf6c);else return _0x4d8234?!![]:![];};