Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / services / routing / server / applications / strategy / util.js
index a6832a1..a27f417 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd3d3=['user:%s','name','user:save','split','\x20interaction','account','notificationShake','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','notification:%s','save','info','isAgentAvailable','busy','OFFLINE','Pause','PAUSE','hasOwnProperty','CurrentCapacity','Capacity','toUpperCase','\x20MAXCAPACITY','hideNotification','writeLog','../utils','mustache','routing','redis','defaults','localhost','emit','format'];(function(_0x152cc6,_0xce8c){var _0x5cab68=function(_0x16ad44){while(--_0x16ad44){_0x152cc6['push'](_0x152cc6['shift']());}};_0x5cab68(++_0xce8c);}(_0xd3d3,0x19a));var _0x3d3d=function(_0x4a747d,_0x3b747f){_0x4a747d=_0x4a747d-0x0;var _0x3a5b5c=_0xd3d3[_0x4a747d];return _0x3a5b5c;};'use strict';var _=require('lodash');var util=require('util');var utils=require(_0x3d3d('0x0'));var Mustache=require(_0x3d3d('0x1'));var Redis=require('ioredis');var config=require('../../../../../config/environment');var logger=require('../../../../../config/logger')(_0x3d3d('0x2'));config[_0x3d3d('0x3')]=_[_0x3d3d('0x4')](config['redis'],{'host':_0x3d3d('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x3d3d('0x3')]));function emit(_0x2b6c5a,_0x73eb99,_0x217fc6){io['to'](_0x2b6c5a)[_0x3d3d('0x6')](_0x73eb99,_0x217fc6);}function sendNotification(_0x3cba4c,_0x27915e,_0x4e2a13,_0x29fea2,_0x46aeb7,_0x5d804b){io['to'](util[_0x3d3d('0x7')](_0x3d3d('0x8'),_0x29fea2[_0x3d3d('0x9')]))[_0x3d3d('0x6')](_0x3d3d('0xa'),_0x29fea2);var _0x18b9d0=_0x5d804b||{};var _0x50c9b1=_0x4e2a13[_0x3d3d('0xb')]('.');var _0x47bcdd={'uniqueid':_0x27915e,'channel':_0x50c9b1[0x0],'id':_0x50c9b1[0x1],'title':_0x50c9b1[0x0]+_0x3d3d('0xc'),'interactionId':_0x50c9b1[0x2],'queue':_0x46aeb7?_0x46aeb7[_0x3d3d('0x9')]:null,'sound':_0x18b9d0[_0x3d3d('0xd')]['notificationSound'],'shake':_0x18b9d0[_0x3d3d('0xd')][_0x3d3d('0xe')]};try{if(!_0x18b9d0[_0x3d3d('0xf')]){_0x18b9d0['body']={};}if(_0x46aeb7){_0x18b9d0[_0x3d3d('0xf')][_0x3d3d('0x10')]=_0x46aeb7;}else if(_0x18b9d0[_0x3d3d('0xf')][_0x3d3d('0x10')]){delete _0x18b9d0[_0x3d3d('0xf')][_0x3d3d('0x10')];}_0x47bcdd[_0x3d3d('0x11')]=utils['getMustacheRender'](_0x18b9d0[_0x3d3d('0xd')][_0x3d3d('0x12')],_0x18b9d0);}catch(_0xa1c93b){_0x47bcdd['msg']=_0x3d3d('0x13');logger[_0x3d3d('0x14')](util[_0x3d3d('0x7')](_0x3d3d('0x15'),_0x27915e,_0xa1c93b[_0x3d3d('0x16')]));}io['to'](util[_0x3d3d('0x7')](_0x3d3d('0x8'),_0x29fea2['name']))[_0x3d3d('0x6')](util['format'](_0x3d3d('0x17'),_0x3cba4c?_0x3d3d('0x18'):'remove'),_0x47bcdd);}function writeLog(_0x5ede83,_0x263a3d,_0x2cafd4){return logger[_0x3d3d('0x19')](util[_0x3d3d('0x7')]('[%s][QUEUE][AGENT:%s][STATUS:%s]',_0x5ede83,_0x263a3d[_0x3d3d('0x9')],_0x2cafd4));}exports[_0x3d3d('0x1a')]=function(_0x150a7b,_0x4d2fe6,_0x388900,_0x288002){if(_0x4d2fe6[_0x3d3d('0x1b')]){writeLog(_0x150a7b,_0x4d2fe6,'BUSY');return![];}if(!_0x4d2fe6['online']){writeLog(_0x150a7b,_0x4d2fe6,_0x3d3d('0x1c'));return![];}if(_0x4d2fe6[_0x388900+_0x3d3d('0x1d')]){writeLog(_0x150a7b,_0x4d2fe6,_0x3d3d('0x1e'));return![];}if(_0x288002&&_0x4d2fe6[_0x3d3d('0x1f')](_0x388900+'Capacity')&&_0x4d2fe6[_0x3d3d('0x1f')](_0x388900+_0x3d3d('0x20'))){if(_0x4d2fe6[_0x388900+_0x3d3d('0x21')]>0x0&&_0x4d2fe6[_0x388900+_0x3d3d('0x20')]>=_0x4d2fe6[_0x388900+_0x3d3d('0x21')]){writeLog(_0x150a7b,_0x4d2fe6,_0x388900[_0x3d3d('0x22')]()+_0x3d3d('0x23'));return![];}}return!![];};exports['showNotification']=function(_0x49a2b7,_0x4b4e04,_0x566dd8,_0x5bf25b,_0x51c8fb){return sendNotification(!![],_0x49a2b7,_0x4b4e04,_0x566dd8,_0x5bf25b,_0x51c8fb);};exports[_0x3d3d('0x24')]=function(_0x8dadd6,_0x41464f,_0x45a836,_0x3bd2a2,_0xd39657){return sendNotification(![],_0x8dadd6,_0x41464f,_0x45a836,_0x3bd2a2,_0xd39657);};exports[_0x3d3d('0x25')]=writeLog;
\ No newline at end of file
+var _0x14d8=['format','[%s][QUEUE]\x20%s','message','user:%s','emit','notification:%s','save','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','checkWaitingNotifications','interaction','UserId','some','channel','QueuesWaitingInteractions','capitalize','InteractionId','agents','saveWaitingNotification','WaitingInteractions','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','redis','socket.io-emitter','split','\x20interaction','name','account','notificationSound','notificationShake','body','queue','getMustacheRender','notificationTemplate','msg','I\x20can\x27t\x20render\x20your\x20template','error'];(function(_0x49c057,_0xc808ed){var _0xd8f0e6=function(_0x5b9042){while(--_0x5b9042){_0x49c057['push'](_0x49c057['shift']());}};_0xd8f0e6(++_0xc808ed);}(_0x14d8,0x87));var _0x814d=function(_0x13d07a,_0x41efc3){_0x13d07a=_0x13d07a-0x0;var _0x5ee0ee=_0x14d8[_0x13d07a];return _0x5ee0ee;};'use strict';var _=require(_0x814d('0x0'));var util=require(_0x814d('0x1'));var utils=require(_0x814d('0x2'));var Redis=require(_0x814d('0x3'));var config=require(_0x814d('0x4'));var logger=require(_0x814d('0x5'))('routing');config[_0x814d('0x6')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x814d('0x7'))(new Redis(config[_0x814d('0x6')]));function sendNotification(_0x105932,_0x52e4c5,_0x927885,_0x2d9a38,_0x2ac802,_0xa745c8){var _0x3c176e=_0xa745c8||{};var _0x94073c=_0x927885[_0x814d('0x8')]('.');var _0x568e55={'uniqueid':_0x52e4c5,'channel':_0x94073c[0x0],'id':_0x94073c[0x1],'title':_0x94073c[0x0]+_0x814d('0x9'),'interactionId':_0x94073c[0x2],'queue':_0x2ac802?_0x2ac802[_0x814d('0xa')]:null,'sound':_0x3c176e[_0x814d('0xb')][_0x814d('0xc')],'shake':_0x3c176e[_0x814d('0xb')][_0x814d('0xd')]};try{if(!_0x3c176e[_0x814d('0xe')]){_0x3c176e[_0x814d('0xe')]={};}if(_0x2ac802){_0x3c176e[_0x814d('0xe')][_0x814d('0xf')]=_0x2ac802;}else if(_0x3c176e[_0x814d('0xe')][_0x814d('0xf')]){delete _0x3c176e[_0x814d('0xe')][_0x814d('0xf')];}_0x568e55['msg']=utils[_0x814d('0x10')](_0x3c176e[_0x814d('0xb')][_0x814d('0x11')],_0x3c176e);}catch(_0x4ded99){_0x568e55[_0x814d('0x12')]=_0x814d('0x13');logger[_0x814d('0x14')](util[_0x814d('0x15')](_0x814d('0x16'),_0x52e4c5,_0x4ded99[_0x814d('0x17')]));}io['to'](util['format'](_0x814d('0x18'),_0x2d9a38[_0x814d('0xa')]))[_0x814d('0x19')](util['format'](_0x814d('0x1a'),_0x105932?_0x814d('0x1b'):'remove'),_0x568e55);}function writeLog(_0x18aa84,_0x27905e,_0xc09189){return logger['debug'](util[_0x814d('0x15')](_0x814d('0x1c'),_0x18aa84,_0x27905e[_0x814d('0xa')],_0xc09189));}exports[_0x814d('0x1d')]=function(_0x250a2f,_0x24387c,_0x16be40,_0x55cb2e){if(_0x24387c[_0x814d('0x1e')]){writeLog(_0x250a2f,_0x24387c,_0x814d('0x1f'));return![];}if(!_0x24387c[_0x814d('0x20')]){writeLog(_0x250a2f,_0x24387c,_0x814d('0x21'));return![];}if(_0x24387c[_0x16be40+'Pause']){writeLog(_0x250a2f,_0x24387c,'PAUSE');return![];}if(_0x55cb2e&&_0x24387c[_0x814d('0x22')](_0x16be40+_0x814d('0x23'))&&_0x24387c[_0x814d('0x22')](_0x16be40+_0x814d('0x24'))){if(_0x24387c[_0x16be40+_0x814d('0x23')]>0x0&&_0x24387c[_0x16be40+'CurrentCapacity']>=_0x24387c[_0x16be40+_0x814d('0x23')]){writeLog(_0x250a2f,_0x24387c,_0x16be40[_0x814d('0x25')]()+_0x814d('0x26'));return![];}}return!![];};exports[_0x814d('0x27')]=function(_0x56e809,_0x31855c,_0x4d0b06,_0x4d5277,_0x5007d9){return sendNotification(!![],_0x56e809,_0x31855c,_0x4d0b06,_0x4d5277,_0x5007d9);};exports['hideNotification']=function(_0x14a5e3,_0x1edb70,_0x2d28dc,_0x31e143,_0x48afd6){return sendNotification(![],_0x14a5e3,_0x1edb70,_0x2d28dc,_0x31e143,_0x48afd6);};exports[_0x814d('0x28')]=function(_0x4d4c2d,_0x18dc10,_0x387acb){var _0x23c9ab=_0x18dc10[_0x814d('0x29')][_0x814d('0x2a')];if(!_0x23c9ab&&_0x387acb){_0x23c9ab=_0x387acb['id'];}var _0x3d0669=_[_0x814d('0x2b')](_0x4d4c2d[_0x18dc10[_0x814d('0x2c')]+_0x814d('0x2d')],function(_0x50326c){var _0xc5e4be=_[_0x814d('0x2e')](_0x18dc10['channel'])+_0x814d('0x2f');return _0x50326c[_0xc5e4be]===_0x18dc10[_0x814d('0x29')]['id'];});if(!_0x3d0669&&_0x23c9ab&&_0x4d4c2d['agents'][_0x23c9ab]){_0x3d0669=_['some'](_0x4d4c2d[_0x814d('0x30')][_0x23c9ab][_0x18dc10[_0x814d('0x2c')]+'WaitingInteractions'],function(_0x5273e3){return _0x5273e3['id']===_0x18dc10[_0x814d('0x29')]['id'];});}return _0x3d0669;};exports[_0x814d('0x31')]=function(_0xccdbd3,_0x38de40,_0x5498aa,_0xeb2c04){if(_0x5498aa&&_0x5498aa['id']&&_0xccdbd3[_0x814d('0x30')]&&_0xccdbd3[_0x814d('0x30')][_0x5498aa['id']]){_0xccdbd3[_0x814d('0x30')][_0x5498aa['id']][_0xeb2c04+_0x814d('0x32')][_0x38de40[_0x814d('0x17')]['id']]={'id':_0x38de40['interaction']['id']};}};exports['removeWaitingNotification']=function(_0x4a611d,_0x3f50a9,_0x35c5f5,_0x21f09d){if(_0x35c5f5&&_0x35c5f5['id']&&_0x4a611d[_0x814d('0x30')]&&_0x4a611d[_0x814d('0x30')][_0x35c5f5['id']]){delete _0x4a611d[_0x814d('0x30')][_0x35c5f5['id']][_0x21f09d+_0x814d('0x32')][_0x3f50a9[_0x814d('0x17')]['id']];}};exports[_0x814d('0x33')]=writeLog;
\ No newline at end of file