fb3fad19a0cd900e791f17fcc926687a54f2b4f9
[motion2.git] / server / services / routing / server / applications / strategy / beepall.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x1c6e=['busy','debug','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','STOP','busyQueue','removeWaitingNotification','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','realtime','push','handleRun','bind','handleTimeout','timeout','drained','handleDrained','prototype','isNil','queue','Agents','length','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog'];(function(_0x3e56e7,_0xd920b5){var _0x1493af=function(_0x2fa6c4){while(--_0x2fa6c4){_0x3e56e7['push'](_0x3e56e7['shift']());}};_0x1493af(++_0xd920b5);}(_0x1c6e,0x1e5));var _0xe1c6=function(_0x47604d,_0x15a014){_0x47604d=_0x47604d-0x0;var _0x388e4c=_0x1c6e[_0x47604d];return _0x388e4c;};'use strict';var _=require(_0xe1c6('0x0'));var uuid=require(_0xe1c6('0x1'));var util=require(_0xe1c6('0x2'));var logger=require(_0xe1c6('0x3'))(_0xe1c6('0x4'));var Beepall=function(_0x110873,_0x2ecb89,_0x48d907,_0x5c5f7e){this[_0xe1c6('0x5')]=uuid['v4']();this[_0xe1c6('0x6')]=_0x110873;this['queue']=_0x2ecb89;this[_0xe1c6('0x7')]=_0x48d907;this[_0xe1c6('0x4')]=_0x5c5f7e;this[_0xe1c6('0x6')][_0xe1c6('0x8')](this[_0xe1c6('0x9')][_0xe1c6('0xa')](this),this[_0xe1c6('0xb')][_0xe1c6('0xa')](this));this[_0xe1c6('0x6')]['on'](_0xe1c6('0xc'),this[_0xe1c6('0xb')][_0xe1c6('0xa')](this));this['squeue']['on'](_0xe1c6('0xd'),this[_0xe1c6('0xe')]['bind'](this));};Beepall[_0xe1c6('0xf')][_0xe1c6('0x8')]=function(){this[_0xe1c6('0x6')][_0xe1c6('0x8')](this['handleRun'][_0xe1c6('0xa')](this),this[_0xe1c6('0xb')]['bind'](this));};Beepall[_0xe1c6('0xf')][_0xe1c6('0xe')]=function(){this['handleTimeout'](!![]);};Beepall[_0xe1c6('0xf')][_0xe1c6('0x9')]=function(){var _0x262c82=!![];if(!_[_0xe1c6('0x10')](this['queue'])&&!_['isNil'](this[_0xe1c6('0x11')][_0xe1c6('0x12')])&&this[_0xe1c6('0x11')]['Agents'][_0xe1c6('0x13')]>0x0){for(var _0x48a815=0x0,_0x211968;_0x48a815<this[_0xe1c6('0x11')][_0xe1c6('0x12')][_0xe1c6('0x13')];_0x48a815+=0x1){_0x211968=this['queue'][_0xe1c6('0x12')][_0x48a815]['id'];if(_['isNil'](this['realtime'][_0xe1c6('0x14')][_0x211968])){logger['debug'](_0xe1c6('0x15'),this[_0xe1c6('0x6')]['id'],_0x211968);}else{if(util[_0xe1c6('0x16')](this[_0xe1c6('0x6')]['id'],this[_0xe1c6('0x7')]['agents'][_0x211968],this[_0xe1c6('0x6')][_0xe1c6('0x17')],!![])){_0x262c82=![];util[_0xe1c6('0x18')](this[_0xe1c6('0x6')]['id'],this[_0xe1c6('0x7')][_0xe1c6('0x14')][_0x211968],'RINGING');this['realtime'][_0xe1c6('0x14')][_0x211968][_0xe1c6('0x19')]=!![];this[_0xe1c6('0x7')]['agents'][_0x211968]['busyQueue']=this[_0xe1c6('0x11')]['name'];util['saveWaitingNotification'](this['realtime'],this[_0xe1c6('0x4')],this[_0xe1c6('0x11')][_0xe1c6('0x12')][_0x48a815],this[_0xe1c6('0x6')][_0xe1c6('0x17')]);util['showNotification'](this['notificationId'],this[_0xe1c6('0x6')]['id'],this['realtime'][_0xe1c6('0x14')][_0x211968],this[_0xe1c6('0x11')],this[_0xe1c6('0x4')]);}}}if(_0x262c82){logger[_0xe1c6('0x1a')](_0xe1c6('0x1b'),this['squeue']['id']);setTimeout(this[_0xe1c6('0x8')]['bind'](this),0x3e8);}}else{logger[_0xe1c6('0x1a')](_0xe1c6('0x1c'),this[_0xe1c6('0x6')]['id']);setTimeout(this['push'][_0xe1c6('0xa')](this),0x3e8);}};Beepall[_0xe1c6('0xf')][_0xe1c6('0xb')]=function(_0x19e7b9){if(!_[_0xe1c6('0x10')](this[_0xe1c6('0x11')])&&!_[_0xe1c6('0x10')](this[_0xe1c6('0x11')][_0xe1c6('0x12')])){for(var _0x46c1f1=0x0,_0x3e883e;_0x46c1f1<this['queue'][_0xe1c6('0x12')][_0xe1c6('0x13')];_0x46c1f1+=0x1){_0x3e883e=this['queue']['Agents'][_0x46c1f1]['id'];if(_[_0xe1c6('0x10')](this[_0xe1c6('0x7')]['agents'][_0x3e883e])){logger['debug'](_0xe1c6('0x15'),this['squeue']['id'],_0x3e883e);}else{util[_0xe1c6('0x1d')](this[_0xe1c6('0x5')],this[_0xe1c6('0x6')]['id'],this[_0xe1c6('0x7')][_0xe1c6('0x14')][_0x3e883e],this[_0xe1c6('0x11')],this[_0xe1c6('0x4')]);util[_0xe1c6('0x18')](this[_0xe1c6('0x6')]['id'],this['realtime'][_0xe1c6('0x14')][_0x3e883e],_0x19e7b9?_0xe1c6('0x1e'):'TIMEOUT');this[_0xe1c6('0x7')][_0xe1c6('0x14')][_0x3e883e][_0xe1c6('0x19')]=![];this[_0xe1c6('0x7')][_0xe1c6('0x14')][_0x3e883e][_0xe1c6('0x1f')]=undefined;util[_0xe1c6('0x20')](this['realtime'],this[_0xe1c6('0x4')],this[_0xe1c6('0x7')]['agents'][_0x3e883e],this[_0xe1c6('0x6')][_0xe1c6('0x17')]);}}}if(!_0x19e7b9){setTimeout(this[_0xe1c6('0x8')][_0xe1c6('0xa')](this),0x3e8);}};function beepall(_0x43785d,_0x4ea459,_0x1edf78,_0x4c6e04){return new Beepall(_0x43785d,_0x4ea459,_0x1edf78,_0x4c6e04);}module[_0xe1c6('0x21')]=beepall;