Built motion from commit (unavailable).|2.5.23
[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 _0x9116=['handleTimeout','drained','handleDrained','prototype','isNil','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','busy','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','hideNotification','writeLog','busyQueue','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind'];(function(_0x2c1448,_0x2bd921){var _0x3e2128=function(_0x298ee6){while(--_0x298ee6){_0x2c1448['push'](_0x2c1448['shift']());}};_0x3e2128(++_0x2bd921);}(_0x9116,0x114));var _0x6911=function(_0x1b8bc6,_0x4672de){_0x1b8bc6=_0x1b8bc6-0x0;var _0x17b6bd=_0x9116[_0x1b8bc6];return _0x17b6bd;};'use strict';var _=require(_0x6911('0x0'));var uuid=require(_0x6911('0x1'));var util=require(_0x6911('0x2'));var logger=require(_0x6911('0x3'))(_0x6911('0x4'));var Beepall=function(_0xc9efb3,_0x1d8bbf,_0xc064ee,_0x4bd7da){this[_0x6911('0x5')]=uuid['v4']();this[_0x6911('0x6')]=_0xc9efb3;this[_0x6911('0x7')]=_0x1d8bbf;this[_0x6911('0x8')]=_0xc064ee;this[_0x6911('0x4')]=_0x4bd7da;this[_0x6911('0x6')][_0x6911('0x9')](this[_0x6911('0xa')][_0x6911('0xb')](this),this[_0x6911('0xc')][_0x6911('0xb')](this));this[_0x6911('0x6')]['on']('timeout',this[_0x6911('0xc')][_0x6911('0xb')](this));this['squeue']['on'](_0x6911('0xd'),this[_0x6911('0xe')][_0x6911('0xb')](this));};Beepall[_0x6911('0xf')][_0x6911('0x9')]=function(){this[_0x6911('0x6')][_0x6911('0x9')](this[_0x6911('0xa')][_0x6911('0xb')](this),this[_0x6911('0xc')][_0x6911('0xb')](this));};Beepall['prototype'][_0x6911('0xe')]=function(_0x5b8c39){this[_0x6911('0xc')](!![]);};Beepall[_0x6911('0xf')][_0x6911('0xa')]=function(_0x20ae7e){var _0x104e95=!![];if(!_[_0x6911('0x10')](this['queue'])&&!_[_0x6911('0x10')](this['queue'][_0x6911('0x11')])&&this[_0x6911('0x7')][_0x6911('0x11')]['length']>0x0){for(var _0x1db2a7=0x0,_0x3d7f69;_0x1db2a7<this[_0x6911('0x7')][_0x6911('0x11')][_0x6911('0x12')];_0x1db2a7+=0x1){_0x3d7f69=this[_0x6911('0x7')][_0x6911('0x11')][_0x1db2a7]['id'];if(_[_0x6911('0x10')](this[_0x6911('0x8')][_0x6911('0x13')][_0x3d7f69])){logger[_0x6911('0x14')](_0x6911('0x15'),this['squeue']['id'],_0x3d7f69);}else{if(util[_0x6911('0x16')](this['squeue']['id'],this['realtime'][_0x6911('0x13')][_0x3d7f69],this[_0x6911('0x6')][_0x6911('0x17')],!![])){_0x104e95=![];util['writeLog'](this[_0x6911('0x6')]['id'],this[_0x6911('0x8')]['agents'][_0x3d7f69],'RINGING');this[_0x6911('0x8')][_0x6911('0x13')][_0x3d7f69][_0x6911('0x18')]=!![];this[_0x6911('0x8')][_0x6911('0x13')][_0x3d7f69]['busyQueue']=this[_0x6911('0x7')][_0x6911('0x19')];util[_0x6911('0x1a')](this[_0x6911('0x5')],this[_0x6911('0x6')]['id'],this[_0x6911('0x8')][_0x6911('0x13')][_0x3d7f69],this[_0x6911('0x7')],this[_0x6911('0x4')]);}}}if(_0x104e95){logger['info'](_0x6911('0x1b'),this[_0x6911('0x6')]['id']);setTimeout(this[_0x6911('0x9')][_0x6911('0xb')](this),0x3e8);}}else{logger[_0x6911('0x14')]('[%s][QUEUE]\x20EMPTY',this[_0x6911('0x6')]['id']);setTimeout(this['push'][_0x6911('0xb')](this),0x3e8);}};Beepall[_0x6911('0xf')]['handleTimeout']=function(_0x48beef){if(!_[_0x6911('0x10')](this[_0x6911('0x7')])&&!_[_0x6911('0x10')](this[_0x6911('0x7')][_0x6911('0x11')])){for(var _0x3c737a=0x0,_0x124937;_0x3c737a<this[_0x6911('0x7')]['Agents']['length'];_0x3c737a+=0x1){_0x124937=this[_0x6911('0x7')][_0x6911('0x11')][_0x3c737a]['id'];if(_[_0x6911('0x10')](this[_0x6911('0x8')][_0x6911('0x13')][_0x124937])){logger[_0x6911('0x14')](_0x6911('0x15'),this[_0x6911('0x6')]['id'],_0x124937);}else{util[_0x6911('0x1c')](this[_0x6911('0x5')],this[_0x6911('0x6')]['id'],this[_0x6911('0x8')]['agents'][_0x124937],this['queue'],this[_0x6911('0x4')]);util[_0x6911('0x1d')](this[_0x6911('0x6')]['id'],this['realtime']['agents'][_0x124937],_0x48beef?'STOP':'TIMEOUT');this[_0x6911('0x8')][_0x6911('0x13')][_0x124937][_0x6911('0x18')]=![];this['realtime'][_0x6911('0x13')][_0x124937][_0x6911('0x1e')]=undefined;}}}if(!_0x48beef){setTimeout(this[_0x6911('0x9')][_0x6911('0xb')](this),0x3e8);}};function beepall(_0x18a9c8,_0xd3f802,_0x1cd520,_0x3f5f04){return new Beepall(_0x18a9c8,_0xd3f802,_0x1cd520,_0x3f5f04);}module[_0x6911('0x1f')]=beepall;