Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / services / routing / server / applications / strategy / util.js
index b1de0db..8157234 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8d0e=['localhost','format','user:%s','emit','user:save','\x20interaction','name','account','notificationSound','body','queue','msg','getMustacheRender','notificationTemplate','error','[%s][QUEUE]\x20%s','notification:%s','save','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults'];(function(_0x36905c,_0xb31581){var _0x5712fb=function(_0x29e126){while(--_0x29e126){_0x36905c['push'](_0x36905c['shift']());}};_0x5712fb(++_0xb31581);}(_0x8d0e,0x1d7));var _0xe8d0=function(_0x1aa42d,_0xa00e80){_0x1aa42d=_0x1aa42d-0x0;var _0x48b4eb=_0x8d0e[_0x1aa42d];return _0x48b4eb;};'use strict';var _=require(_0xe8d0('0x0'));var util=require(_0xe8d0('0x1'));var utils=require(_0xe8d0('0x2'));var Redis=require(_0xe8d0('0x3'));var config=require(_0xe8d0('0x4'));var logger=require(_0xe8d0('0x5'))(_0xe8d0('0x6'));config[_0xe8d0('0x7')]=_[_0xe8d0('0x8')](config['redis'],{'host':_0xe8d0('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function sendNotification(_0x2e2985,_0x92483d,_0x469d37,_0xcc03d0,_0x2b6dce,_0x13aa63){io['to'](util[_0xe8d0('0xa')](_0xe8d0('0xb'),_0xcc03d0['name']))[_0xe8d0('0xc')](_0xe8d0('0xd'),_0xcc03d0);var _0x463159=_0x13aa63||{};var _0x599bc3=_0x469d37['split']('.');var _0x42e0c2={'uniqueid':_0x92483d,'channel':_0x599bc3[0x0],'id':_0x599bc3[0x1],'title':_0x599bc3[0x0]+_0xe8d0('0xe'),'interactionId':_0x599bc3[0x2],'queue':_0x2b6dce?_0x2b6dce[_0xe8d0('0xf')]:null,'sound':_0x463159[_0xe8d0('0x10')][_0xe8d0('0x11')],'shake':_0x463159[_0xe8d0('0x10')]['notificationShake']};try{if(!_0x463159[_0xe8d0('0x12')]){_0x463159[_0xe8d0('0x12')]={};}if(_0x2b6dce){_0x463159['body'][_0xe8d0('0x13')]=_0x2b6dce;}else if(_0x463159['body']['queue']){delete _0x463159[_0xe8d0('0x12')][_0xe8d0('0x13')];}_0x42e0c2[_0xe8d0('0x14')]=utils[_0xe8d0('0x15')](_0x463159[_0xe8d0('0x10')][_0xe8d0('0x16')],_0x463159);}catch(_0x52818a){_0x42e0c2[_0xe8d0('0x14')]='I\x20can\x27t\x20render\x20your\x20template';logger[_0xe8d0('0x17')](util[_0xe8d0('0xa')](_0xe8d0('0x18'),_0x92483d,_0x52818a['message']));}io['to'](util['format']('user:%s',_0xcc03d0[_0xe8d0('0xf')]))[_0xe8d0('0xc')](util[_0xe8d0('0xa')](_0xe8d0('0x19'),_0x2e2985?_0xe8d0('0x1a'):'remove'),_0x42e0c2);}function writeLog(_0x105861,_0x12ebf4,_0x524b00){return logger['debug'](util['format'](_0xe8d0('0x1b'),_0x105861,_0x12ebf4[_0xe8d0('0xf')],_0x524b00));}exports[_0xe8d0('0x1c')]=function(_0x1fbfe8,_0x25f764,_0x23a945,_0x1bd25c){if(_0x25f764[_0xe8d0('0x1d')]){writeLog(_0x1fbfe8,_0x25f764,_0xe8d0('0x1e'));return![];}if(!_0x25f764['online']){writeLog(_0x1fbfe8,_0x25f764,_0xe8d0('0x1f'));return![];}if(_0x25f764[_0x23a945+_0xe8d0('0x20')]){writeLog(_0x1fbfe8,_0x25f764,'PAUSE');return![];}if(_0x1bd25c&&_0x25f764[_0xe8d0('0x21')](_0x23a945+_0xe8d0('0x22'))&&_0x25f764[_0xe8d0('0x21')](_0x23a945+_0xe8d0('0x23'))){if(_0x25f764[_0x23a945+_0xe8d0('0x22')]>0x0&&_0x25f764[_0x23a945+_0xe8d0('0x23')]>=_0x25f764[_0x23a945+_0xe8d0('0x22')]){writeLog(_0x1fbfe8,_0x25f764,_0x23a945[_0xe8d0('0x24')]()+_0xe8d0('0x25'));return![];}}return!![];};exports[_0xe8d0('0x26')]=function(_0x264de4,_0x539548,_0x24982c,_0x26dd52,_0x10dec2){return sendNotification(!![],_0x264de4,_0x539548,_0x24982c,_0x26dd52,_0x10dec2);};exports['hideNotification']=function(_0x10a30b,_0x343b08,_0x526240,_0x1519e2,_0x3ffcb7){return sendNotification(![],_0x10a30b,_0x343b08,_0x526240,_0x1519e2,_0x3ffcb7);};exports[_0xe8d0('0x27')]=writeLog;
\ No newline at end of file
+var _0xba97=['interaction','saveWaitingNotification','agents','WaitingInteractions','removeWaitingNotification','writeLog','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','redis','defaults','localhost','\x20interaction','name','notificationSound','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','format','[%s][QUEUE]\x20%s','message','user:%s','notification:%s','save','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','busy','BUSY','online','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','\x20MAXCAPACITY','showNotification','hideNotification','checkWaitingNotifications','UserId','some','channel','QueuesWaitingInteractions','capitalize','InteractionId'];(function(_0x1e015f,_0x213a8e){var _0xbc58d=function(_0xc6817b){while(--_0xc6817b){_0x1e015f['push'](_0x1e015f['shift']());}};_0xbc58d(++_0x213a8e);}(_0xba97,0x13e));var _0x7ba9=function(_0x5c8d06,_0x2e02e6){_0x5c8d06=_0x5c8d06-0x0;var _0x1516c3=_0xba97[_0x5c8d06];return _0x1516c3;};'use strict';var _=require('lodash');var util=require(_0x7ba9('0x0'));var utils=require(_0x7ba9('0x1'));var Redis=require(_0x7ba9('0x2'));var config=require(_0x7ba9('0x3'));var logger=require(_0x7ba9('0x4'))('routing');config[_0x7ba9('0x5')]=_[_0x7ba9('0x6')](config[_0x7ba9('0x5')],{'host':_0x7ba9('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x7ba9('0x5')]));function sendNotification(_0x20fc9d,_0x448814,_0x25f2bf,_0x3c4cd8,_0xd5ce1,_0x10e303){var _0xe88e11=_0x10e303||{};var _0x52d56d=_0x25f2bf['split']('.');var _0x561d2b={'uniqueid':_0x448814,'channel':_0x52d56d[0x0],'id':_0x52d56d[0x1],'title':_0x52d56d[0x0]+_0x7ba9('0x8'),'interactionId':_0x52d56d[0x2],'queue':_0xd5ce1?_0xd5ce1[_0x7ba9('0x9')]:null,'sound':_0xe88e11['account'][_0x7ba9('0xa')],'shake':_0xe88e11['account'][_0x7ba9('0xb')]};try{if(!_0xe88e11[_0x7ba9('0xc')]){_0xe88e11[_0x7ba9('0xc')]={};}if(_0xd5ce1){_0xe88e11[_0x7ba9('0xc')][_0x7ba9('0xd')]=_0xd5ce1;}else if(_0xe88e11[_0x7ba9('0xc')][_0x7ba9('0xd')]){delete _0xe88e11[_0x7ba9('0xc')][_0x7ba9('0xd')];}_0x561d2b[_0x7ba9('0xe')]=utils[_0x7ba9('0xf')](_0xe88e11['account'][_0x7ba9('0x10')],_0xe88e11);}catch(_0x1089c7){_0x561d2b[_0x7ba9('0xe')]=_0x7ba9('0x11');logger[_0x7ba9('0x12')](util[_0x7ba9('0x13')](_0x7ba9('0x14'),_0x448814,_0x1089c7[_0x7ba9('0x15')]));}io['to'](util[_0x7ba9('0x13')](_0x7ba9('0x16'),_0x3c4cd8[_0x7ba9('0x9')]))['emit'](util[_0x7ba9('0x13')](_0x7ba9('0x17'),_0x20fc9d?_0x7ba9('0x18'):_0x7ba9('0x19')),_0x561d2b);}function writeLog(_0x1ddce8,_0x471dc2,_0x3803b3){return logger[_0x7ba9('0x1a')](util[_0x7ba9('0x13')](_0x7ba9('0x1b'),_0x1ddce8,_0x471dc2[_0x7ba9('0x9')],_0x3803b3));}exports['isAgentAvailable']=function(_0x2c0b81,_0x2951b8,_0x6af753,_0x2cce25){if(_0x2951b8[_0x7ba9('0x1c')]){writeLog(_0x2c0b81,_0x2951b8,_0x7ba9('0x1d'));return![];}if(!_0x2951b8[_0x7ba9('0x1e')]){writeLog(_0x2c0b81,_0x2951b8,_0x7ba9('0x1f'));return![];}if(_0x2951b8[_0x6af753+_0x7ba9('0x20')]){writeLog(_0x2c0b81,_0x2951b8,'PAUSE');return![];}if(_0x2cce25&&_0x2951b8[_0x7ba9('0x21')](_0x6af753+_0x7ba9('0x22'))&&_0x2951b8[_0x7ba9('0x21')](_0x6af753+_0x7ba9('0x23'))){if(_0x2951b8[_0x6af753+_0x7ba9('0x22')]>0x0&&_0x2951b8[_0x6af753+_0x7ba9('0x23')]>=_0x2951b8[_0x6af753+_0x7ba9('0x22')]){writeLog(_0x2c0b81,_0x2951b8,_0x6af753['toUpperCase']()+_0x7ba9('0x24'));return![];}}return!![];};exports[_0x7ba9('0x25')]=function(_0x925e2e,_0x485d03,_0xef6452,_0x4c5c66,_0x5a8ef8){return sendNotification(!![],_0x925e2e,_0x485d03,_0xef6452,_0x4c5c66,_0x5a8ef8);};exports[_0x7ba9('0x26')]=function(_0x28813d,_0x53e0f5,_0x49df85,_0x202c36,_0x38e21b){return sendNotification(![],_0x28813d,_0x53e0f5,_0x49df85,_0x202c36,_0x38e21b);};exports[_0x7ba9('0x27')]=function(_0x5254f8,_0x596872,_0x28f9ed){var _0x13efb4=_0x596872['interaction'][_0x7ba9('0x28')];if(!_0x13efb4&&_0x28f9ed){_0x13efb4=_0x28f9ed['id'];}var _0x304dc7=_[_0x7ba9('0x29')](_0x5254f8[_0x596872[_0x7ba9('0x2a')]+_0x7ba9('0x2b')],function(_0x5396e9){var _0x1c42bc=_[_0x7ba9('0x2c')](_0x596872[_0x7ba9('0x2a')])+_0x7ba9('0x2d');return _0x5396e9[_0x1c42bc]===_0x596872[_0x7ba9('0x2e')]['id'];});if(!_0x304dc7&&_0x13efb4&&_0x5254f8['agents'][_0x13efb4]){_0x304dc7=_[_0x7ba9('0x29')](_0x5254f8['agents'][_0x13efb4][_0x596872['channel']+'WaitingInteractions'],function(_0xd7db93){return _0xd7db93['id']===_0x596872[_0x7ba9('0x2e')]['id'];});}return _0x304dc7;};exports[_0x7ba9('0x2f')]=function(_0x457f96,_0x5a6c22,_0x3bd438,_0x2a7299){if(_0x3bd438&&_0x3bd438['id']&&_0x457f96[_0x7ba9('0x30')]&&_0x457f96[_0x7ba9('0x30')][_0x3bd438['id']]){_0x457f96[_0x7ba9('0x30')][_0x3bd438['id']][_0x2a7299+_0x7ba9('0x31')][_0x5a6c22['message']['id']]={'id':_0x5a6c22[_0x7ba9('0x2e')]['id']};}};exports[_0x7ba9('0x32')]=function(_0x530cd1,_0x339d4e,_0x5ebfa2,_0x531436){if(_0x5ebfa2&&_0x5ebfa2['id']&&_0x530cd1[_0x7ba9('0x30')]&&_0x530cd1[_0x7ba9('0x30')][_0x5ebfa2['id']]){delete _0x530cd1[_0x7ba9('0x30')][_0x5ebfa2['id']][_0x531436+'WaitingInteractions'][_0x339d4e['message']['id']];}};exports[_0x7ba9('0x33')]=writeLog;
\ No newline at end of file