Built motion from commit 14588770.|2.5.38
[motion2.git] / server / services / xdr / utils.js
index fcba2f7..9082e83 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x91f8=['debug','error','request','[utils][request]\x20name:%s','GetUser','internal','name','then','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','found','notfound','catch','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]','getVoiceQueueByName','GetVoiceQueue','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','addTime','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','format','diffTime','diff','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','http','../../config/logger','xdr','info','inspect'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x91f8,0x13f));var _0x891f=function(_0x128de4,_0x511592){_0x128de4=_0x128de4-0x0;var _0x167659=_0x91f8[_0x128de4];return _0x167659;};'use strict';var BPromise=require(_0x891f('0x0'));var jayson=require(_0x891f('0x1'));var moment=require(_0x891f('0x2'));var util=require(_0x891f('0x3'));var client=jayson[_0x891f('0x4')][_0x891f('0x5')]({'port':0x2329});var logger=require(_0x891f('0x6'))(_0x891f('0x7'));exports['info']=function(_0x381674,_0x61a1c0){logger[_0x891f('0x8')](_0x381674,_0x61a1c0?util[_0x891f('0x9')](_0x61a1c0,{'showHidden':![],'depth':null}):'');};exports['debug']=function(_0x1723af,_0x574b79){logger[_0x891f('0xa')](_0x1723af,_0x574b79?util[_0x891f('0x9')](_0x574b79,{'showHidden':![],'depth':null}):'');};exports[_0x891f('0xb')]=function(_0x5506b3,_0x51a692){logger[_0x891f('0xb')](_0x5506b3,_0x51a692?util[_0x891f('0x9')](_0x51a692,{'showHidden':![],'depth':null}):'');};exports['request']=function(_0x198a69,_0x1f4d97){return client[_0x891f('0xc')](_0x198a69,{'body':_0x1f4d97})['then'](function(_0xe033ac){logger[_0x891f('0xa')]('[utils][request]\x20name:%s',_0x198a69,_0xe033ac?util[_0x891f('0x9')](_0xe033ac,{'showHidden':![],'depth':null}):'');})['catch'](function(_0x2e50c0){logger[_0x891f('0xb')](_0x891f('0xd'),_0x198a69,_0x2e50c0?util[_0x891f('0x9')](_0x2e50c0,{'showHidden':![],'depth':null}):'');});};function getUser(_0x2dfdd0){return client[_0x891f('0xc')](_0x891f('0xe'),{'options':{'raw':!![],'attributes':['id',_0x891f('0xf'),_0x891f('0x10'),'interface'],'where':_0x2dfdd0,'limit':0x1}})[_0x891f('0x11')](function(_0x23f6cc){logger[_0x891f('0xa')](_0x891f('0x12'),JSON[_0x891f('0x13')](_0x2dfdd0),_0x23f6cc?util[_0x891f('0x9')](_0x23f6cc,{'showHidden':![],'depth':null}):'');return _0x23f6cc[_0x891f('0x14')][_0x891f('0x15')]?_0x23f6cc[_0x891f('0x14')][0x0]:null;});}exports[_0x891f('0x16')]=function(_0x4cb3e1){return new BPromise(function(_0x21b1ff,_0x2739c8){if(_0x4cb3e1){return getUser({'internal':_0x4cb3e1})[_0x891f('0x11')](function(_0xa6d5e0){logger[_0x891f('0x8')]('[utils][getUserByInternal]\x20internal:%s\x20%s',_0x4cb3e1,_0xa6d5e0?_0x891f('0x17'):_0x891f('0x18'));return _0x21b1ff(_0xa6d5e0);})[_0x891f('0x19')](function(_0x329d9b){logger[_0x891f('0xb')](_0x891f('0x1a'),_0x329d9b?util[_0x891f('0x9')](_0x329d9b,{'showHidden':![],'depth':null}):'');return _0x21b1ff(null);});}return _0x21b1ff(null);});};exports[_0x891f('0x1b')]=function(_0x4bfbd0){return new BPromise(function(_0x2ce130,_0x1ef9bf){if(_0x4bfbd0){return getUser({'interface':_0x4bfbd0})[_0x891f('0x11')](function(_0x798f0b){logger[_0x891f('0x8')]('[utils][getUserByInterface]\x20interface:%s\x20%s',_0x4bfbd0,_0x798f0b?'found':_0x891f('0x18'));return _0x2ce130(_0x798f0b);})[_0x891f('0x19')](function(_0x5f0e90){logger[_0x891f('0xb')](_0x891f('0x1c'),_0x5f0e90?util['inspect'](_0x5f0e90,{'showHidden':![],'depth':null}):'');return _0x2ce130(null);});}return _0x2ce130(null);});};exports[_0x891f('0x1d')]=function(_0x5c21a0){return new BPromise(function(_0xc518d1,_0x288f87){if(_0x5c21a0){return getUser({'name':_0x5c21a0})[_0x891f('0x11')](function(_0x1734bb){logger[_0x891f('0x8')]('[utils][getUserByName]\x20name:%s\x20%s',_0x5c21a0,_0x1734bb?_0x891f('0x17'):_0x891f('0x18'));return _0xc518d1(_0x1734bb);})[_0x891f('0x19')](function(_0x536418){logger[_0x891f('0xb')](_0x891f('0x1e'),_0x536418?util[_0x891f('0x9')](_0x536418,{'showHidden':![],'depth':null}):'');return _0xc518d1(null);});}return _0xc518d1(null);});};exports[_0x891f('0x1f')]=function(_0x2ebd84){return new BPromise(function(_0x5d4179,_0x1154cc){if(_0x2ebd84){return client['request'](_0x891f('0x20'),{'options':{'raw':!![],'attributes':['id',_0x891f('0x10'),'type','acw',_0x891f('0x21')],'where':{'name':_0x2ebd84},'limit':0x1}})[_0x891f('0x11')](function(_0x4dce22){logger['debug'](_0x891f('0x22'),_0x2ebd84,_0x4dce22?util[_0x891f('0x9')](_0x4dce22,{'showHidden':![],'depth':null}):'');logger['info'](_0x891f('0x23'),_0x2ebd84,_0x4dce22?_0x891f('0x17'):'notfound');return _0x5d4179(_0x4dce22[_0x891f('0x14')][_0x891f('0x15')]?_0x4dce22[_0x891f('0x14')][0x0]:null);})[_0x891f('0x19')](function(_0x31a144){logger[_0x891f('0xb')]('[utils][getVoiceQueueByName]',_0x31a144?util[_0x891f('0x9')](_0x31a144,{'showHidden':![],'depth':null}):'');return _0x5d4179(null);});}return _0x5d4179(null);});};exports[_0x891f('0x24')]=function(_0x4c72a7,_0x1bfa41){return moment(_0x4c72a7)['add'](_0x1bfa41,_0x891f('0x25'))['format'](_0x891f('0x26'));};exports[_0x891f('0x27')]=function(_0x24710e,_0x205e5a){return moment(_0x24710e)['subtract'](_0x205e5a,_0x891f('0x25'))[_0x891f('0x28')](_0x891f('0x26'));};exports[_0x891f('0x29')]=function(_0x4724a6,_0x4ed369){return moment(_0x4724a6)[_0x891f('0x2a')](moment(_0x4ed369),_0x891f('0x25'));};exports[_0x891f('0x2b')]=function(_0x1595d6,_0x5ca57e){return parseInt(_0x1595d6,0xa)+parseInt(_0x5ca57e,0xa);};exports[_0x891f('0x2c')]=function(){return moment()[_0x891f('0x28')](_0x891f('0x26'));};exports[_0x891f('0x2d')]=function(_0x10b0fe,_0x4a11da){if(_0x4a11da){return moment(_0x10b0fe)['isAfter'](_0x4a11da);}return!![];};exports[_0x891f('0x2e')]=function(_0x40cd3e,_0x1b423f){if(_0x1b423f){return moment(_0x40cd3e)[_0x891f('0x2e')](_0x1b423f);}else if(_0x40cd3e){return!![];}return![];};
\ No newline at end of file
+var _0x6397=['inspect','debug','error','then','[utils][request]\x20name:%s','catch','GetUser','internal','name','interface','[utils][getUser]\x20where:%s','stringify','result','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]\x20name:%s\x20%s','request','GetVoiceQueue','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','addTime','add','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','format','diffTime','sumTime','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','http','../../config/logger','xdr','info'];(function(_0x1b6ef2,_0xc3b63f){var _0x4f4fbe=function(_0x19d8c6){while(--_0x19d8c6){_0x1b6ef2['push'](_0x1b6ef2['shift']());}};_0x4f4fbe(++_0xc3b63f);}(_0x6397,0xbf));var _0x7639=function(_0x9c6c1c,_0x21ead9){_0x9c6c1c=_0x9c6c1c-0x0;var _0x594c42=_0x6397[_0x9c6c1c];return _0x594c42;};'use strict';var BPromise=require(_0x7639('0x0'));var jayson=require(_0x7639('0x1'));var moment=require(_0x7639('0x2'));var util=require(_0x7639('0x3'));var client=jayson[_0x7639('0x4')][_0x7639('0x5')]({'port':0x2329});var logger=require(_0x7639('0x6'))(_0x7639('0x7'));exports['info']=function(_0x136de2,_0x50916a){logger[_0x7639('0x8')](_0x136de2,_0x50916a?util[_0x7639('0x9')](_0x50916a,{'showHidden':![],'depth':null}):'');};exports[_0x7639('0xa')]=function(_0x1cba31,_0x598f27){logger[_0x7639('0xa')](_0x1cba31,_0x598f27?util[_0x7639('0x9')](_0x598f27,{'showHidden':![],'depth':null}):'');};exports['error']=function(_0xc0db52,_0x24132b){logger[_0x7639('0xb')](_0xc0db52,_0x24132b?util['inspect'](_0x24132b,{'showHidden':![],'depth':null}):'');};exports['request']=function(_0xd58a81,_0x147ac4){return client['request'](_0xd58a81,{'body':_0x147ac4})[_0x7639('0xc')](function(_0x6ce83e){logger[_0x7639('0xa')](_0x7639('0xd'),_0xd58a81,_0x6ce83e?util[_0x7639('0x9')](_0x6ce83e,{'showHidden':![],'depth':null}):'');})[_0x7639('0xe')](function(_0x33354f){logger['error'](_0x7639('0xd'),_0xd58a81,_0x33354f?util['inspect'](_0x33354f,{'showHidden':![],'depth':null}):'');});};function getUser(_0x9802ea){return client['request'](_0x7639('0xf'),{'options':{'raw':!![],'attributes':['id',_0x7639('0x10'),_0x7639('0x11'),_0x7639('0x12')],'where':_0x9802ea,'limit':0x1}})['then'](function(_0x3462fb){logger['debug'](_0x7639('0x13'),JSON[_0x7639('0x14')](_0x9802ea),_0x3462fb?util[_0x7639('0x9')](_0x3462fb,{'showHidden':![],'depth':null}):'');return _0x3462fb[_0x7639('0x15')]['length']?_0x3462fb['result'][0x0]:null;});}exports[_0x7639('0x16')]=function(_0xe3e357){return new BPromise(function(_0x204745,_0x378615){if(_0xe3e357){return getUser({'internal':_0xe3e357})[_0x7639('0xc')](function(_0x3c0db5){logger[_0x7639('0x8')](_0x7639('0x17'),_0xe3e357,_0x3c0db5?_0x7639('0x18'):_0x7639('0x19'));return _0x204745(_0x3c0db5);})[_0x7639('0xe')](function(_0x3ecedc){logger[_0x7639('0xb')](_0x7639('0x1a'),_0x3ecedc?util[_0x7639('0x9')](_0x3ecedc,{'showHidden':![],'depth':null}):'');return _0x204745(null);});}return _0x204745(null);});};exports['getUserByInterface']=function(_0x4bc2d9){return new BPromise(function(_0x3d67d6,_0x3dfebb){if(_0x4bc2d9){return getUser({'interface':_0x4bc2d9})[_0x7639('0xc')](function(_0x43a527){logger[_0x7639('0x8')](_0x7639('0x1b'),_0x4bc2d9,_0x43a527?_0x7639('0x18'):_0x7639('0x19'));return _0x3d67d6(_0x43a527);})['catch'](function(_0x4ee609){logger['error'](_0x7639('0x1c'),_0x4ee609?util[_0x7639('0x9')](_0x4ee609,{'showHidden':![],'depth':null}):'');return _0x3d67d6(null);});}return _0x3d67d6(null);});};exports[_0x7639('0x1d')]=function(_0x40da1a){return new BPromise(function(_0x555e4a,_0x3c54dd){if(_0x40da1a){return getUser({'name':_0x40da1a})[_0x7639('0xc')](function(_0x36c860){logger[_0x7639('0x8')](_0x7639('0x1e'),_0x40da1a,_0x36c860?_0x7639('0x18'):'notfound');return _0x555e4a(_0x36c860);})['catch'](function(_0x1cf7e5){logger[_0x7639('0xb')]('[utils][getUserByName]',_0x1cf7e5?util['inspect'](_0x1cf7e5,{'showHidden':![],'depth':null}):'');return _0x555e4a(null);});}return _0x555e4a(null);});};exports['getVoiceQueueByName']=function(_0xe51772){return new BPromise(function(_0x5e5924,_0x25d2d4){if(_0xe51772){return client[_0x7639('0x1f')](_0x7639('0x20'),{'options':{'raw':!![],'attributes':['id',_0x7639('0x11'),_0x7639('0x21'),_0x7639('0x22'),_0x7639('0x23')],'where':{'name':_0xe51772},'limit':0x1}})[_0x7639('0xc')](function(_0x3b2726){logger[_0x7639('0xa')](_0x7639('0x24'),_0xe51772,_0x3b2726?util['inspect'](_0x3b2726,{'showHidden':![],'depth':null}):'');logger['info'](_0x7639('0x25'),_0xe51772,_0x3b2726?'found':_0x7639('0x19'));return _0x5e5924(_0x3b2726[_0x7639('0x15')]['length']?_0x3b2726[_0x7639('0x15')][0x0]:null);})[_0x7639('0xe')](function(_0x2c6eb0){logger[_0x7639('0xb')](_0x7639('0x26'),_0x2c6eb0?util['inspect'](_0x2c6eb0,{'showHidden':![],'depth':null}):'');return _0x5e5924(null);});}return _0x5e5924(null);});};exports[_0x7639('0x27')]=function(_0x2fde8d,_0x2eb083){return moment(_0x2fde8d)[_0x7639('0x28')](_0x2eb083,_0x7639('0x29'))['format'](_0x7639('0x2a'));};exports[_0x7639('0x2b')]=function(_0x159da2,_0x1f4ad7){return moment(_0x159da2)[_0x7639('0x2c')](_0x1f4ad7,'seconds')[_0x7639('0x2d')](_0x7639('0x2a'));};exports[_0x7639('0x2e')]=function(_0x321798,_0x25746a){return moment(_0x321798)['diff'](moment(_0x25746a),_0x7639('0x29'));};exports[_0x7639('0x2f')]=function(_0x2f2fb9,_0x4cf3b1){return parseInt(_0x2f2fb9,0xa)+parseInt(_0x4cf3b1,0xa);};exports['now']=function(){return moment()['format']('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x7639('0x30')]=function(_0x2a1cd8,_0x1eb8e2){if(_0x1eb8e2){return moment(_0x2a1cd8)[_0x7639('0x30')](_0x1eb8e2);}return!![];};exports[_0x7639('0x31')]=function(_0x37d6c5,_0x255cbe){if(_0x255cbe){return moment(_0x37d6c5)[_0x7639('0x31')](_0x255cbe);}else if(_0x37d6c5){return!![];}return![];};
\ No newline at end of file