Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / services / xdr / utils.js
index 0070c01..d943096 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x72c3=['sumTime','now','isAfter','isBefore','bluebird','jayson/promise','util','client','http','../../config/logger','xdr','info','inspect','debug','error','request','then','[utils][request]\x20name:%s','catch','internal','name','interface','[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]\x20name:%s\x20%s','[utils][getUserByName]','getVoiceQueueByName','GetVoiceQueue','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','[utils][getVoiceQueueByName]','addTime','add','format','YYYY-MM-DD\x20HH:mm:ss','subtract','seconds','diff'];(function(_0x309cbc,_0x543e8f){var _0x2ac832=function(_0xfe43bc){while(--_0xfe43bc){_0x309cbc['push'](_0x309cbc['shift']());}};_0x2ac832(++_0x543e8f);}(_0x72c3,0x108));var _0x372c=function(_0x4324de,_0x3538ae){_0x4324de=_0x4324de-0x0;var _0x5419cf=_0x72c3[_0x4324de];return _0x5419cf;};'use strict';var BPromise=require(_0x372c('0x0'));var jayson=require(_0x372c('0x1'));var moment=require('moment');var util=require(_0x372c('0x2'));var client=jayson[_0x372c('0x3')][_0x372c('0x4')]({'port':0x2329});var logger=require(_0x372c('0x5'))(_0x372c('0x6'));exports['info']=function(_0x1f4c05,_0x10c107){logger[_0x372c('0x7')](_0x1f4c05,_0x10c107?util[_0x372c('0x8')](_0x10c107,{'showHidden':![],'depth':null}):'');};exports[_0x372c('0x9')]=function(_0x686537,_0x4c741b){logger[_0x372c('0x9')](_0x686537,_0x4c741b?util[_0x372c('0x8')](_0x4c741b,{'showHidden':![],'depth':null}):'');};exports[_0x372c('0xa')]=function(_0x3911b0,_0x504035){logger[_0x372c('0xa')](_0x3911b0,_0x504035?util[_0x372c('0x8')](_0x504035,{'showHidden':![],'depth':null}):'');};exports[_0x372c('0xb')]=function(_0x5591c1,_0x3187c9){return client[_0x372c('0xb')](_0x5591c1,{'body':_0x3187c9})[_0x372c('0xc')](function(_0x2fb4fa){logger[_0x372c('0x9')](_0x372c('0xd'),_0x5591c1,_0x2fb4fa?util['inspect'](_0x2fb4fa,{'showHidden':![],'depth':null}):'');})[_0x372c('0xe')](function(_0x3686bd){logger[_0x372c('0xa')]('[utils][request]\x20name:%s',_0x5591c1,_0x3686bd?util[_0x372c('0x8')](_0x3686bd,{'showHidden':![],'depth':null}):'');});};function getUser(_0x30a612){return client[_0x372c('0xb')]('GetUser',{'options':{'raw':!![],'attributes':['id',_0x372c('0xf'),_0x372c('0x10'),_0x372c('0x11')],'where':_0x30a612,'limit':0x1}})[_0x372c('0xc')](function(_0x359510){logger[_0x372c('0x9')](_0x372c('0x12'),JSON[_0x372c('0x13')](_0x30a612),_0x359510?util[_0x372c('0x8')](_0x359510,{'showHidden':![],'depth':null}):'');return _0x359510[_0x372c('0x14')][_0x372c('0x15')]?_0x359510[_0x372c('0x14')][0x0]:null;});}exports[_0x372c('0x16')]=function(_0x2b1d73){return new BPromise(function(_0x212363,_0x416c9c){if(_0x2b1d73){return getUser({'internal':_0x2b1d73})['then'](function(_0x226222){logger[_0x372c('0x7')](_0x372c('0x17'),_0x2b1d73,_0x226222?_0x372c('0x18'):_0x372c('0x19'));return _0x212363(_0x226222);})['catch'](function(_0x56e805){logger[_0x372c('0xa')](_0x372c('0x1a'),_0x56e805?util[_0x372c('0x8')](_0x56e805,{'showHidden':![],'depth':null}):'');return _0x212363(null);});}return _0x212363(null);});};exports[_0x372c('0x1b')]=function(_0x4d947a){return new BPromise(function(_0x1cddae,_0x41a4e9){if(_0x4d947a){return getUser({'interface':_0x4d947a})[_0x372c('0xc')](function(_0x43796b){logger['info'](_0x372c('0x1c'),_0x4d947a,_0x43796b?'found':_0x372c('0x19'));return _0x1cddae(_0x43796b);})['catch'](function(_0x46ff79){logger['error'](_0x372c('0x1d'),_0x46ff79?util[_0x372c('0x8')](_0x46ff79,{'showHidden':![],'depth':null}):'');return _0x1cddae(null);});}return _0x1cddae(null);});};exports[_0x372c('0x1e')]=function(_0x50d0c1){return new BPromise(function(_0x4792e0,_0x32698c){if(_0x50d0c1){return getUser({'name':_0x50d0c1})[_0x372c('0xc')](function(_0x473ddd){logger['info'](_0x372c('0x1f'),_0x50d0c1,_0x473ddd?'found':_0x372c('0x19'));return _0x4792e0(_0x473ddd);})['catch'](function(_0x27b4f6){logger[_0x372c('0xa')](_0x372c('0x20'),_0x27b4f6?util[_0x372c('0x8')](_0x27b4f6,{'showHidden':![],'depth':null}):'');return _0x4792e0(null);});}return _0x4792e0(null);});};exports[_0x372c('0x21')]=function(_0x4563ef){return new BPromise(function(_0x56cc9d,_0x1f5123){if(_0x4563ef){return client[_0x372c('0xb')](_0x372c('0x22'),{'options':{'raw':!![],'attributes':['id',_0x372c('0x10'),_0x372c('0x23'),_0x372c('0x24'),_0x372c('0x25')],'where':{'name':_0x4563ef},'limit':0x1}})[_0x372c('0xc')](function(_0x13cc94){logger[_0x372c('0x9')](_0x372c('0x26'),_0x4563ef,_0x13cc94?util[_0x372c('0x8')](_0x13cc94,{'showHidden':![],'depth':null}):'');logger[_0x372c('0x7')](_0x372c('0x27'),_0x4563ef,_0x13cc94?_0x372c('0x18'):_0x372c('0x19'));return _0x56cc9d(_0x13cc94[_0x372c('0x14')]['length']?_0x13cc94[_0x372c('0x14')][0x0]:null);})[_0x372c('0xe')](function(_0x38cc52){logger[_0x372c('0xa')](_0x372c('0x28'),_0x38cc52?util['inspect'](_0x38cc52,{'showHidden':![],'depth':null}):'');return _0x56cc9d(null);});}return _0x56cc9d(null);});};exports[_0x372c('0x29')]=function(_0x565573,_0x35d70d){return moment(_0x565573)[_0x372c('0x2a')](_0x35d70d,'seconds')[_0x372c('0x2b')](_0x372c('0x2c'));};exports['subtractTime']=function(_0x5436d0,_0x4b3459){return moment(_0x5436d0)[_0x372c('0x2d')](_0x4b3459,_0x372c('0x2e'))[_0x372c('0x2b')](_0x372c('0x2c'));};exports['diffTime']=function(_0x320451,_0x5b4d18){return moment(_0x320451)[_0x372c('0x2f')](moment(_0x5b4d18),_0x372c('0x2e'));};exports[_0x372c('0x30')]=function(_0x1f9a64,_0x130ce3){return parseInt(_0x1f9a64,0xa)+parseInt(_0x130ce3,0xa);};exports[_0x372c('0x31')]=function(){return moment()[_0x372c('0x2b')](_0x372c('0x2c'));};exports['isAfter']=function(_0x2451a2,_0x5a9e6d){if(_0x5a9e6d){return moment(_0x2451a2)[_0x372c('0x32')](_0x5a9e6d);}return!![];};exports[_0x372c('0x33')]=function(_0x4babec,_0x17ad51){if(_0x17ad51){return moment(_0x4babec)[_0x372c('0x33')](_0x17ad51);}else if(_0x4babec){return!![];}return![];};
\ No newline at end of file
+var _0x457a=['error','request','catch','[utils][request]\x20name:%s','GetUser','internal','name','interface','then','stringify','length','getUserByInternal','[utils][getUserByInternal]\x20internal:%s\x20%s','found','notfound','getUserByInterface','[utils][getUserByInterface]\x20interface:%s\x20%s','[utils][getUserByInterface]','getUserByName','getVoiceQueueByName','GetVoiceQueue','type','acw','acwTimeout','[utils][getVoiceQueueByName]\x20name:%s','[utils][getVoiceQueueByName]\x20name:%s\x20%s','result','add','seconds','YYYY-MM-DD\x20HH:mm:ss','format','diffTime','diff','sumTime','now','isAfter','isBefore','bluebird','jayson/promise','moment','client','../../config/logger','xdr','info','inspect','debug'];(function(_0x3be650,_0x3e75f6){var _0x440588=function(_0xb0b66c){while(--_0xb0b66c){_0x3be650['push'](_0x3be650['shift']());}};_0x440588(++_0x3e75f6);}(_0x457a,0x167));var _0xa457=function(_0x1528ae,_0x1cd182){_0x1528ae=_0x1528ae-0x0;var _0x57fb8d=_0x457a[_0x1528ae];return _0x57fb8d;};'use strict';var BPromise=require(_0xa457('0x0'));var jayson=require(_0xa457('0x1'));var moment=require(_0xa457('0x2'));var util=require('util');var client=jayson[_0xa457('0x3')]['http']({'port':0x2329});var logger=require(_0xa457('0x4'))(_0xa457('0x5'));exports[_0xa457('0x6')]=function(_0x685838,_0x553716){logger[_0xa457('0x6')](_0x685838,_0x553716?util[_0xa457('0x7')](_0x553716,{'showHidden':![],'depth':null}):'');};exports[_0xa457('0x8')]=function(_0x13157b,_0x5759de){logger[_0xa457('0x8')](_0x13157b,_0x5759de?util[_0xa457('0x7')](_0x5759de,{'showHidden':![],'depth':null}):'');};exports[_0xa457('0x9')]=function(_0x6bb203,_0x5a0b33){logger[_0xa457('0x9')](_0x6bb203,_0x5a0b33?util[_0xa457('0x7')](_0x5a0b33,{'showHidden':![],'depth':null}):'');};exports[_0xa457('0xa')]=function(_0x16b549,_0x480f9b){return client['request'](_0x16b549,{'body':_0x480f9b})['then'](function(_0x1f1474){logger[_0xa457('0x8')]('[utils][request]\x20name:%s',_0x16b549,_0x1f1474?util[_0xa457('0x7')](_0x1f1474,{'showHidden':![],'depth':null}):'');})[_0xa457('0xb')](function(_0x2811af){logger['error'](_0xa457('0xc'),_0x16b549,_0x2811af?util[_0xa457('0x7')](_0x2811af,{'showHidden':![],'depth':null}):'');});};function getUser(_0x53f4b1){return client['request'](_0xa457('0xd'),{'options':{'raw':!![],'attributes':['id',_0xa457('0xe'),_0xa457('0xf'),_0xa457('0x10')],'where':_0x53f4b1,'limit':0x1}})[_0xa457('0x11')](function(_0x5640e1){logger[_0xa457('0x8')]('[utils][getUser]\x20where:%s',JSON[_0xa457('0x12')](_0x53f4b1),_0x5640e1?util[_0xa457('0x7')](_0x5640e1,{'showHidden':![],'depth':null}):'');return _0x5640e1['result'][_0xa457('0x13')]?_0x5640e1['result'][0x0]:null;});}exports[_0xa457('0x14')]=function(_0x4278ee){return new BPromise(function(_0x39e62e,_0x57612b){if(_0x4278ee){return getUser({'internal':_0x4278ee})[_0xa457('0x11')](function(_0xbc36c5){logger['info'](_0xa457('0x15'),_0x4278ee,_0xbc36c5?_0xa457('0x16'):_0xa457('0x17'));return _0x39e62e(_0xbc36c5);})[_0xa457('0xb')](function(_0x175071){logger[_0xa457('0x9')]('[utils][getUserByInternal]',_0x175071?util[_0xa457('0x7')](_0x175071,{'showHidden':![],'depth':null}):'');return _0x39e62e(null);});}return _0x39e62e(null);});};exports[_0xa457('0x18')]=function(_0x26629f){return new BPromise(function(_0x4faffa,_0x78f58f){if(_0x26629f){return getUser({'interface':_0x26629f})['then'](function(_0x53632d){logger[_0xa457('0x6')](_0xa457('0x19'),_0x26629f,_0x53632d?_0xa457('0x16'):_0xa457('0x17'));return _0x4faffa(_0x53632d);})[_0xa457('0xb')](function(_0x498901){logger[_0xa457('0x9')](_0xa457('0x1a'),_0x498901?util[_0xa457('0x7')](_0x498901,{'showHidden':![],'depth':null}):'');return _0x4faffa(null);});}return _0x4faffa(null);});};exports[_0xa457('0x1b')]=function(_0x32c1c5){return new BPromise(function(_0x20a6f1,_0xbd23a2){if(_0x32c1c5){return getUser({'name':_0x32c1c5})[_0xa457('0x11')](function(_0x4e0107){logger['info']('[utils][getUserByName]\x20name:%s\x20%s',_0x32c1c5,_0x4e0107?_0xa457('0x16'):'notfound');return _0x20a6f1(_0x4e0107);})[_0xa457('0xb')](function(_0xfba969){logger[_0xa457('0x9')]('[utils][getUserByName]',_0xfba969?util[_0xa457('0x7')](_0xfba969,{'showHidden':![],'depth':null}):'');return _0x20a6f1(null);});}return _0x20a6f1(null);});};exports[_0xa457('0x1c')]=function(_0x143384){return new BPromise(function(_0x2c1c01,_0x2aa3f0){if(_0x143384){return client['request'](_0xa457('0x1d'),{'options':{'raw':!![],'attributes':['id',_0xa457('0xf'),_0xa457('0x1e'),_0xa457('0x1f'),_0xa457('0x20')],'where':{'name':_0x143384},'limit':0x1}})[_0xa457('0x11')](function(_0x4d6ba3){logger[_0xa457('0x8')](_0xa457('0x21'),_0x143384,_0x4d6ba3?util[_0xa457('0x7')](_0x4d6ba3,{'showHidden':![],'depth':null}):'');logger[_0xa457('0x6')](_0xa457('0x22'),_0x143384,_0x4d6ba3?_0xa457('0x16'):_0xa457('0x17'));return _0x2c1c01(_0x4d6ba3['result'][_0xa457('0x13')]?_0x4d6ba3[_0xa457('0x23')][0x0]:null);})[_0xa457('0xb')](function(_0x25cdbf){logger['error']('[utils][getVoiceQueueByName]',_0x25cdbf?util[_0xa457('0x7')](_0x25cdbf,{'showHidden':![],'depth':null}):'');return _0x2c1c01(null);});}return _0x2c1c01(null);});};exports['addTime']=function(_0xc36f2c,_0x525012){return moment(_0xc36f2c)[_0xa457('0x24')](_0x525012,_0xa457('0x25'))['format'](_0xa457('0x26'));};exports['subtractTime']=function(_0x1dc037,_0x55509f){return moment(_0x1dc037)['subtract'](_0x55509f,'seconds')[_0xa457('0x27')]('YYYY-MM-DD\x20HH:mm:ss');};exports[_0xa457('0x28')]=function(_0x174579,_0x163c9d){return moment(_0x174579)[_0xa457('0x29')](moment(_0x163c9d),_0xa457('0x25'));};exports[_0xa457('0x2a')]=function(_0x379c12,_0x1f10a7){return parseInt(_0x379c12,0xa)+parseInt(_0x1f10a7,0xa);};exports[_0xa457('0x2b')]=function(){return moment()[_0xa457('0x27')]('YYYY-MM-DD\x20HH:mm:ss');};exports['isAfter']=function(_0x56d34b,_0x2c1509){if(_0x2c1509){return moment(_0x56d34b)[_0xa457('0x2c')](_0x2c1509);}return!![];};exports[_0xa457('0x2d')]=function(_0x259eaf,_0x9f4af2){if(_0x9f4af2){return moment(_0x259eaf)[_0xa457('0x2d')](_0x9f4af2);}else if(_0x259eaf){return!![];}return![];};
\ No newline at end of file