d5ef05c628fd41b9fee4d80e288ed71808d18506
[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 _0x80b1=['realtime','handleRun','handleTimeout','bind','timeout','drained','handleDrained','prototype','push','isNil','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','RINGING','busy','busyQueue','saveWaitingNotification','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','writeLog','STOP','TIMEOUT','removeWaitingNotification','exports','lodash','./util','../../../../../config/logger','routing','notificationId','squeue','queue'];(function(_0x4ed5b2,_0xc950dc){var _0x22eaa9=function(_0xa457be){while(--_0xa457be){_0x4ed5b2['push'](_0x4ed5b2['shift']());}};_0x22eaa9(++_0xc950dc);}(_0x80b1,0x85));var _0x180b=function(_0x2440fe,_0x281a11){_0x2440fe=_0x2440fe-0x0;var _0x5cf734=_0x80b1[_0x2440fe];return _0x5cf734;};'use strict';var _=require(_0x180b('0x0'));var uuid=require('uuid');var util=require(_0x180b('0x1'));var logger=require(_0x180b('0x2'))(_0x180b('0x3'));var Beepall=function(_0x492fdc,_0x11c6c8,_0x379a86,_0x34cf92){this[_0x180b('0x4')]=uuid['v4']();this[_0x180b('0x5')]=_0x492fdc;this[_0x180b('0x6')]=_0x11c6c8;this[_0x180b('0x7')]=_0x379a86;this[_0x180b('0x3')]=_0x34cf92;this[_0x180b('0x5')]['push'](this[_0x180b('0x8')]['bind'](this),this[_0x180b('0x9')][_0x180b('0xa')](this));this[_0x180b('0x5')]['on'](_0x180b('0xb'),this[_0x180b('0x9')][_0x180b('0xa')](this));this[_0x180b('0x5')]['on'](_0x180b('0xc'),this[_0x180b('0xd')][_0x180b('0xa')](this));};Beepall[_0x180b('0xe')][_0x180b('0xf')]=function(){this[_0x180b('0x5')]['push'](this['handleRun'][_0x180b('0xa')](this),this[_0x180b('0x9')][_0x180b('0xa')](this));};Beepall[_0x180b('0xe')][_0x180b('0xd')]=function(){this[_0x180b('0x9')](!![]);};Beepall[_0x180b('0xe')][_0x180b('0x8')]=function(){var _0x2a4bbf=!![];if(!_[_0x180b('0x10')](this['queue'])&&!_[_0x180b('0x10')](this['queue'][_0x180b('0x11')])&&this[_0x180b('0x6')][_0x180b('0x11')][_0x180b('0x12')]>0x0){for(var _0x3764dc=0x0,_0x1d8c51;_0x3764dc<this[_0x180b('0x6')][_0x180b('0x11')][_0x180b('0x12')];_0x3764dc+=0x1){_0x1d8c51=this[_0x180b('0x6')][_0x180b('0x11')][_0x3764dc]['id'];if(_[_0x180b('0x10')](this[_0x180b('0x7')][_0x180b('0x13')][_0x1d8c51])){logger[_0x180b('0x14')](_0x180b('0x15'),this[_0x180b('0x5')]['id'],_0x1d8c51);}else{if(util['isAgentAvailable'](this[_0x180b('0x5')]['id'],this[_0x180b('0x7')][_0x180b('0x13')][_0x1d8c51],this[_0x180b('0x5')][_0x180b('0x16')],!![])){_0x2a4bbf=![];util['writeLog'](this['squeue']['id'],this[_0x180b('0x7')][_0x180b('0x13')][_0x1d8c51],_0x180b('0x17'));this['realtime'][_0x180b('0x13')][_0x1d8c51][_0x180b('0x18')]=!![];this[_0x180b('0x7')]['agents'][_0x1d8c51][_0x180b('0x19')]=this[_0x180b('0x6')]['name'];util[_0x180b('0x1a')](this[_0x180b('0x7')],this['routing'],this[_0x180b('0x6')]['Agents'][_0x3764dc],this[_0x180b('0x5')][_0x180b('0x16')]);util[_0x180b('0x1b')](this[_0x180b('0x4')],this['squeue']['id'],this[_0x180b('0x7')][_0x180b('0x13')][_0x1d8c51],this[_0x180b('0x6')],this[_0x180b('0x3')]);}}}if(_0x2a4bbf){logger[_0x180b('0x14')](_0x180b('0x1c'),this['squeue']['id']);setTimeout(this['push']['bind'](this),0x3e8);}}else{logger['debug'](_0x180b('0x1d'),this[_0x180b('0x5')]['id']);setTimeout(this[_0x180b('0xf')][_0x180b('0xa')](this),0x3e8);}};Beepall['prototype'][_0x180b('0x9')]=function(_0x10f494){if(!_[_0x180b('0x10')](this['queue'])&&!_[_0x180b('0x10')](this[_0x180b('0x6')][_0x180b('0x11')])){for(var _0x5cf0bb=0x0,_0x353b22;_0x5cf0bb<this[_0x180b('0x6')][_0x180b('0x11')][_0x180b('0x12')];_0x5cf0bb+=0x1){_0x353b22=this[_0x180b('0x6')]['Agents'][_0x5cf0bb]['id'];if(_[_0x180b('0x10')](this[_0x180b('0x7')]['agents'][_0x353b22])){logger[_0x180b('0x14')](_0x180b('0x15'),this[_0x180b('0x5')]['id'],_0x353b22);}else{util['hideNotification'](this['notificationId'],this[_0x180b('0x5')]['id'],this[_0x180b('0x7')][_0x180b('0x13')][_0x353b22],this['queue'],this[_0x180b('0x3')]);util[_0x180b('0x1e')](this[_0x180b('0x5')]['id'],this[_0x180b('0x7')]['agents'][_0x353b22],_0x10f494?_0x180b('0x1f'):_0x180b('0x20'));this[_0x180b('0x7')][_0x180b('0x13')][_0x353b22][_0x180b('0x18')]=![];this[_0x180b('0x7')]['agents'][_0x353b22][_0x180b('0x19')]=undefined;util[_0x180b('0x21')](this[_0x180b('0x7')],this[_0x180b('0x3')],this[_0x180b('0x7')][_0x180b('0x13')][_0x353b22],this[_0x180b('0x5')][_0x180b('0x16')]);}}}if(!_0x10f494){setTimeout(this[_0x180b('0xf')][_0x180b('0xa')](this),0x3e8);}};function beepall(_0x24ea49,_0x1ff3b4,_0x140de9,_0x2c4035){return new Beepall(_0x24ea49,_0x1ff3b4,_0x140de9,_0x2c4035);}module[_0x180b('0x22')]=beepall;