Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / services / routing / server / applications / strategy / util.js
index d669cbc..8157234 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ace=['\x20MAXCAPACITY','showNotification','hideNotification','writeLog','lodash','util','../utils','mustache','ioredis','../../../../../config/environment','../../../../../config/logger','routing','redis','defaults','localhost','socket.io-emitter','format','user:%s','name','user:save','\x20interaction','account','notificationSound','notificationShake','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','emit','notification:%s','save','info','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity'];(function(_0x53ccf2,_0x13cb67){var _0x5a2964=function(_0x3b0514){while(--_0x3b0514){_0x53ccf2['push'](_0x53ccf2['shift']());}};_0x5a2964(++_0x13cb67);}(_0x8ace,0x1bc));var _0xe8ac=function(_0x27c28c,_0x49ba23){_0x27c28c=_0x27c28c-0x0;var _0x1f5669=_0x8ace[_0x27c28c];return _0x1f5669;};'use strict';var _=require(_0xe8ac('0x0'));var util=require(_0xe8ac('0x1'));var utils=require(_0xe8ac('0x2'));var Mustache=require(_0xe8ac('0x3'));var Redis=require(_0xe8ac('0x4'));var config=require(_0xe8ac('0x5'));var logger=require(_0xe8ac('0x6'))(_0xe8ac('0x7'));config[_0xe8ac('0x8')]=_[_0xe8ac('0x9')](config[_0xe8ac('0x8')],{'host':_0xe8ac('0xa'),'port':0x18eb});var io=require(_0xe8ac('0xb'))(new Redis(config[_0xe8ac('0x8')]));function emit(_0x4eb087,_0x2d56f0,_0x1357ed){io['to'](_0x4eb087)['emit'](_0x2d56f0,_0x1357ed);}function sendNotification(_0x5c83e1,_0x4644ef,_0x513793,_0x1b5467,_0x271fdb,_0x19d9c8){io['to'](util[_0xe8ac('0xc')](_0xe8ac('0xd'),_0x1b5467[_0xe8ac('0xe')]))['emit'](_0xe8ac('0xf'),_0x1b5467);var _0x2e3b25=_0x19d9c8||{};var _0x1f71ff=_0x513793['split']('.');var _0x15b0cf={'uniqueid':_0x4644ef,'channel':_0x1f71ff[0x0],'id':_0x1f71ff[0x1],'title':_0x1f71ff[0x0]+_0xe8ac('0x10'),'interactionId':_0x1f71ff[0x2],'queue':_0x271fdb?_0x271fdb['name']:null,'sound':_0x2e3b25[_0xe8ac('0x11')][_0xe8ac('0x12')],'shake':_0x2e3b25[_0xe8ac('0x11')][_0xe8ac('0x13')]};try{if(!_0x2e3b25[_0xe8ac('0x14')]){_0x2e3b25[_0xe8ac('0x14')]={};}if(_0x271fdb){_0x2e3b25[_0xe8ac('0x14')][_0xe8ac('0x15')]=_0x271fdb;}else if(_0x2e3b25[_0xe8ac('0x14')][_0xe8ac('0x15')]){delete _0x2e3b25['body'][_0xe8ac('0x15')];}_0x15b0cf[_0xe8ac('0x16')]=utils['getMustacheRender'](_0x2e3b25[_0xe8ac('0x11')][_0xe8ac('0x17')],_0x2e3b25);}catch(_0x1421df){_0x15b0cf[_0xe8ac('0x16')]=_0xe8ac('0x18');logger[_0xe8ac('0x19')](util['format']('[%s][QUEUE]\x20%s',_0x4644ef,_0x1421df['message']));}io['to'](util[_0xe8ac('0xc')](_0xe8ac('0xd'),_0x1b5467['name']))[_0xe8ac('0x1a')](util['format'](_0xe8ac('0x1b'),_0x5c83e1?_0xe8ac('0x1c'):'remove'),_0x15b0cf);}function writeLog(_0x6258f8,_0x169929,_0x13aa7c){return logger[_0xe8ac('0x1d')](util['format'](_0xe8ac('0x1e'),_0x6258f8,_0x169929['name'],_0x13aa7c));}exports[_0xe8ac('0x1f')]=function(_0x3933d2,_0x3c3a78,_0x252440,_0x36108c){if(_0x3c3a78[_0xe8ac('0x20')]){writeLog(_0x3933d2,_0x3c3a78,_0xe8ac('0x21'));return![];}if(!_0x3c3a78['online']){writeLog(_0x3933d2,_0x3c3a78,_0xe8ac('0x22'));return![];}if(_0x3c3a78[_0x252440+_0xe8ac('0x23')]){writeLog(_0x3933d2,_0x3c3a78,_0xe8ac('0x24'));return![];}if(_0x36108c&&_0x3c3a78[_0xe8ac('0x25')](_0x252440+_0xe8ac('0x26'))&&_0x3c3a78[_0xe8ac('0x25')](_0x252440+_0xe8ac('0x27'))){if(_0x3c3a78[_0x252440+_0xe8ac('0x26')]>0x0&&_0x3c3a78[_0x252440+_0xe8ac('0x27')]>=_0x3c3a78[_0x252440+'Capacity']){writeLog(_0x3933d2,_0x3c3a78,_0x252440['toUpperCase']()+_0xe8ac('0x28'));return![];}}return!![];};exports[_0xe8ac('0x29')]=function(_0x59512c,_0x2a78c6,_0x5948aa,_0x54f94c,_0x4c1d08){return sendNotification(!![],_0x59512c,_0x2a78c6,_0x5948aa,_0x54f94c,_0x4c1d08);};exports[_0xe8ac('0x2a')]=function(_0x41294e,_0x3798c5,_0x5d7562,_0x156550,_0x41ffe8){return sendNotification(![],_0x41294e,_0x3798c5,_0x5d7562,_0x156550,_0x41ffe8);};exports[_0xe8ac('0x2b')]=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