Built motion from commit 639a1a7f.|2.6.19
[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 _0x2841=['[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','STOP','TIMEOUT','removeWaitingNotification','channel','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind','timeout','handleTimeout','prototype','handleDrained','isNil','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','RINGING','busy','name','saveWaitingNotification','showNotification'];(function(_0x318f54,_0x4c5110){var _0x57092d=function(_0x53b19f){while(--_0x53b19f){_0x318f54['push'](_0x318f54['shift']());}};_0x57092d(++_0x4c5110);}(_0x2841,0x1cd));var _0x1284=function(_0x2d3ab3,_0x47d90b){_0x2d3ab3=_0x2d3ab3-0x0;var _0x321f9e=_0x2841[_0x2d3ab3];return _0x321f9e;};'use strict';var _=require(_0x1284('0x0'));var uuid=require(_0x1284('0x1'));var util=require(_0x1284('0x2'));var logger=require(_0x1284('0x3'))(_0x1284('0x4'));var Beepall=function(_0x333b94,_0x31a87b,_0x350458,_0x34de17){this[_0x1284('0x5')]=uuid['v4']();this[_0x1284('0x6')]=_0x333b94;this[_0x1284('0x7')]=_0x31a87b;this[_0x1284('0x8')]=_0x350458;this[_0x1284('0x4')]=_0x34de17;this[_0x1284('0x6')][_0x1284('0x9')](this[_0x1284('0xa')]['bind'](this),this['handleTimeout'][_0x1284('0xb')](this));this[_0x1284('0x6')]['on'](_0x1284('0xc'),this[_0x1284('0xd')][_0x1284('0xb')](this));this[_0x1284('0x6')]['on']('drained',this['handleDrained'][_0x1284('0xb')](this));};Beepall['prototype'][_0x1284('0x9')]=function(){this[_0x1284('0x6')][_0x1284('0x9')](this[_0x1284('0xa')][_0x1284('0xb')](this),this[_0x1284('0xd')][_0x1284('0xb')](this));};Beepall[_0x1284('0xe')][_0x1284('0xf')]=function(){this[_0x1284('0xd')](!![]);};Beepall['prototype']['handleRun']=function(){var _0x31a81b=!![];if(!_[_0x1284('0x10')](this[_0x1284('0x7')])&&!_[_0x1284('0x10')](this[_0x1284('0x7')][_0x1284('0x11')])&&this[_0x1284('0x7')]['Agents'][_0x1284('0x12')]>0x0){for(var _0x11528e=0x0,_0x52b129;_0x11528e<this[_0x1284('0x7')][_0x1284('0x11')][_0x1284('0x12')];_0x11528e+=0x1){_0x52b129=this[_0x1284('0x7')][_0x1284('0x11')][_0x11528e]['id'];if(_['isNil'](this[_0x1284('0x8')][_0x1284('0x13')][_0x52b129])){logger[_0x1284('0x14')](_0x1284('0x15'),this['squeue']['id'],_0x52b129);}else{if(util[_0x1284('0x16')](this['squeue']['id'],this[_0x1284('0x8')][_0x1284('0x13')][_0x52b129],this[_0x1284('0x6')]['channel'],!![])){_0x31a81b=![];util[_0x1284('0x17')](this[_0x1284('0x6')]['id'],this[_0x1284('0x8')][_0x1284('0x13')][_0x52b129],_0x1284('0x18'));this[_0x1284('0x8')]['agents'][_0x52b129][_0x1284('0x19')]=!![];this['realtime']['agents'][_0x52b129]['busyQueue']=this[_0x1284('0x7')][_0x1284('0x1a')];util[_0x1284('0x1b')](this['realtime'],this[_0x1284('0x4')],this[_0x1284('0x7')][_0x1284('0x11')][_0x11528e],this[_0x1284('0x6')]['channel']);util[_0x1284('0x1c')](this[_0x1284('0x5')],this[_0x1284('0x6')]['id'],this[_0x1284('0x8')]['agents'][_0x52b129],this['queue'],this['routing']);}}}if(_0x31a81b){logger[_0x1284('0x14')](_0x1284('0x1d'),this['squeue']['id']);setTimeout(this[_0x1284('0x9')]['bind'](this),0x3e8);}}else{logger['debug']('[%s][QUEUE]\x20EMPTY',this[_0x1284('0x6')]['id']);setTimeout(this[_0x1284('0x9')][_0x1284('0xb')](this),0x3e8);}};Beepall[_0x1284('0xe')][_0x1284('0xd')]=function(_0x4fa259){if(!_[_0x1284('0x10')](this['queue'])&&!_[_0x1284('0x10')](this[_0x1284('0x7')][_0x1284('0x11')])){for(var _0x1f02dd=0x0,_0x12c2de;_0x1f02dd<this[_0x1284('0x7')][_0x1284('0x11')]['length'];_0x1f02dd+=0x1){_0x12c2de=this[_0x1284('0x7')][_0x1284('0x11')][_0x1f02dd]['id'];if(_[_0x1284('0x10')](this[_0x1284('0x8')][_0x1284('0x13')][_0x12c2de])){logger['debug'](_0x1284('0x15'),this[_0x1284('0x6')]['id'],_0x12c2de);}else{util['hideNotification'](this['notificationId'],this[_0x1284('0x6')]['id'],this[_0x1284('0x8')][_0x1284('0x13')][_0x12c2de],this[_0x1284('0x7')],this[_0x1284('0x4')]);util[_0x1284('0x17')](this[_0x1284('0x6')]['id'],this[_0x1284('0x8')][_0x1284('0x13')][_0x12c2de],_0x4fa259?_0x1284('0x1e'):_0x1284('0x1f'));this[_0x1284('0x8')][_0x1284('0x13')][_0x12c2de][_0x1284('0x19')]=![];this['realtime'][_0x1284('0x13')][_0x12c2de]['busyQueue']=undefined;util[_0x1284('0x20')](this[_0x1284('0x8')],this[_0x1284('0x4')],this['realtime'][_0x1284('0x13')][_0x12c2de],this['squeue'][_0x1284('0x21')]);}}}if(!_0x4fa259){setTimeout(this[_0x1284('0x9')][_0x1284('0xb')](this),0x3e8);}};function beepall(_0x5d44f0,_0x5f5597,_0x2bb251,_0x174571){return new Beepall(_0x5d44f0,_0x5f5597,_0x2bb251,_0x174571);}module[_0x1284('0x22')]=beepall;