Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / services / routing / server / applications / strategy / util.js
index 4c0a425..2c0deb2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2eb2=['Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','hideNotification','writeLog','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','defaults','socket.io-emitter','redis','format','user:%s','name','emit','account','notificationShake','body','queue','getMustacheRender','I\x20can\x27t\x20render\x20your\x20template','[%s][QUEUE]\x20%s','notification:%s','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE'];(function(_0xc3a264,_0x1a7dbf){var _0x5d62b7=function(_0x1cd21b){while(--_0x1cd21b){_0xc3a264['push'](_0xc3a264['shift']());}};_0x5d62b7(++_0x1a7dbf);}(_0x2eb2,0x19f));var _0x22eb=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0x2eb2[_0x5b644e];return _0x49c6bf;};'use strict';var _=require('lodash');var util=require(_0x22eb('0x0'));var utils=require(_0x22eb('0x1'));var Redis=require(_0x22eb('0x2'));var config=require(_0x22eb('0x3'));var logger=require(_0x22eb('0x4'))(_0x22eb('0x5'));config['redis']=_[_0x22eb('0x6')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x22eb('0x7'))(new Redis(config[_0x22eb('0x8')]));function sendNotification(_0x35dd5b,_0x2a9850,_0x4539d0,_0x396806,_0x33ddef,_0x3375d6){io['to'](util[_0x22eb('0x9')](_0x22eb('0xa'),_0x396806[_0x22eb('0xb')]))[_0x22eb('0xc')]('user:save',_0x396806);var _0x46c197=_0x3375d6||{};var _0x54342e=_0x4539d0['split']('.');var _0x1aa348={'uniqueid':_0x2a9850,'channel':_0x54342e[0x0],'id':_0x54342e[0x1],'title':_0x54342e[0x0]+'\x20interaction','interactionId':_0x54342e[0x2],'queue':_0x33ddef?_0x33ddef[_0x22eb('0xb')]:null,'sound':_0x46c197[_0x22eb('0xd')]['notificationSound'],'shake':_0x46c197['account'][_0x22eb('0xe')]};try{if(!_0x46c197[_0x22eb('0xf')]){_0x46c197[_0x22eb('0xf')]={};}if(_0x33ddef){_0x46c197[_0x22eb('0xf')][_0x22eb('0x10')]=_0x33ddef;}else if(_0x46c197['body'][_0x22eb('0x10')]){delete _0x46c197['body'][_0x22eb('0x10')];}_0x1aa348['msg']=utils[_0x22eb('0x11')](_0x46c197[_0x22eb('0xd')]['notificationTemplate'],_0x46c197);}catch(_0x48b63c){_0x1aa348['msg']=_0x22eb('0x12');logger['error'](util['format'](_0x22eb('0x13'),_0x2a9850,_0x48b63c['message']));}io['to'](util['format'](_0x22eb('0xa'),_0x396806[_0x22eb('0xb')]))[_0x22eb('0xc')](util[_0x22eb('0x9')](_0x22eb('0x14'),_0x35dd5b?'save':_0x22eb('0x15')),_0x1aa348);}function writeLog(_0x12bbd1,_0x10d182,_0x410c25){return logger[_0x22eb('0x16')](util['format'](_0x22eb('0x17'),_0x12bbd1,_0x10d182[_0x22eb('0xb')],_0x410c25));}exports[_0x22eb('0x18')]=function(_0x49ce2a,_0x490b34,_0x4335b7,_0x267d97){if(_0x490b34[_0x22eb('0x19')]){writeLog(_0x49ce2a,_0x490b34,_0x22eb('0x1a'));return![];}if(!_0x490b34[_0x22eb('0x1b')]){writeLog(_0x49ce2a,_0x490b34,_0x22eb('0x1c'));return![];}if(_0x490b34[_0x4335b7+_0x22eb('0x1d')]){writeLog(_0x49ce2a,_0x490b34,'PAUSE');return![];}if(_0x267d97&&_0x490b34[_0x22eb('0x1e')](_0x4335b7+_0x22eb('0x1f'))&&_0x490b34[_0x22eb('0x1e')](_0x4335b7+_0x22eb('0x20'))){if(_0x490b34[_0x4335b7+_0x22eb('0x1f')]>0x0&&_0x490b34[_0x4335b7+'CurrentCapacity']>=_0x490b34[_0x4335b7+_0x22eb('0x1f')]){writeLog(_0x49ce2a,_0x490b34,_0x4335b7[_0x22eb('0x21')]()+_0x22eb('0x22'));return![];}}return!![];};exports['showNotification']=function(_0xe0783c,_0x259847,_0x4b409a,_0x32a4b6,_0x222ef3){return sendNotification(!![],_0xe0783c,_0x259847,_0x4b409a,_0x32a4b6,_0x222ef3);};exports[_0x22eb('0x23')]=function(_0x2924f6,_0x2da5c6,_0x4f4f56,_0x49dd59,_0x2a950e){return sendNotification(![],_0x2924f6,_0x2da5c6,_0x4f4f56,_0x49dd59,_0x2a950e);};exports[_0x22eb('0x24')]=writeLog;
\ No newline at end of file
+var _0xdcc4=['PAUSE','Capacity','hasOwnProperty','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','checkWaitingNotifications','UserId','channel','capitalize','InteractionId','interaction','agents','some','WaitingInteractions','saveWaitingNotification','removeWaitingNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','routing','redis','defaults','localhost','socket.io-emitter','user:%s','name','emit','user:save','split','account','notificationShake','body','queue','msg','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','[%s][QUEUE]\x20%s','message','format','save','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','BUSY','online','OFFLINE','Pause'];(function(_0x3d1895,_0x1c207b){var _0x5b6663=function(_0x50ca20){while(--_0x50ca20){_0x3d1895['push'](_0x3d1895['shift']());}};_0x5b6663(++_0x1c207b);}(_0xdcc4,0xea));var _0x4dcc=function(_0x13f741,_0x113a37){_0x13f741=_0x13f741-0x0;var _0x1be8f5=_0xdcc4[_0x13f741];return _0x1be8f5;};'use strict';var _=require(_0x4dcc('0x0'));var util=require(_0x4dcc('0x1'));var utils=require(_0x4dcc('0x2'));var Redis=require(_0x4dcc('0x3'));var config=require(_0x4dcc('0x4'));var logger=require('../../../../../config/logger')(_0x4dcc('0x5'));config[_0x4dcc('0x6')]=_[_0x4dcc('0x7')](config[_0x4dcc('0x6')],{'host':_0x4dcc('0x8'),'port':0x18eb});var io=require(_0x4dcc('0x9'))(new Redis(config['redis']));function sendNotification(_0x1f8ef7,_0x5561be,_0x3392ef,_0x1634f2,_0x461e9c,_0x165bf5){io['to'](util['format'](_0x4dcc('0xa'),_0x1634f2[_0x4dcc('0xb')]))[_0x4dcc('0xc')](_0x4dcc('0xd'),_0x1634f2);var _0x7ad844=_0x165bf5||{};var _0x227f00=_0x3392ef[_0x4dcc('0xe')]('.');var _0x43e361={'uniqueid':_0x5561be,'channel':_0x227f00[0x0],'id':_0x227f00[0x1],'title':_0x227f00[0x0]+'\x20interaction','interactionId':_0x227f00[0x2],'queue':_0x461e9c?_0x461e9c[_0x4dcc('0xb')]:null,'sound':_0x7ad844[_0x4dcc('0xf')]['notificationSound'],'shake':_0x7ad844[_0x4dcc('0xf')][_0x4dcc('0x10')]};try{if(!_0x7ad844['body']){_0x7ad844[_0x4dcc('0x11')]={};}if(_0x461e9c){_0x7ad844[_0x4dcc('0x11')][_0x4dcc('0x12')]=_0x461e9c;}else if(_0x7ad844[_0x4dcc('0x11')][_0x4dcc('0x12')]){delete _0x7ad844[_0x4dcc('0x11')][_0x4dcc('0x12')];}_0x43e361[_0x4dcc('0x13')]=utils['getMustacheRender'](_0x7ad844['account'][_0x4dcc('0x14')],_0x7ad844);}catch(_0x407072){_0x43e361[_0x4dcc('0x13')]=_0x4dcc('0x15');logger[_0x4dcc('0x16')](util['format'](_0x4dcc('0x17'),_0x5561be,_0x407072[_0x4dcc('0x18')]));}io['to'](util['format']('user:%s',_0x1634f2['name']))[_0x4dcc('0xc')](util[_0x4dcc('0x19')]('notification:%s',_0x1f8ef7?_0x4dcc('0x1a'):_0x4dcc('0x1b')),_0x43e361);}function writeLog(_0x25157f,_0x548f24,_0x27cb11){return logger[_0x4dcc('0x1c')](util[_0x4dcc('0x19')](_0x4dcc('0x1d'),_0x25157f,_0x548f24[_0x4dcc('0xb')],_0x27cb11));}exports[_0x4dcc('0x1e')]=function(_0x44ae9e,_0x3c6d3b,_0x1b2834,_0x1ed6d0){if(_0x3c6d3b[_0x4dcc('0x1f')]){writeLog(_0x44ae9e,_0x3c6d3b,_0x4dcc('0x20'));return![];}if(!_0x3c6d3b[_0x4dcc('0x21')]){writeLog(_0x44ae9e,_0x3c6d3b,_0x4dcc('0x22'));return![];}if(_0x3c6d3b[_0x1b2834+_0x4dcc('0x23')]){writeLog(_0x44ae9e,_0x3c6d3b,_0x4dcc('0x24'));return![];}if(_0x1ed6d0&&_0x3c6d3b['hasOwnProperty'](_0x1b2834+_0x4dcc('0x25'))&&_0x3c6d3b[_0x4dcc('0x26')](_0x1b2834+_0x4dcc('0x27'))){if(_0x3c6d3b[_0x1b2834+'Capacity']>0x0&&_0x3c6d3b[_0x1b2834+_0x4dcc('0x27')]>=_0x3c6d3b[_0x1b2834+'Capacity']){writeLog(_0x44ae9e,_0x3c6d3b,_0x1b2834[_0x4dcc('0x28')]()+_0x4dcc('0x29'));return![];}}return!![];};exports['showNotification']=function(_0x3853ae,_0x2afff8,_0x4fb23c,_0x388cc2,_0x288514){return sendNotification(!![],_0x3853ae,_0x2afff8,_0x4fb23c,_0x388cc2,_0x288514);};exports['hideNotification']=function(_0x488bf3,_0x110911,_0x1aac81,_0x160805,_0x562d1f){return sendNotification(![],_0x488bf3,_0x110911,_0x1aac81,_0x160805,_0x562d1f);};exports[_0x4dcc('0x2a')]=function(_0x5c2464,_0x2ffac7,_0x279524){var _0x45b0d5=_0x2ffac7['interaction'][_0x4dcc('0x2b')];if(!_0x45b0d5&&_0x279524){_0x45b0d5=_0x279524['id'];}var _0x4dd2e6=_['some'](_0x5c2464[_0x2ffac7[_0x4dcc('0x2c')]+'QueuesWaitingInteractions'],function(_0x39ce82){var _0x213c95=_[_0x4dcc('0x2d')](_0x2ffac7[_0x4dcc('0x2c')])+_0x4dcc('0x2e');return _0x39ce82[_0x213c95]===_0x2ffac7[_0x4dcc('0x2f')]['id'];});if(!_0x4dd2e6&&_0x45b0d5&&_0x5c2464[_0x4dcc('0x30')][_0x45b0d5]){_0x4dd2e6=_[_0x4dcc('0x31')](_0x5c2464[_0x4dcc('0x30')][_0x45b0d5][_0x2ffac7[_0x4dcc('0x2c')]+_0x4dcc('0x32')],function(_0x5686a9){return _0x5686a9['id']===_0x2ffac7['interaction']['id'];});}return _0x4dd2e6;};exports[_0x4dcc('0x33')]=function(_0x53e80a,_0x3a88ac,_0x445087,_0x3656fe){if(_0x445087&&_0x445087['id']&&_0x53e80a[_0x4dcc('0x30')]&&_0x53e80a[_0x4dcc('0x30')][_0x445087['id']]){_0x53e80a[_0x4dcc('0x30')][_0x445087['id']][_0x3656fe+_0x4dcc('0x32')][_0x3a88ac[_0x4dcc('0x18')]['id']]={'id':_0x3a88ac['interaction']['id']};}};exports[_0x4dcc('0x34')]=function(_0x5698b8,_0x6722ca,_0x53b522,_0x333fb8){if(_0x53b522&&_0x53b522['id']&&_0x5698b8['agents']&&_0x5698b8[_0x4dcc('0x30')][_0x53b522['id']]){delete _0x5698b8[_0x4dcc('0x30')][_0x53b522['id']][_0x333fb8+_0x4dcc('0x32')][_0x6722ca[_0x4dcc('0x18')]['id']];}};exports[_0x4dcc('0x35')]=writeLog;
\ No newline at end of file