fcbb15d452c4253268e291b2b7b16b9a00377268
[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 _0x8d9e=['busy','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','STOP','TIMEOUT','busyQueue','removeWaitingNotification','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','realtime','handleRun','bind','handleTimeout','timeout','drained','handleDrained','prototype','push','isNil','queue','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING'];(function(_0x42dfd1,_0x13f4d4){var _0x3b573c=function(_0x4de267){while(--_0x4de267){_0x42dfd1['push'](_0x42dfd1['shift']());}};_0x3b573c(++_0x13f4d4);}(_0x8d9e,0x1eb));var _0xe8d9=function(_0x443111,_0x3c94ae){_0x443111=_0x443111-0x0;var _0x3056c5=_0x8d9e[_0x443111];return _0x3056c5;};'use strict';var _=require(_0xe8d9('0x0'));var uuid=require(_0xe8d9('0x1'));var util=require(_0xe8d9('0x2'));var logger=require(_0xe8d9('0x3'))(_0xe8d9('0x4'));var Beepall=function(_0x1551ca,_0x2cb971,_0xdf447d,_0x41f802){this[_0xe8d9('0x5')]=uuid['v4']();this[_0xe8d9('0x6')]=_0x1551ca;this['queue']=_0x2cb971;this[_0xe8d9('0x7')]=_0xdf447d;this[_0xe8d9('0x4')]=_0x41f802;this[_0xe8d9('0x6')]['push'](this[_0xe8d9('0x8')][_0xe8d9('0x9')](this),this[_0xe8d9('0xa')]['bind'](this));this['squeue']['on'](_0xe8d9('0xb'),this[_0xe8d9('0xa')]['bind'](this));this[_0xe8d9('0x6')]['on'](_0xe8d9('0xc'),this[_0xe8d9('0xd')][_0xe8d9('0x9')](this));};Beepall[_0xe8d9('0xe')]['push']=function(){this['squeue'][_0xe8d9('0xf')](this[_0xe8d9('0x8')][_0xe8d9('0x9')](this),this['handleTimeout'][_0xe8d9('0x9')](this));};Beepall[_0xe8d9('0xe')]['handleDrained']=function(){this[_0xe8d9('0xa')](!![]);};Beepall[_0xe8d9('0xe')][_0xe8d9('0x8')]=function(){var _0x650ad7=!![];if(!_[_0xe8d9('0x10')](this[_0xe8d9('0x11')])&&!_['isNil'](this[_0xe8d9('0x11')][_0xe8d9('0x12')])&&this[_0xe8d9('0x11')]['Agents'][_0xe8d9('0x13')]>0x0){for(var _0x2e5f42=0x0,_0x35f684;_0x2e5f42<this[_0xe8d9('0x11')][_0xe8d9('0x12')][_0xe8d9('0x13')];_0x2e5f42+=0x1){_0x35f684=this[_0xe8d9('0x11')][_0xe8d9('0x12')][_0x2e5f42]['id'];if(_[_0xe8d9('0x10')](this[_0xe8d9('0x7')][_0xe8d9('0x14')][_0x35f684])){logger[_0xe8d9('0x15')](_0xe8d9('0x16'),this[_0xe8d9('0x6')]['id'],_0x35f684);}else{if(util[_0xe8d9('0x17')](this[_0xe8d9('0x6')]['id'],this['realtime'][_0xe8d9('0x14')][_0x35f684],this[_0xe8d9('0x6')][_0xe8d9('0x18')],!![])){_0x650ad7=![];util[_0xe8d9('0x19')](this[_0xe8d9('0x6')]['id'],this['realtime'][_0xe8d9('0x14')][_0x35f684],_0xe8d9('0x1a'));this[_0xe8d9('0x7')]['agents'][_0x35f684][_0xe8d9('0x1b')]=!![];this[_0xe8d9('0x7')][_0xe8d9('0x14')][_0x35f684]['busyQueue']=this[_0xe8d9('0x11')][_0xe8d9('0x1c')];util['saveWaitingNotification'](this['realtime'],this[_0xe8d9('0x4')],this[_0xe8d9('0x11')][_0xe8d9('0x12')][_0x2e5f42],this[_0xe8d9('0x6')]['channel']);util[_0xe8d9('0x1d')](this[_0xe8d9('0x5')],this['squeue']['id'],this['realtime'][_0xe8d9('0x14')][_0x35f684],this[_0xe8d9('0x11')],this[_0xe8d9('0x4')]);}}}if(_0x650ad7){logger[_0xe8d9('0x15')](_0xe8d9('0x1e'),this[_0xe8d9('0x6')]['id']);setTimeout(this[_0xe8d9('0xf')]['bind'](this),0x3e8);}}else{logger[_0xe8d9('0x15')](_0xe8d9('0x1f'),this[_0xe8d9('0x6')]['id']);setTimeout(this[_0xe8d9('0xf')][_0xe8d9('0x9')](this),0x3e8);}};Beepall[_0xe8d9('0xe')][_0xe8d9('0xa')]=function(_0x2cee2e){if(!_['isNil'](this['queue'])&&!_['isNil'](this[_0xe8d9('0x11')]['Agents'])){for(var _0x49d532=0x0,_0x34c539;_0x49d532<this[_0xe8d9('0x11')][_0xe8d9('0x12')]['length'];_0x49d532+=0x1){_0x34c539=this[_0xe8d9('0x11')]['Agents'][_0x49d532]['id'];if(_['isNil'](this['realtime'][_0xe8d9('0x14')][_0x34c539])){logger[_0xe8d9('0x15')](_0xe8d9('0x16'),this['squeue']['id'],_0x34c539);}else{util['hideNotification'](this['notificationId'],this['squeue']['id'],this[_0xe8d9('0x7')][_0xe8d9('0x14')][_0x34c539],this[_0xe8d9('0x11')],this[_0xe8d9('0x4')]);util[_0xe8d9('0x19')](this[_0xe8d9('0x6')]['id'],this[_0xe8d9('0x7')][_0xe8d9('0x14')][_0x34c539],_0x2cee2e?_0xe8d9('0x20'):_0xe8d9('0x21'));this[_0xe8d9('0x7')][_0xe8d9('0x14')][_0x34c539]['busy']=![];this['realtime'][_0xe8d9('0x14')][_0x34c539][_0xe8d9('0x22')]=undefined;util[_0xe8d9('0x23')](this[_0xe8d9('0x7')],this['routing'],this[_0xe8d9('0x7')]['agents'][_0x34c539],this['squeue'][_0xe8d9('0x18')]);}}}if(!_0x2cee2e){setTimeout(this[_0xe8d9('0xf')][_0xe8d9('0x9')](this),0x3e8);}};function beepall(_0x42f470,_0xef1fc4,_0xfcde79,_0x4427ff){return new Beepall(_0x42f470,_0xef1fc4,_0xfcde79,_0x4427ff);}module[_0xe8d9('0x24')]=beepall;