Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / services / xdr / utils.js
index 98d0cfb..5f07977 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x34d2=['internal','name','interface','[utils][getUser]\x20where:%s','stringify','length','getUserByInternal','then','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]\x20name:%s\x20%s','[utils][getUserByName]','GetVoiceQueue','type','acw','[utils][getVoiceQueueByName]\x20name:%s','result','[utils][getVoiceQueueByName]','addTime','seconds','YYYY-MM-DD\x20HH:mm:ss','subtractTime','format','diffTime','diff','sumTime','isAfter','isBefore','jayson/promise','http','xdr','info','debug','inspect','error','request','catch','GetUser'];(function(_0x5f415d,_0x39b258){var _0x3ac7a6=function(_0x314dc5){while(--_0x314dc5){_0x5f415d['push'](_0x5f415d['shift']());}};_0x3ac7a6(++_0x39b258);}(_0x34d2,0x12a));var _0x234d=function(_0x1e0e31,_0x212cd6){_0x1e0e31=_0x1e0e31-0x0;var _0x495be0=_0x34d2[_0x1e0e31];return _0x495be0;};'use strict';var BPromise=require('bluebird');var jayson=require(_0x234d('0x0'));var moment=require('moment');var util=require('util');var client=jayson['client'][_0x234d('0x1')]({'port':0x2329});var logger=require('../../config/logger')(_0x234d('0x2'));exports[_0x234d('0x3')]=function(_0x5530d7,_0x4ba374){logger[_0x234d('0x3')](_0x5530d7,_0x4ba374?util['inspect'](_0x4ba374,{'showHidden':![],'depth':null}):'');};exports['debug']=function(_0x31aa2c,_0x318ff0){logger[_0x234d('0x4')](_0x31aa2c,_0x318ff0?util[_0x234d('0x5')](_0x318ff0,{'showHidden':![],'depth':null}):'');};exports['error']=function(_0x8d0cf2,_0x25e350){logger[_0x234d('0x6')](_0x8d0cf2,_0x25e350?util[_0x234d('0x5')](_0x25e350,{'showHidden':![],'depth':null}):'');};exports[_0x234d('0x7')]=function(_0x3a2a60,_0x3179d1){return client['request'](_0x3a2a60,{'body':_0x3179d1})['then'](function(_0x4b1615){logger[_0x234d('0x4')]('[utils][request]\x20name:%s',_0x3a2a60,_0x4b1615?util[_0x234d('0x5')](_0x4b1615,{'showHidden':![],'depth':null}):'');})[_0x234d('0x8')](function(_0x2c48bb){logger[_0x234d('0x6')]('[utils][request]\x20name:%s',_0x3a2a60,_0x2c48bb?util[_0x234d('0x5')](_0x2c48bb,{'showHidden':![],'depth':null}):'');});};function getUser(_0xca341a){return client['request'](_0x234d('0x9'),{'options':{'raw':!![],'attributes':['id',_0x234d('0xa'),_0x234d('0xb'),_0x234d('0xc')],'where':_0xca341a,'limit':0x1}})['then'](function(_0x560711){logger[_0x234d('0x4')](_0x234d('0xd'),JSON[_0x234d('0xe')](_0xca341a),_0x560711?util[_0x234d('0x5')](_0x560711,{'showHidden':![],'depth':null}):'');return _0x560711['result'][_0x234d('0xf')]?_0x560711['result'][0x0]:null;});}exports[_0x234d('0x10')]=function(_0x2ae590){return new BPromise(function(_0x25e2a2,_0x507967){if(_0x2ae590){return getUser({'internal':_0x2ae590})[_0x234d('0x11')](function(_0x239441){logger[_0x234d('0x3')](_0x234d('0x12'),_0x2ae590,_0x239441?_0x234d('0x13'):_0x234d('0x14'));return _0x25e2a2(_0x239441);})[_0x234d('0x8')](function(_0x316e71){logger[_0x234d('0x6')](_0x234d('0x15'),_0x316e71?util['inspect'](_0x316e71,{'showHidden':![],'depth':null}):'');return _0x25e2a2(null);});}return _0x25e2a2(null);});};exports[_0x234d('0x16')]=function(_0x4a34cd){return new BPromise(function(_0x55b76c,_0x16c748){if(_0x4a34cd){return getUser({'interface':_0x4a34cd})['then'](function(_0x2d59e5){logger['info'](_0x234d('0x17'),_0x4a34cd,_0x2d59e5?_0x234d('0x13'):_0x234d('0x14'));return _0x55b76c(_0x2d59e5);})[_0x234d('0x8')](function(_0x5916db){logger[_0x234d('0x6')](_0x234d('0x18'),_0x5916db?util[_0x234d('0x5')](_0x5916db,{'showHidden':![],'depth':null}):'');return _0x55b76c(null);});}return _0x55b76c(null);});};exports[_0x234d('0x19')]=function(_0x44380a){return new BPromise(function(_0x410323,_0x2dfbe8){if(_0x44380a){return getUser({'name':_0x44380a})[_0x234d('0x11')](function(_0x4d0115){logger[_0x234d('0x3')](_0x234d('0x1a'),_0x44380a,_0x4d0115?_0x234d('0x13'):_0x234d('0x14'));return _0x410323(_0x4d0115);})['catch'](function(_0x4ffb61){logger[_0x234d('0x6')](_0x234d('0x1b'),_0x4ffb61?util[_0x234d('0x5')](_0x4ffb61,{'showHidden':![],'depth':null}):'');return _0x410323(null);});}return _0x410323(null);});};exports['getVoiceQueueByName']=function(_0x56c388){return new BPromise(function(_0x54b8ac,_0x4f029e){if(_0x56c388){return client[_0x234d('0x7')](_0x234d('0x1c'),{'options':{'raw':!![],'attributes':['id',_0x234d('0xb'),_0x234d('0x1d'),_0x234d('0x1e'),'acwTimeout'],'where':{'name':_0x56c388},'limit':0x1}})[_0x234d('0x11')](function(_0x29467c){logger[_0x234d('0x4')](_0x234d('0x1f'),_0x56c388,_0x29467c?util[_0x234d('0x5')](_0x29467c,{'showHidden':![],'depth':null}):'');logger[_0x234d('0x3')]('[utils][getVoiceQueueByName]\x20name:%s\x20%s',_0x56c388,_0x29467c?_0x234d('0x13'):_0x234d('0x14'));return _0x54b8ac(_0x29467c[_0x234d('0x20')][_0x234d('0xf')]?_0x29467c[_0x234d('0x20')][0x0]:null);})['catch'](function(_0x135ce9){logger[_0x234d('0x6')](_0x234d('0x21'),_0x135ce9?util[_0x234d('0x5')](_0x135ce9,{'showHidden':![],'depth':null}):'');return _0x54b8ac(null);});}return _0x54b8ac(null);});};exports[_0x234d('0x22')]=function(_0x554fde,_0x489076){return moment(_0x554fde)['add'](_0x489076,_0x234d('0x23'))['format'](_0x234d('0x24'));};exports[_0x234d('0x25')]=function(_0x1dba4f,_0x21aed3){return moment(_0x1dba4f)['subtract'](_0x21aed3,_0x234d('0x23'))[_0x234d('0x26')](_0x234d('0x24'));};exports[_0x234d('0x27')]=function(_0x1af41a,_0x947a4e){return moment(_0x1af41a)[_0x234d('0x28')](moment(_0x947a4e),_0x234d('0x23'));};exports[_0x234d('0x29')]=function(_0x43d16e,_0x48c1e7){return parseInt(_0x43d16e,0xa)+parseInt(_0x48c1e7,0xa);};exports['now']=function(){return moment()['format']('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x234d('0x2a')]=function(_0x2ddba8,_0x471477){if(_0x471477){return moment(_0x2ddba8)['isAfter'](_0x471477);}return!![];};exports[_0x234d('0x2b')]=function(_0x335266,_0x2c4b1b){if(_0x2c4b1b){return moment(_0x335266)[_0x234d('0x2b')](_0x2c4b1b);}else if(_0x335266){return!![];}return![];};
\ No newline at end of file
+var _0x3bf0=['[utils][request]\x20name:%s','catch','GetUser','internal','[utils][getUser]\x20where:%s','stringify','result','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','[utils][getUserByInternal]','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','[utils][getUserByName]','getVoiceQueueByName','name','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','add','seconds','format','YYYY-MM-DD\x20HH:mm:ss','subtract','diffTime','diff','sumTime','now','isBefore','bluebird','jayson/promise','moment','util','client','http','../../config/logger','info','inspect','error','request','then','debug'];(function(_0xb0f7c3,_0x4eae95){var _0x28ea68=function(_0x4395a7){while(--_0x4395a7){_0xb0f7c3['push'](_0xb0f7c3['shift']());}};_0x28ea68(++_0x4eae95);}(_0x3bf0,0x83));var _0x03bf=function(_0x1d1d40,_0xedf59d){_0x1d1d40=_0x1d1d40-0x0;var _0x3db8d9=_0x3bf0[_0x1d1d40];return _0x3db8d9;};'use strict';var BPromise=require(_0x03bf('0x0'));var jayson=require(_0x03bf('0x1'));var moment=require(_0x03bf('0x2'));var util=require(_0x03bf('0x3'));var client=jayson[_0x03bf('0x4')][_0x03bf('0x5')]({'port':0x2329});var logger=require(_0x03bf('0x6'))('xdr');exports[_0x03bf('0x7')]=function(_0x412688,_0x3398b8){logger[_0x03bf('0x7')](_0x412688,_0x3398b8?util[_0x03bf('0x8')](_0x3398b8,{'showHidden':![],'depth':null}):'');};exports['debug']=function(_0x2c37c7,_0xf513cf){logger['debug'](_0x2c37c7,_0xf513cf?util[_0x03bf('0x8')](_0xf513cf,{'showHidden':![],'depth':null}):'');};exports[_0x03bf('0x9')]=function(_0x151297,_0x4c43a1){logger[_0x03bf('0x9')](_0x151297,_0x4c43a1?util[_0x03bf('0x8')](_0x4c43a1,{'showHidden':![],'depth':null}):'');};exports[_0x03bf('0xa')]=function(_0x3baf28,_0x374024){return client[_0x03bf('0xa')](_0x3baf28,{'body':_0x374024})[_0x03bf('0xb')](function(_0x33152f){logger[_0x03bf('0xc')](_0x03bf('0xd'),_0x3baf28,_0x33152f?util[_0x03bf('0x8')](_0x33152f,{'showHidden':![],'depth':null}):'');})[_0x03bf('0xe')](function(_0xfde47c){logger[_0x03bf('0x9')](_0x03bf('0xd'),_0x3baf28,_0xfde47c?util[_0x03bf('0x8')](_0xfde47c,{'showHidden':![],'depth':null}):'');});};function getUser(_0x34af14){return client[_0x03bf('0xa')](_0x03bf('0xf'),{'options':{'raw':!![],'attributes':['id',_0x03bf('0x10'),'name','interface'],'where':_0x34af14,'limit':0x1}})[_0x03bf('0xb')](function(_0x7f2750){logger['debug'](_0x03bf('0x11'),JSON[_0x03bf('0x12')](_0x34af14),_0x7f2750?util[_0x03bf('0x8')](_0x7f2750,{'showHidden':![],'depth':null}):'');return _0x7f2750[_0x03bf('0x13')][_0x03bf('0x14')]?_0x7f2750[_0x03bf('0x13')][0x0]:null;});}exports[_0x03bf('0x15')]=function(_0x316f4b){return new BPromise(function(_0x573dc4,_0x37e8fe){if(_0x316f4b){return getUser({'internal':_0x316f4b})[_0x03bf('0xb')](function(_0x3f7e65){logger[_0x03bf('0x7')](_0x03bf('0x16'),_0x316f4b,_0x3f7e65?_0x03bf('0x17'):_0x03bf('0x18'));return _0x573dc4(_0x3f7e65);})[_0x03bf('0xe')](function(_0x30a7fd){logger[_0x03bf('0x9')](_0x03bf('0x19'),_0x30a7fd?util[_0x03bf('0x8')](_0x30a7fd,{'showHidden':![],'depth':null}):'');return _0x573dc4(null);});}return _0x573dc4(null);});};exports[_0x03bf('0x1a')]=function(_0x22e0e2){return new BPromise(function(_0x51fc81,_0x24d1f){if(_0x22e0e2){return getUser({'interface':_0x22e0e2})[_0x03bf('0xb')](function(_0x5686fb){logger[_0x03bf('0x7')](_0x03bf('0x1b'),_0x22e0e2,_0x5686fb?_0x03bf('0x17'):_0x03bf('0x18'));return _0x51fc81(_0x5686fb);})[_0x03bf('0xe')](function(_0x57c873){logger['error'](_0x03bf('0x1c'),_0x57c873?util[_0x03bf('0x8')](_0x57c873,{'showHidden':![],'depth':null}):'');return _0x51fc81(null);});}return _0x51fc81(null);});};exports[_0x03bf('0x1d')]=function(_0x250850){return new BPromise(function(_0x16c0ab,_0x59378f){if(_0x250850){return getUser({'name':_0x250850})[_0x03bf('0xb')](function(_0x50d1a7){logger[_0x03bf('0x7')]('[utils][getUserByName]\x20name:%s\x20%s',_0x250850,_0x50d1a7?_0x03bf('0x17'):_0x03bf('0x18'));return _0x16c0ab(_0x50d1a7);})['catch'](function(_0x1ba789){logger[_0x03bf('0x9')](_0x03bf('0x1e'),_0x1ba789?util['inspect'](_0x1ba789,{'showHidden':![],'depth':null}):'');return _0x16c0ab(null);});}return _0x16c0ab(null);});};exports[_0x03bf('0x1f')]=function(_0x45a5df){return new BPromise(function(_0x12e554,_0x20e9ba){if(_0x45a5df){return client[_0x03bf('0xa')]('GetVoiceQueue',{'options':{'raw':!![],'attributes':['id',_0x03bf('0x20'),'type',_0x03bf('0x21'),_0x03bf('0x22')],'where':{'name':_0x45a5df},'limit':0x1}})[_0x03bf('0xb')](function(_0x1f7595){logger[_0x03bf('0xc')](_0x03bf('0x23'),_0x45a5df,_0x1f7595?util[_0x03bf('0x8')](_0x1f7595,{'showHidden':![],'depth':null}):'');logger[_0x03bf('0x7')](_0x03bf('0x24'),_0x45a5df,_0x1f7595?'found':_0x03bf('0x18'));return _0x12e554(_0x1f7595[_0x03bf('0x13')][_0x03bf('0x14')]?_0x1f7595['result'][0x0]:null);})[_0x03bf('0xe')](function(_0x352ac4){logger['error'](_0x03bf('0x25'),_0x352ac4?util[_0x03bf('0x8')](_0x352ac4,{'showHidden':![],'depth':null}):'');return _0x12e554(null);});}return _0x12e554(null);});};exports['addTime']=function(_0x4a9466,_0x2b0db7){return moment(_0x4a9466)[_0x03bf('0x26')](_0x2b0db7,_0x03bf('0x27'))[_0x03bf('0x28')](_0x03bf('0x29'));};exports['subtractTime']=function(_0x3beb7a,_0x1b0eed){return moment(_0x3beb7a)[_0x03bf('0x2a')](_0x1b0eed,'seconds')[_0x03bf('0x28')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0x03bf('0x2b')]=function(_0x3a7603,_0x5b4e42){return moment(_0x3a7603)[_0x03bf('0x2c')](moment(_0x5b4e42),_0x03bf('0x27'));};exports[_0x03bf('0x2d')]=function(_0x53e729,_0x31f05f){return parseInt(_0x53e729,0xa)+parseInt(_0x31f05f,0xa);};exports[_0x03bf('0x2e')]=function(){return moment()[_0x03bf('0x28')](_0x03bf('0x29'));};exports['isAfter']=function(_0xd498f3,_0x5be22f){if(_0x5be22f){return moment(_0xd498f3)['isAfter'](_0x5be22f);}return!![];};exports[_0x03bf('0x2f')]=function(_0x2f6e61,_0x329ab7){if(_0x329ab7){return moment(_0x2f6e61)[_0x03bf('0x2f')](_0x329ab7);}else if(_0x2f6e61){return!![];}return![];};
\ No newline at end of file