Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / services / routing / server / applications / strategy / util.js
index 425d195..e2e590b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe547=['toUpperCase','showNotification','hideNotification','checkWaitingNotifications','interaction','UserId','some','channel','QueuesWaitingInteractions','capitalize','InteractionId','agents','WaitingInteractions','saveWaitingNotification','removeWaitingNotification','writeLog','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','routing','defaults','redis','localhost','socket.io-emitter','split','\x20interaction','name','account','notificationSound','notificationShake','body','queue','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','format','[%s][QUEUE]\x20%s','message','emit','notification:%s','save','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy','online','OFFLINE','Pause','PAUSE','hasOwnProperty','Capacity','CurrentCapacity'];(function(_0x20cced,_0x4e5560){var _0x47ee35=function(_0xe03c28){while(--_0xe03c28){_0x20cced['push'](_0x20cced['shift']());}};_0x47ee35(++_0x4e5560);}(_0xe547,0x191));var _0x7e54=function(_0xe078c6,_0x3a5eb4){_0xe078c6=_0xe078c6-0x0;var _0x428a9e=_0xe547[_0xe078c6];return _0x428a9e;};'use strict';var _=require('lodash');var util=require('util');var utils=require(_0x7e54('0x0'));var Redis=require(_0x7e54('0x1'));var config=require(_0x7e54('0x2'));var logger=require(_0x7e54('0x3'))(_0x7e54('0x4'));config['redis']=_[_0x7e54('0x5')](config[_0x7e54('0x6')],{'host':_0x7e54('0x7'),'port':0x18eb});var io=require(_0x7e54('0x8'))(new Redis(config[_0x7e54('0x6')]));function sendNotification(_0x3c99e0,_0x3fa88e,_0x536333,_0x160c07,_0x1b220e,_0x10c0a7){var _0x2afc1f=_0x10c0a7||{};var _0x2ff95c=_0x536333[_0x7e54('0x9')]('.');var _0x38d0af={'uniqueid':_0x3fa88e,'channel':_0x2ff95c[0x0],'id':_0x2ff95c[0x1],'title':_0x2ff95c[0x0]+_0x7e54('0xa'),'interactionId':_0x2ff95c[0x2],'queue':_0x1b220e?_0x1b220e[_0x7e54('0xb')]:null,'sound':_0x2afc1f[_0x7e54('0xc')][_0x7e54('0xd')],'shake':_0x2afc1f[_0x7e54('0xc')][_0x7e54('0xe')]};try{if(!_0x2afc1f[_0x7e54('0xf')]){_0x2afc1f[_0x7e54('0xf')]={};}if(_0x1b220e){_0x2afc1f['body'][_0x7e54('0x10')]=_0x1b220e;}else if(_0x2afc1f[_0x7e54('0xf')][_0x7e54('0x10')]){delete _0x2afc1f['body'][_0x7e54('0x10')];}_0x38d0af[_0x7e54('0x11')]=utils[_0x7e54('0x12')](_0x2afc1f[_0x7e54('0xc')][_0x7e54('0x13')],_0x2afc1f);}catch(_0x49efbf){_0x38d0af['msg']=_0x7e54('0x14');logger['error'](util[_0x7e54('0x15')](_0x7e54('0x16'),_0x3fa88e,_0x49efbf[_0x7e54('0x17')]));}io['to'](util[_0x7e54('0x15')]('user:%s',_0x160c07['name']))[_0x7e54('0x18')](util['format'](_0x7e54('0x19'),_0x3c99e0?_0x7e54('0x1a'):_0x7e54('0x1b')),_0x38d0af);}function writeLog(_0x329c12,_0x47eec0,_0x285c84){return logger[_0x7e54('0x1c')](util[_0x7e54('0x15')](_0x7e54('0x1d'),_0x329c12,_0x47eec0['name'],_0x285c84));}exports[_0x7e54('0x1e')]=function(_0x381574,_0x1ae074,_0x10ed71,_0x5117a6){if(_0x1ae074[_0x7e54('0x1f')]){writeLog(_0x381574,_0x1ae074,'BUSY');return![];}if(!_0x1ae074[_0x7e54('0x20')]){writeLog(_0x381574,_0x1ae074,_0x7e54('0x21'));return![];}if(_0x1ae074[_0x10ed71+_0x7e54('0x22')]){writeLog(_0x381574,_0x1ae074,_0x7e54('0x23'));return![];}if(_0x5117a6&&_0x1ae074[_0x7e54('0x24')](_0x10ed71+_0x7e54('0x25'))&&_0x1ae074[_0x7e54('0x24')](_0x10ed71+_0x7e54('0x26'))){if(_0x1ae074[_0x10ed71+'Capacity']>0x0&&_0x1ae074[_0x10ed71+'CurrentCapacity']>=_0x1ae074[_0x10ed71+'Capacity']){writeLog(_0x381574,_0x1ae074,_0x10ed71[_0x7e54('0x27')]()+'\x20MAXCAPACITY');return![];}}return!![];};exports[_0x7e54('0x28')]=function(_0x383f7e,_0x66ddc9,_0x3f4f7e,_0x588fb0,_0x3cced4){return sendNotification(!![],_0x383f7e,_0x66ddc9,_0x3f4f7e,_0x588fb0,_0x3cced4);};exports[_0x7e54('0x29')]=function(_0x193bf6,_0xe35c2a,_0x1f0683,_0x2f11cd,_0x54c742){return sendNotification(![],_0x193bf6,_0xe35c2a,_0x1f0683,_0x2f11cd,_0x54c742);};exports[_0x7e54('0x2a')]=function(_0x36f971,_0x5d6fa1,_0x5a35b2){var _0xa4da44=_0x5d6fa1[_0x7e54('0x2b')][_0x7e54('0x2c')];if(!_0xa4da44&&_0x5a35b2){_0xa4da44=_0x5a35b2['id'];}var _0x174806=_[_0x7e54('0x2d')](_0x36f971[_0x5d6fa1[_0x7e54('0x2e')]+_0x7e54('0x2f')],function(_0x3b9c8f){var _0x5b6497=_[_0x7e54('0x30')](_0x5d6fa1[_0x7e54('0x2e')])+_0x7e54('0x31');return _0x3b9c8f[_0x5b6497]===_0x5d6fa1[_0x7e54('0x2b')]['id'];});if(!_0x174806&&_0xa4da44&&_0x36f971['agents'][_0xa4da44]){_0x174806=_['some'](_0x36f971[_0x7e54('0x32')][_0xa4da44][_0x5d6fa1[_0x7e54('0x2e')]+_0x7e54('0x33')],function(_0x9618f6){return _0x9618f6['id']===_0x5d6fa1[_0x7e54('0x2b')]['id'];});}return _0x174806;};exports[_0x7e54('0x34')]=function(_0x1ae144,_0x426a33,_0x4cd5fe,_0x41bbe8){if(_0x4cd5fe&&_0x4cd5fe['id']&&_0x1ae144[_0x7e54('0x32')]&&_0x1ae144[_0x7e54('0x32')][_0x4cd5fe['id']]){_0x1ae144[_0x7e54('0x32')][_0x4cd5fe['id']][_0x41bbe8+_0x7e54('0x33')][_0x426a33[_0x7e54('0x17')]['id']]={'id':_0x426a33[_0x7e54('0x2b')]['id']};}};exports[_0x7e54('0x35')]=function(_0x11ae37,_0x30a1a0,_0x596c3b,_0x14df2a){if(_0x596c3b&&_0x596c3b['id']&&_0x11ae37['agents']&&_0x11ae37['agents'][_0x596c3b['id']]){delete _0x11ae37[_0x7e54('0x32')][_0x596c3b['id']][_0x14df2a+_0x7e54('0x33')][_0x30a1a0['message']['id']];}};exports[_0x7e54('0x36')]=writeLog;
\ No newline at end of file
+var _0xa1b4=['BUSY','online','OFFLINE','Pause','hasOwnProperty','Capacity','CurrentCapacity','toUpperCase','\x20MAXCAPACITY','showNotification','hideNotification','interaction','UserId','some','channel','QueuesWaitingInteractions','InteractionId','agents','WaitingInteractions','removeWaitingNotification','writeLog','lodash','util','../utils','ioredis','../../../../../config/environment','../../../../../config/logger','defaults','redis','localhost','socket.io-emitter','split','name','account','notificationSound','notificationShake','queue','body','msg','getMustacheRender','notificationTemplate','I\x20can\x27t\x20render\x20your\x20template','error','format','[%s][QUEUE]\x20%s','message','user:%s','emit','notification:%s','save','remove','debug','[%s][QUEUE][AGENT:%s][STATUS:%s]','isAgentAvailable','busy'];(function(_0x3d42d8,_0x4cffaa){var _0x27fc41=function(_0x3a363b){while(--_0x3a363b){_0x3d42d8['push'](_0x3d42d8['shift']());}};_0x27fc41(++_0x4cffaa);}(_0xa1b4,0x83));var _0x4a1b=function(_0x39bfb6,_0x4272c8){_0x39bfb6=_0x39bfb6-0x0;var _0x23fef9=_0xa1b4[_0x39bfb6];return _0x23fef9;};'use strict';var _=require(_0x4a1b('0x0'));var util=require(_0x4a1b('0x1'));var utils=require(_0x4a1b('0x2'));var Redis=require(_0x4a1b('0x3'));var config=require(_0x4a1b('0x4'));var logger=require(_0x4a1b('0x5'))('routing');config['redis']=_[_0x4a1b('0x6')](config[_0x4a1b('0x7')],{'host':_0x4a1b('0x8'),'port':0x18eb});var io=require(_0x4a1b('0x9'))(new Redis(config[_0x4a1b('0x7')]));function sendNotification(_0x509ec1,_0x30581a,_0x243f36,_0x5a7388,_0x44e31f,_0x13cae9){var _0x4d6f2b=_0x13cae9||{};var _0x21b221=_0x243f36[_0x4a1b('0xa')]('.');var _0x4cba75={'uniqueid':_0x30581a,'channel':_0x21b221[0x0],'id':_0x21b221[0x1],'title':_0x21b221[0x0]+'\x20interaction','interactionId':_0x21b221[0x2],'queue':_0x44e31f?_0x44e31f[_0x4a1b('0xb')]:null,'sound':_0x4d6f2b[_0x4a1b('0xc')][_0x4a1b('0xd')],'shake':_0x4d6f2b['account'][_0x4a1b('0xe')]};try{if(!_0x4d6f2b['body']){_0x4d6f2b['body']={};}if(_0x44e31f){_0x4d6f2b['body'][_0x4a1b('0xf')]=_0x44e31f;}else if(_0x4d6f2b[_0x4a1b('0x10')]['queue']){delete _0x4d6f2b[_0x4a1b('0x10')][_0x4a1b('0xf')];}_0x4cba75[_0x4a1b('0x11')]=utils[_0x4a1b('0x12')](_0x4d6f2b[_0x4a1b('0xc')][_0x4a1b('0x13')],_0x4d6f2b);}catch(_0x103f44){_0x4cba75['msg']=_0x4a1b('0x14');logger[_0x4a1b('0x15')](util[_0x4a1b('0x16')](_0x4a1b('0x17'),_0x30581a,_0x103f44[_0x4a1b('0x18')]));}io['to'](util[_0x4a1b('0x16')](_0x4a1b('0x19'),_0x5a7388['name']))[_0x4a1b('0x1a')](util['format'](_0x4a1b('0x1b'),_0x509ec1?_0x4a1b('0x1c'):_0x4a1b('0x1d')),_0x4cba75);}function writeLog(_0x3a84e9,_0x5ada51,_0x88d1a2){return logger[_0x4a1b('0x1e')](util['format'](_0x4a1b('0x1f'),_0x3a84e9,_0x5ada51['name'],_0x88d1a2));}exports[_0x4a1b('0x20')]=function(_0x47551e,_0x135ca1,_0x10e245,_0x254ea3){if(_0x135ca1[_0x4a1b('0x21')]){writeLog(_0x47551e,_0x135ca1,_0x4a1b('0x22'));return![];}if(!_0x135ca1[_0x4a1b('0x23')]){writeLog(_0x47551e,_0x135ca1,_0x4a1b('0x24'));return![];}if(_0x135ca1[_0x10e245+_0x4a1b('0x25')]){writeLog(_0x47551e,_0x135ca1,'PAUSE');return![];}if(_0x254ea3&&_0x135ca1[_0x4a1b('0x26')](_0x10e245+_0x4a1b('0x27'))&&_0x135ca1[_0x4a1b('0x26')](_0x10e245+_0x4a1b('0x28'))){if(_0x135ca1[_0x10e245+_0x4a1b('0x27')]>0x0&&_0x135ca1[_0x10e245+_0x4a1b('0x28')]>=_0x135ca1[_0x10e245+_0x4a1b('0x27')]){writeLog(_0x47551e,_0x135ca1,_0x10e245[_0x4a1b('0x29')]()+_0x4a1b('0x2a'));return![];}}return!![];};exports[_0x4a1b('0x2b')]=function(_0x2ec4e5,_0x169525,_0x3336a8,_0x19eb98,_0x59bc18){return sendNotification(!![],_0x2ec4e5,_0x169525,_0x3336a8,_0x19eb98,_0x59bc18);};exports[_0x4a1b('0x2c')]=function(_0x2ab164,_0x1d1860,_0x260395,_0x4e1ebd,_0x3f5701){return sendNotification(![],_0x2ab164,_0x1d1860,_0x260395,_0x4e1ebd,_0x3f5701);};exports['checkWaitingNotifications']=function(_0x3d9b31,_0x259163,_0x219bef){var _0x68a8fc=_0x259163[_0x4a1b('0x2d')][_0x4a1b('0x2e')];if(!_0x68a8fc&&_0x219bef){_0x68a8fc=_0x219bef['id'];}var _0x26d080=_[_0x4a1b('0x2f')](_0x3d9b31[_0x259163[_0x4a1b('0x30')]+_0x4a1b('0x31')],function(_0x5f0f1b){var _0x1515f2=_['capitalize'](_0x259163[_0x4a1b('0x30')])+_0x4a1b('0x32');return _0x5f0f1b[_0x1515f2]===_0x259163[_0x4a1b('0x2d')]['id'];});if(!_0x26d080&&_0x68a8fc&&_0x3d9b31[_0x4a1b('0x33')][_0x68a8fc]){_0x26d080=_['some'](_0x3d9b31['agents'][_0x68a8fc][_0x259163[_0x4a1b('0x30')]+_0x4a1b('0x34')],function(_0x28ed41){return _0x28ed41['id']===_0x259163['interaction']['id'];});}return _0x26d080;};exports['saveWaitingNotification']=function(_0x31f4fd,_0x210476,_0x1464d7,_0x16c3bf){if(_0x1464d7&&_0x1464d7['id']&&_0x31f4fd[_0x4a1b('0x33')]&&_0x31f4fd['agents'][_0x1464d7['id']]){_0x31f4fd['agents'][_0x1464d7['id']][_0x16c3bf+'WaitingInteractions'][_0x210476[_0x4a1b('0x18')]['id']]={'id':_0x210476['interaction']['id']};}};exports[_0x4a1b('0x35')]=function(_0x420690,_0x2b4a21,_0x29f027,_0x21f0bb){if(_0x29f027&&_0x29f027['id']&&_0x420690['agents']&&_0x420690[_0x4a1b('0x33')][_0x29f027['id']]){delete _0x420690[_0x4a1b('0x33')][_0x29f027['id']][_0x21f0bb+'WaitingInteractions'][_0x2b4a21['message']['id']];}};exports[_0x4a1b('0x36')]=writeLog;
\ No newline at end of file