Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / services / xdr / utils.js
index 861ab74..05694e6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x09f3=['FOUND','NOTFOUND','length','getUserByInternal','catch','stack','getUserByInterface','getUserByName','getVoiceQueueByName','GetVoiceQueue','acwTimeout','GETVOICEQUEUEBYNAME|','addTime','add','YYYY-MM-DD\x20HH:mm:ss','subtractTime','seconds','format','diff','isAfter','isBefore','moment','bluebird','client','http','../../config/logger','xdr','info','debug','stringify','error','request','then','internal','interface','GETUSER|','result'];(function(_0x528fd9,_0x4de3c4){var _0x59b2aa=function(_0x958bda){while(--_0x958bda){_0x528fd9['push'](_0x528fd9['shift']());}};_0x59b2aa(++_0x4de3c4);}(_0x09f3,0x84));var _0x309f=function(_0x6ae66b,_0x3ba914){_0x6ae66b=_0x6ae66b-0x0;var _0x465cef=_0x09f3[_0x6ae66b];return _0x465cef;};'use strict';var jayson=require('jayson/promise');var moment=require(_0x309f('0x0'));var BPromise=require(_0x309f('0x1'));var client=jayson[_0x309f('0x2')][_0x309f('0x3')]({'port':0x2329});var logger=require(_0x309f('0x4'))(_0x309f('0x5'));exports[_0x309f('0x6')]=function(_0x440e79){logger['info'](_0x440e79);};exports[_0x309f('0x7')]=function(_0x15eccb){logger[_0x309f('0x7')](JSON[_0x309f('0x8')](_0x15eccb));};exports[_0x309f('0x9')]=function(_0x3f6605){logger['error'](_0x3f6605['stack']);};exports[_0x309f('0xa')]=function(_0x527ecc,_0x4b069a){return client[_0x309f('0xa')](_0x527ecc,{'body':_0x4b069a})[_0x309f('0xb')](function(_0x510f41){logger[_0x309f('0x7')](JSON[_0x309f('0x8')](_0x510f41));})['catch'](function(_0x1ca822){logger['error'](_0x1ca822['stack']);});};function getUser(_0x24bfa6){return client[_0x309f('0xa')]('GetUser',{'options':{'raw':!![],'attributes':['id',_0x309f('0xc'),'name',_0x309f('0xd')],'where':_0x24bfa6,'limit':0x1}})['then'](function(_0x47cc5d){logger['info'](_0x309f('0xe')+JSON[_0x309f('0x8')](_0x24bfa6)+'|'+(_0x47cc5d[_0x309f('0xf')]['length']?_0x309f('0x10'):_0x309f('0x11')));return _0x47cc5d[_0x309f('0xf')][_0x309f('0x12')]?_0x47cc5d['result'][0x0]:null;});}exports[_0x309f('0x13')]=function(_0x2921f1){return new BPromise(function(_0x2470ef,_0x250df0){if(_0x2921f1){return getUser({'internal':_0x2921f1})[_0x309f('0xb')](function(_0x4eb6ea){return _0x2470ef(_0x4eb6ea);})[_0x309f('0x14')](function(_0x2570bd){logger[_0x309f('0x9')](_0x2570bd[_0x309f('0x15')]);return _0x2470ef(null);});}else{return _0x2470ef(null);}});};exports[_0x309f('0x16')]=function(_0xdba119){return new BPromise(function(_0x13a199,_0x233f87){if(_0xdba119){return getUser({'interface':_0xdba119})[_0x309f('0xb')](function(_0x243b3c){return _0x13a199(_0x243b3c);})[_0x309f('0x14')](function(_0x301ae4){logger[_0x309f('0x9')](_0x301ae4[_0x309f('0x15')]);return _0x13a199(null);});}else{return _0x13a199(null);}});};exports[_0x309f('0x17')]=function(_0x15f5e4){return new BPromise(function(_0x165787,_0x29214a){if(_0x15f5e4){return getUser({'name':_0x15f5e4})[_0x309f('0xb')](function(_0x3f7adc){return _0x165787(_0x3f7adc);})[_0x309f('0x14')](function(_0x13eef3){logger['error'](_0x13eef3[_0x309f('0x15')]);return _0x165787(null);});}else{return _0x165787(null);}});};exports[_0x309f('0x18')]=function(_0x39e71a){return new BPromise(function(_0x114e3f,_0x5ec308){if(_0x39e71a){return client['request'](_0x309f('0x19'),{'options':{'raw':!![],'attributes':['id','name','type','acw',_0x309f('0x1a')],'where':{'name':_0x39e71a},'limit':0x1}})[_0x309f('0xb')](function(_0x31b538){logger[_0x309f('0x6')](_0x309f('0x1b')+_0x39e71a+'|'+(_0x31b538['result'][_0x309f('0x12')]?_0x309f('0x10'):_0x309f('0x11')));return _0x114e3f(_0x31b538[_0x309f('0xf')][_0x309f('0x12')]?_0x31b538[_0x309f('0xf')][0x0]:null);})['catch'](function(_0x29745c){logger[_0x309f('0x9')](_0x29745c[_0x309f('0x15')]);return _0x114e3f(null);});}else{return _0x114e3f(null);}});};exports[_0x309f('0x1c')]=function(_0x4338be,_0x260b4a){return moment(_0x4338be)[_0x309f('0x1d')](_0x260b4a,'seconds')['format'](_0x309f('0x1e'));};exports[_0x309f('0x1f')]=function(_0x3b9da1,_0x55a2d9){return moment(_0x3b9da1)['subtract'](_0x55a2d9,_0x309f('0x20'))[_0x309f('0x21')](_0x309f('0x1e'));};exports['diffTime']=function(_0x28f562,_0xb20c77){return moment(_0x28f562)[_0x309f('0x22')](moment(_0xb20c77),'seconds');};exports['sumTime']=function(_0x26ed13,_0x22607d){return parseInt(_0x26ed13,0xa)+parseInt(_0x22607d,0xa);};exports['now']=function(){return moment()[_0x309f('0x21')](_0x309f('0x1e'));};exports[_0x309f('0x23')]=function(_0xd81fc0,_0x5d774e){if(_0x5d774e){return moment(_0xd81fc0)['isAfter'](_0x5d774e);}else{return!![];}};exports['isBefore']=function(_0x4e5b42,_0x36c545){if(_0x36c545){return moment(_0x4e5b42)[_0x309f('0x24')](_0x36c545);}else if(_0x4e5b42){return!![];}else{return![];}};
\ No newline at end of file
+var _0xbb35=['seconds','format','subtract','YYYY-MM-DD\x20HH:mm:ss','diffTime','diff','sumTime','now','isAfter','isBefore','jayson/promise','moment','bluebird','client','http','../../config/logger','xdr','info','debug','stringify','error','stack','request','then','catch','GetUser','internal','name','interface','GETUSER|','result','length','getUserByInternal','getUserByInterface','GetVoiceQueue','type','acw','acwTimeout','GETVOICEQUEUEBYNAME|','FOUND','NOTFOUND','addTime','add'];(function(_0x4f0416,_0x4853a3){var _0xe7c8af=function(_0xaaaf71){while(--_0xaaaf71){_0x4f0416['push'](_0x4f0416['shift']());}};_0xe7c8af(++_0x4853a3);}(_0xbb35,0x1b8));var _0x5bb3=function(_0x1f0067,_0xbf5609){_0x1f0067=_0x1f0067-0x0;var _0x3d0dac=_0xbb35[_0x1f0067];return _0x3d0dac;};'use strict';var jayson=require(_0x5bb3('0x0'));var moment=require(_0x5bb3('0x1'));var BPromise=require(_0x5bb3('0x2'));var client=jayson[_0x5bb3('0x3')][_0x5bb3('0x4')]({'port':0x2329});var logger=require(_0x5bb3('0x5'))(_0x5bb3('0x6'));exports['info']=function(_0x55d7f0){logger[_0x5bb3('0x7')](_0x55d7f0);};exports['debug']=function(_0x599acc){logger[_0x5bb3('0x8')](JSON[_0x5bb3('0x9')](_0x599acc));};exports[_0x5bb3('0xa')]=function(_0x48db0a){logger[_0x5bb3('0xa')](_0x48db0a[_0x5bb3('0xb')]);};exports[_0x5bb3('0xc')]=function(_0x528c5c,_0x5cff76){return client[_0x5bb3('0xc')](_0x528c5c,{'body':_0x5cff76})[_0x5bb3('0xd')](function(_0x53575d){logger[_0x5bb3('0x8')](JSON[_0x5bb3('0x9')](_0x53575d));})[_0x5bb3('0xe')](function(_0x15b4c5){logger[_0x5bb3('0xa')](_0x15b4c5[_0x5bb3('0xb')]);});};function getUser(_0x59f0d1){return client[_0x5bb3('0xc')](_0x5bb3('0xf'),{'options':{'raw':!![],'attributes':['id',_0x5bb3('0x10'),_0x5bb3('0x11'),_0x5bb3('0x12')],'where':_0x59f0d1,'limit':0x1}})[_0x5bb3('0xd')](function(_0x26c961){logger[_0x5bb3('0x7')](_0x5bb3('0x13')+JSON[_0x5bb3('0x9')](_0x59f0d1)+'|'+(_0x26c961[_0x5bb3('0x14')][_0x5bb3('0x15')]?'FOUND':'NOTFOUND'));return _0x26c961['result'][_0x5bb3('0x15')]?_0x26c961[_0x5bb3('0x14')][0x0]:null;});}exports[_0x5bb3('0x16')]=function(_0x2d0776){return new BPromise(function(_0x263136,_0x8acb7d){if(_0x2d0776){return getUser({'internal':_0x2d0776})['then'](function(_0x529cf0){return _0x263136(_0x529cf0);})['catch'](function(_0x552cdc){logger['error'](_0x552cdc['stack']);return _0x263136(null);});}else{return _0x263136(null);}});};exports[_0x5bb3('0x17')]=function(_0x2d1540){return new BPromise(function(_0x5e5fdf,_0x561b5a){if(_0x2d1540){return getUser({'interface':_0x2d1540})[_0x5bb3('0xd')](function(_0x16311b){return _0x5e5fdf(_0x16311b);})['catch'](function(_0x4b1afb){logger[_0x5bb3('0xa')](_0x4b1afb[_0x5bb3('0xb')]);return _0x5e5fdf(null);});}else{return _0x5e5fdf(null);}});};exports['getUserByName']=function(_0x2757fe){return new BPromise(function(_0x34624f,_0x4f9813){if(_0x2757fe){return getUser({'name':_0x2757fe})[_0x5bb3('0xd')](function(_0x43a81e){return _0x34624f(_0x43a81e);})[_0x5bb3('0xe')](function(_0xe05e36){logger[_0x5bb3('0xa')](_0xe05e36['stack']);return _0x34624f(null);});}else{return _0x34624f(null);}});};exports['getVoiceQueueByName']=function(_0x1f6e21){return new BPromise(function(_0x5018a2,_0x5ac05e){if(_0x1f6e21){return client[_0x5bb3('0xc')](_0x5bb3('0x18'),{'options':{'raw':!![],'attributes':['id',_0x5bb3('0x11'),_0x5bb3('0x19'),_0x5bb3('0x1a'),_0x5bb3('0x1b')],'where':{'name':_0x1f6e21},'limit':0x1}})[_0x5bb3('0xd')](function(_0xd5d6bc){logger[_0x5bb3('0x7')](_0x5bb3('0x1c')+_0x1f6e21+'|'+(_0xd5d6bc[_0x5bb3('0x14')][_0x5bb3('0x15')]?_0x5bb3('0x1d'):_0x5bb3('0x1e')));return _0x5018a2(_0xd5d6bc[_0x5bb3('0x14')]['length']?_0xd5d6bc[_0x5bb3('0x14')][0x0]:null);})[_0x5bb3('0xe')](function(_0xf7b6b1){logger['error'](_0xf7b6b1[_0x5bb3('0xb')]);return _0x5018a2(null);});}else{return _0x5018a2(null);}});};exports[_0x5bb3('0x1f')]=function(_0x5919bf,_0x5de85b){return moment(_0x5919bf)[_0x5bb3('0x20')](_0x5de85b,_0x5bb3('0x21'))[_0x5bb3('0x22')]('YYYY-MM-DD\x20HH:mm:ss');};exports['subtractTime']=function(_0x74dded,_0x1e44ef){return moment(_0x74dded)[_0x5bb3('0x23')](_0x1e44ef,_0x5bb3('0x21'))['format'](_0x5bb3('0x24'));};exports[_0x5bb3('0x25')]=function(_0x18867a,_0x4a6a5e){return moment(_0x18867a)[_0x5bb3('0x26')](moment(_0x4a6a5e),'seconds');};exports[_0x5bb3('0x27')]=function(_0x346923,_0x432107){return parseInt(_0x346923,0xa)+parseInt(_0x432107,0xa);};exports[_0x5bb3('0x28')]=function(){return moment()[_0x5bb3('0x22')](_0x5bb3('0x24'));};exports['isAfter']=function(_0x18fcb7,_0x4fb68a){if(_0x4fb68a){return moment(_0x18fcb7)[_0x5bb3('0x29')](_0x4fb68a);}else{return!![];}};exports[_0x5bb3('0x2a')]=function(_0x32a9ca,_0x26abd0){if(_0x26abd0){return moment(_0x32a9ca)[_0x5bb3('0x2a')](_0x26abd0);}else if(_0x32a9ca){return!![];}else{return![];}};
\ No newline at end of file