Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / services / xdr / utils.js
index b53857e..a3750fd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0f25=['diffTime','isAfter','isBefore','bluebird','jayson/promise','util','client','http','../../config/logger','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','GetUser','name','interface','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','[utils][getUserByInternal]','[utils][getUserByInterface]\x20interface:%s\x20%s','notfound','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]','type','acw','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]','addTime','add','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','format'];(function(_0x4005fe,_0x1fc3c1){var _0x50022d=function(_0x2ce718){while(--_0x2ce718){_0x4005fe['push'](_0x4005fe['shift']());}};_0x50022d(++_0x1fc3c1);}(_0x0f25,0xdf));var _0x50f2=function(_0x47579b,_0x4ea44e){_0x47579b=_0x47579b-0x0;var _0x4e47f5=_0x0f25[_0x47579b];return _0x4e47f5;};'use strict';var BPromise=require(_0x50f2('0x0'));var jayson=require(_0x50f2('0x1'));var moment=require('moment');var util=require(_0x50f2('0x2'));var client=jayson[_0x50f2('0x3')][_0x50f2('0x4')]({'port':0x2329});var logger=require(_0x50f2('0x5'))('xdr');exports['info']=function(_0x19e72e,_0x101e24){logger[_0x50f2('0x6')](_0x19e72e,_0x101e24?util[_0x50f2('0x7')](_0x101e24,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0x8')]=function(_0x379d0b,_0x19e3ce){logger[_0x50f2('0x8')](_0x379d0b,_0x19e3ce?util[_0x50f2('0x7')](_0x19e3ce,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0x9')]=function(_0x519b84,_0x58ce92){logger[_0x50f2('0x9')](_0x519b84,_0x58ce92?util[_0x50f2('0x7')](_0x58ce92,{'showHidden':![],'depth':null}):'');};exports[_0x50f2('0xa')]=function(_0x134bb4,_0xaca1fd){return client[_0x50f2('0xa')](_0x134bb4,{'body':_0xaca1fd})[_0x50f2('0xb')](function(_0x31cb73){logger[_0x50f2('0x8')](_0x50f2('0xc'),_0x134bb4,_0x31cb73?util[_0x50f2('0x7')](_0x31cb73,{'showHidden':![],'depth':null}):'');})[_0x50f2('0xd')](function(_0x2c513f){logger[_0x50f2('0x9')](_0x50f2('0xc'),_0x134bb4,_0x2c513f?util['inspect'](_0x2c513f,{'showHidden':![],'depth':null}):'');});};function getUser(_0x437fb7){return client[_0x50f2('0xa')](_0x50f2('0xe'),{'options':{'raw':!![],'attributes':['id','internal',_0x50f2('0xf'),_0x50f2('0x10')],'where':_0x437fb7,'limit':0x1}})['then'](function(_0x5c6c2b){logger['debug'](_0x50f2('0x11'),JSON[_0x50f2('0x12')](_0x437fb7),_0x5c6c2b?util[_0x50f2('0x7')](_0x5c6c2b,{'showHidden':![],'depth':null}):'');return _0x5c6c2b[_0x50f2('0x13')][_0x50f2('0x14')]?_0x5c6c2b[_0x50f2('0x13')][0x0]:null;});}exports[_0x50f2('0x15')]=function(_0xedbb5a){return new BPromise(function(_0x3caca9,_0x36a5f7){if(_0xedbb5a){return getUser({'internal':_0xedbb5a})['then'](function(_0x173ce6){logger[_0x50f2('0x6')](_0x50f2('0x16'),_0xedbb5a,_0x173ce6?_0x50f2('0x17'):'notfound');return _0x3caca9(_0x173ce6);})[_0x50f2('0xd')](function(_0x1779cb){logger['error'](_0x50f2('0x18'),_0x1779cb?util[_0x50f2('0x7')](_0x1779cb,{'showHidden':![],'depth':null}):'');return _0x3caca9(null);});}return _0x3caca9(null);});};exports['getUserByInterface']=function(_0x4b6eda){return new BPromise(function(_0x2592bd,_0x234703){if(_0x4b6eda){return getUser({'interface':_0x4b6eda})[_0x50f2('0xb')](function(_0x54a53d){logger['info'](_0x50f2('0x19'),_0x4b6eda,_0x54a53d?_0x50f2('0x17'):_0x50f2('0x1a'));return _0x2592bd(_0x54a53d);})['catch'](function(_0x5523bd){logger[_0x50f2('0x9')](_0x50f2('0x1b'),_0x5523bd?util[_0x50f2('0x7')](_0x5523bd,{'showHidden':![],'depth':null}):'');return _0x2592bd(null);});}return _0x2592bd(null);});};exports[_0x50f2('0x1c')]=function(_0x549f7f){return new BPromise(function(_0x4a4577,_0x4b26ad){if(_0x549f7f){return getUser({'name':_0x549f7f})[_0x50f2('0xb')](function(_0x13da77){logger[_0x50f2('0x6')]('[utils][getUserByName]\x20name:%s\x20%s',_0x549f7f,_0x13da77?'found':_0x50f2('0x1a'));return _0x4a4577(_0x13da77);})[_0x50f2('0xd')](function(_0x29ce54){logger[_0x50f2('0x9')](_0x50f2('0x1d'),_0x29ce54?util['inspect'](_0x29ce54,{'showHidden':![],'depth':null}):'');return _0x4a4577(null);});}return _0x4a4577(null);});};exports['getVoiceQueueByName']=function(_0xbb398c){return new BPromise(function(_0x5c6703,_0x24df1f){if(_0xbb398c){return client[_0x50f2('0xa')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0x50f2('0xf'),_0x50f2('0x1e'),_0x50f2('0x1f'),'acwTimeout'],'where':{'name':_0xbb398c},'limit':0x1}})[_0x50f2('0xb')](function(_0x55cf78){logger[_0x50f2('0x8')](_0x50f2('0x20'),_0xbb398c,_0x55cf78?util[_0x50f2('0x7')](_0x55cf78,{'showHidden':![],'depth':null}):'');logger[_0x50f2('0x6')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0xbb398c,_0x55cf78?_0x50f2('0x17'):_0x50f2('0x1a'));return _0x5c6703(_0x55cf78[_0x50f2('0x13')]['length']?_0x55cf78[_0x50f2('0x13')][0x0]:null);})[_0x50f2('0xd')](function(_0x4ba4c2){logger[_0x50f2('0x9')](_0x50f2('0x21'),_0x4ba4c2?util[_0x50f2('0x7')](_0x4ba4c2,{'showHidden':![],'depth':null}):'');return _0x5c6703(null);});}return _0x5c6703(null);});};exports[_0x50f2('0x22')]=function(_0x320807,_0x2e7e7e){return moment(_0x320807)[_0x50f2('0x23')](_0x2e7e7e,_0x50f2('0x24'))['format'](_0x50f2('0x25'));};exports[_0x50f2('0x26')]=function(_0x2801eb,_0xde6926){return moment(_0x2801eb)[_0x50f2('0x27')](_0xde6926,'seconds')[_0x50f2('0x28')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x50f2('0x29')]=function(_0x253d6b,_0x2dd13a){return moment(_0x253d6b)['diff'](moment(_0x2dd13a),_0x50f2('0x24'));};exports['sumTime']=function(_0x51b501,_0x5ed302){return parseInt(_0x51b501,0xa)+parseInt(_0x5ed302,0xa);};exports['now']=function(){return moment()[_0x50f2('0x28')](_0x50f2('0x25'));};exports[_0x50f2('0x2a')]=function(_0x31b6ff,_0x4b8eb4){if(_0x4b8eb4){return moment(_0x31b6ff)['isAfter'](_0x4b8eb4);}return!![];};exports[_0x50f2('0x2b')]=function(_0x200004,_0x31bd7a){if(_0x31bd7a){return moment(_0x200004)['isBefore'](_0x31bd7a);}else if(_0x200004){return!![];}return![];};
\ No newline at end of file
+var _0x22dd=['[utils][getUserByInternal]','[utils][getUserByInterface]','getUserByName','GetVoiceQueue','type','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','addTime','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtractTime','subtract','diff','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','util','client','../../config/logger','info','inspect','error','request','then','debug','[utils][request]\x20name:%s','catch','internal','name','interface','[utils][getUser]\x20where:%s','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound'];(function(_0x4ebe88,_0x10b8a8){var _0x3dbfae=function(_0x5adc06){while(--_0x5adc06){_0x4ebe88['push'](_0x4ebe88['shift']());}};_0x3dbfae(++_0x10b8a8);}(_0x22dd,0x98));var _0xd22d=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x22dd[_0x3dd15e];return _0x231fd0;};'use strict';var BPromise=require(_0xd22d('0x0'));var jayson=require(_0xd22d('0x1'));var moment=require(_0xd22d('0x2'));var util=require(_0xd22d('0x3'));var client=jayson[_0xd22d('0x4')]['http']({'port':0x2329});var logger=require(_0xd22d('0x5'))('xdr');exports[_0xd22d('0x6')]=function(_0x1b38af,_0x3d6c6f){logger['info'](_0x1b38af,_0x3d6c6f?util['inspect'](_0x3d6c6f,{'showHidden':![],'depth':null}):'');};exports['debug']=function(_0x158b68,_0xdc40fb){logger['debug'](_0x158b68,_0xdc40fb?util[_0xd22d('0x7')](_0xdc40fb,{'showHidden':![],'depth':null}):'');};exports[_0xd22d('0x8')]=function(_0xd6c64b,_0x1bcf34){logger[_0xd22d('0x8')](_0xd6c64b,_0x1bcf34?util['inspect'](_0x1bcf34,{'showHidden':![],'depth':null}):'');};exports[_0xd22d('0x9')]=function(_0x58ccaf,_0x45dd73){return client[_0xd22d('0x9')](_0x58ccaf,{'body':_0x45dd73})[_0xd22d('0xa')](function(_0x1e68fd){logger[_0xd22d('0xb')](_0xd22d('0xc'),_0x58ccaf,_0x1e68fd?util[_0xd22d('0x7')](_0x1e68fd,{'showHidden':![],'depth':null}):'');})[_0xd22d('0xd')](function(_0x5cc7aa){logger[_0xd22d('0x8')](_0xd22d('0xc'),_0x58ccaf,_0x5cc7aa?util[_0xd22d('0x7')](_0x5cc7aa,{'showHidden':![],'depth':null}):'');});};function getUser(_0x46b9a2){return client[_0xd22d('0x9')]('GetUser',{'options':{'raw':!![],'attributes':['id',_0xd22d('0xe'),_0xd22d('0xf'),_0xd22d('0x10')],'where':_0x46b9a2,'limit':0x1}})[_0xd22d('0xa')](function(_0x944593){logger[_0xd22d('0xb')](_0xd22d('0x11'),JSON['stringify'](_0x46b9a2),_0x944593?util['inspect'](_0x944593,{'showHidden':![],'depth':null}):'');return _0x944593[_0xd22d('0x12')][_0xd22d('0x13')]?_0x944593[_0xd22d('0x12')][0x0]:null;});}exports[_0xd22d('0x14')]=function(_0x9d5923){return new BPromise(function(_0x5319b0,_0x38af0f){if(_0x9d5923){return getUser({'internal':_0x9d5923})[_0xd22d('0xa')](function(_0x57de77){logger[_0xd22d('0x6')](_0xd22d('0x15'),_0x9d5923,_0x57de77?_0xd22d('0x16'):_0xd22d('0x17'));return _0x5319b0(_0x57de77);})[_0xd22d('0xd')](function(_0x518243){logger[_0xd22d('0x8')](_0xd22d('0x18'),_0x518243?util[_0xd22d('0x7')](_0x518243,{'showHidden':![],'depth':null}):'');return _0x5319b0(null);});}return _0x5319b0(null);});};exports['getUserByInterface']=function(_0x39c84c){return new BPromise(function(_0x3c2972,_0x43ebff){if(_0x39c84c){return getUser({'interface':_0x39c84c})[_0xd22d('0xa')](function(_0x441181){logger[_0xd22d('0x6')]('[utils][getUserByInterface]\x20interface:%s\x20%s',_0x39c84c,_0x441181?'found':'notfound');return _0x3c2972(_0x441181);})[_0xd22d('0xd')](function(_0x2037c7){logger[_0xd22d('0x8')](_0xd22d('0x19'),_0x2037c7?util['inspect'](_0x2037c7,{'showHidden':![],'depth':null}):'');return _0x3c2972(null);});}return _0x3c2972(null);});};exports[_0xd22d('0x1a')]=function(_0x3820d2){return new BPromise(function(_0x5e8234,_0x47206f){if(_0x3820d2){return getUser({'name':_0x3820d2})[_0xd22d('0xa')](function(_0x28e5da){logger[_0xd22d('0x6')]('[utils][getUserByName]\x20name:%s\x20%s',_0x3820d2,_0x28e5da?_0xd22d('0x16'):'notfound');return _0x5e8234(_0x28e5da);})[_0xd22d('0xd')](function(_0x28bafa){logger[_0xd22d('0x8')]('[utils][getUserByName]',_0x28bafa?util[_0xd22d('0x7')](_0x28bafa,{'showHidden':![],'depth':null}):'');return _0x5e8234(null);});}return _0x5e8234(null);});};exports['getVoiceQueueByName']=function(_0x3fcbfc){return new BPromise(function(_0x384977,_0x126784){if(_0x3fcbfc){return client[_0xd22d('0x9')](_0xd22d('0x1b'),{'options':{'raw':!![],'attributes':['id',_0xd22d('0xf'),_0xd22d('0x1c'),'acw',_0xd22d('0x1d')],'where':{'name':_0x3fcbfc},'limit':0x1}})[_0xd22d('0xa')](function(_0x4e4d43){logger[_0xd22d('0xb')](_0xd22d('0x1e'),_0x3fcbfc,_0x4e4d43?util[_0xd22d('0x7')](_0x4e4d43,{'showHidden':![],'depth':null}):'');logger[_0xd22d('0x6')](_0xd22d('0x1f'),_0x3fcbfc,_0x4e4d43?'found':_0xd22d('0x17'));return _0x384977(_0x4e4d43[_0xd22d('0x12')][_0xd22d('0x13')]?_0x4e4d43[_0xd22d('0x12')][0x0]:null);})[_0xd22d('0xd')](function(_0x2bfc5c){logger[_0xd22d('0x8')](_0xd22d('0x20'),_0x2bfc5c?util[_0xd22d('0x7')](_0x2bfc5c,{'showHidden':![],'depth':null}):'');return _0x384977(null);});}return _0x384977(null);});};exports[_0xd22d('0x21')]=function(_0x28f47f,_0x1da09b){return moment(_0x28f47f)['add'](_0x1da09b,_0xd22d('0x22'))[_0xd22d('0x23')](_0xd22d('0x24'));};exports[_0xd22d('0x25')]=function(_0xdbefda,_0x7c2926){return moment(_0xdbefda)[_0xd22d('0x26')](_0x7c2926,'seconds')['format'](_0xd22d('0x24'));};exports['diffTime']=function(_0x50da78,_0x519fbf){return moment(_0x50da78)[_0xd22d('0x27')](moment(_0x519fbf),_0xd22d('0x22'));};exports[_0xd22d('0x28')]=function(_0x5583b9,_0x19b95e){return parseInt(_0x5583b9,0xa)+parseInt(_0x19b95e,0xa);};exports[_0xd22d('0x29')]=function(){return moment()[_0xd22d('0x23')](_0xd22d('0x24'));};exports[_0xd22d('0x2a')]=function(_0x12e6ab,_0x50d779){if(_0x50d779){return moment(_0x12e6ab)[_0xd22d('0x2a')](_0x50d779);}return!![];};exports[_0xd22d('0x2b')]=function(_0x126110,_0x533bbb){if(_0x533bbb){return moment(_0x126110)['isBefore'](_0x533bbb);}else if(_0x126110){return!![];}return![];};
\ No newline at end of file