Built motion from commit e781dc3c.|2.5.42
[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 _0x5af0=['handleDrained','prototype','handleRun','isNil','Agents','length','agents','info','channel','RINGING','busy','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','hideNotification','busyQueue','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','queue','realtime','push','bind','handleTimeout','squeue','drained'];(function(_0x2b4411,_0x2625ed){var _0x8e41ef=function(_0x2aa8c1){while(--_0x2aa8c1){_0x2b4411['push'](_0x2b4411['shift']());}};_0x8e41ef(++_0x2625ed);}(_0x5af0,0x1eb));var _0x05af=function(_0x299fad,_0x3c50f9){_0x299fad=_0x299fad-0x0;var _0x5c7ef9=_0x5af0[_0x299fad];return _0x5c7ef9;};'use strict';var _=require(_0x05af('0x0'));var uuid=require(_0x05af('0x1'));var util=require(_0x05af('0x2'));var logger=require(_0x05af('0x3'))(_0x05af('0x4'));var Beepall=function(_0x17cdb5,_0x2ad944,_0x8c87f7,_0x518abd){this[_0x05af('0x5')]=uuid['v4']();this['squeue']=_0x17cdb5;this[_0x05af('0x6')]=_0x2ad944;this[_0x05af('0x7')]=_0x8c87f7;this[_0x05af('0x4')]=_0x518abd;this['squeue'][_0x05af('0x8')](this['handleRun'][_0x05af('0x9')](this),this[_0x05af('0xa')][_0x05af('0x9')](this));this['squeue']['on']('timeout',this['handleTimeout']['bind'](this));this[_0x05af('0xb')]['on'](_0x05af('0xc'),this[_0x05af('0xd')]['bind'](this));};Beepall[_0x05af('0xe')]['push']=function(){this['squeue'][_0x05af('0x8')](this[_0x05af('0xf')][_0x05af('0x9')](this),this[_0x05af('0xa')][_0x05af('0x9')](this));};Beepall[_0x05af('0xe')][_0x05af('0xd')]=function(_0x2fd2d4){this[_0x05af('0xa')](!![]);};Beepall[_0x05af('0xe')][_0x05af('0xf')]=function(_0x123596){var _0xa9c93e=!![];if(!_[_0x05af('0x10')](this[_0x05af('0x6')])&&!_[_0x05af('0x10')](this[_0x05af('0x6')]['Agents'])&&this['queue'][_0x05af('0x11')][_0x05af('0x12')]>0x0){for(var _0x3fe03f=0x0,_0x4c7b6a;_0x3fe03f<this[_0x05af('0x6')][_0x05af('0x11')][_0x05af('0x12')];_0x3fe03f+=0x1){_0x4c7b6a=this[_0x05af('0x6')][_0x05af('0x11')][_0x3fe03f]['id'];if(_[_0x05af('0x10')](this[_0x05af('0x7')][_0x05af('0x13')][_0x4c7b6a])){logger[_0x05af('0x14')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x05af('0xb')]['id'],_0x4c7b6a);}else{if(util['isAgentAvailable'](this[_0x05af('0xb')]['id'],this[_0x05af('0x7')][_0x05af('0x13')][_0x4c7b6a],this[_0x05af('0xb')][_0x05af('0x15')],!![])){_0xa9c93e=![];util['writeLog'](this[_0x05af('0xb')]['id'],this[_0x05af('0x7')][_0x05af('0x13')][_0x4c7b6a],_0x05af('0x16'));this[_0x05af('0x7')][_0x05af('0x13')][_0x4c7b6a][_0x05af('0x17')]=!![];this[_0x05af('0x7')][_0x05af('0x13')][_0x4c7b6a]['busyQueue']=this['queue']['name'];util['showNotification'](this[_0x05af('0x5')],this[_0x05af('0xb')]['id'],this[_0x05af('0x7')]['agents'][_0x4c7b6a],this['queue'],this[_0x05af('0x4')]);}}}if(_0xa9c93e){logger['info'](_0x05af('0x18'),this[_0x05af('0xb')]['id']);setTimeout(this[_0x05af('0x8')][_0x05af('0x9')](this),0x3e8);}}else{logger[_0x05af('0x14')]('[%s][QUEUE]\x20EMPTY',this[_0x05af('0xb')]['id']);setTimeout(this[_0x05af('0x8')]['bind'](this),0x3e8);}};Beepall[_0x05af('0xe')]['handleTimeout']=function(_0x331241){if(!_['isNil'](this[_0x05af('0x6')])&&!_[_0x05af('0x10')](this[_0x05af('0x6')]['Agents'])){for(var _0x159880=0x0,_0x29d814;_0x159880<this[_0x05af('0x6')][_0x05af('0x11')][_0x05af('0x12')];_0x159880+=0x1){_0x29d814=this[_0x05af('0x6')][_0x05af('0x11')][_0x159880]['id'];if(_['isNil'](this[_0x05af('0x7')][_0x05af('0x13')][_0x29d814])){logger['info']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x05af('0xb')]['id'],_0x29d814);}else{util[_0x05af('0x19')](this[_0x05af('0x5')],this[_0x05af('0xb')]['id'],this[_0x05af('0x7')][_0x05af('0x13')][_0x29d814],this['queue'],this[_0x05af('0x4')]);util['writeLog'](this[_0x05af('0xb')]['id'],this[_0x05af('0x7')][_0x05af('0x13')][_0x29d814],_0x331241?'STOP':'TIMEOUT');this['realtime'][_0x05af('0x13')][_0x29d814][_0x05af('0x17')]=![];this[_0x05af('0x7')]['agents'][_0x29d814][_0x05af('0x1a')]=undefined;}}}if(!_0x331241){setTimeout(this[_0x05af('0x8')][_0x05af('0x9')](this),0x3e8);}};function beepall(_0x506a8f,_0x3529bc,_0xb70c6,_0x2904e3){return new Beepall(_0x506a8f,_0x3529bc,_0xb70c6,_0x2904e3);}module[_0x05af('0x1b')]=beepall;