Built motion from commit ffdca78c.|2.6.24
[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 _0x8fb0=['push','handleRun','bind','handleTimeout','squeue','drained','handleDrained','isNil','queue','Agents','length','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','agents','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','prototype','hideNotification','STOP','TIMEOUT','removeWaitingNotification','exports','lodash','uuid','../../../../../config/logger','notificationId','realtime','routing'];(function(_0x3e7e96,_0x5683ca){var _0x13f6f0=function(_0x320767){while(--_0x320767){_0x3e7e96['push'](_0x3e7e96['shift']());}};_0x13f6f0(++_0x5683ca);}(_0x8fb0,0x14e));var _0x08fb=function(_0x35da42,_0x5c2610){_0x35da42=_0x35da42-0x0;var _0x370035=_0x8fb0[_0x35da42];return _0x370035;};'use strict';var _=require(_0x08fb('0x0'));var uuid=require(_0x08fb('0x1'));var util=require('./util');var logger=require(_0x08fb('0x2'))('routing');var Beepall=function(_0x32975c,_0x419f53,_0x50f61e,_0x2e9198){this[_0x08fb('0x3')]=uuid['v4']();this['squeue']=_0x32975c;this['queue']=_0x419f53;this[_0x08fb('0x4')]=_0x50f61e;this[_0x08fb('0x5')]=_0x2e9198;this['squeue'][_0x08fb('0x6')](this[_0x08fb('0x7')][_0x08fb('0x8')](this),this[_0x08fb('0x9')][_0x08fb('0x8')](this));this[_0x08fb('0xa')]['on']('timeout',this[_0x08fb('0x9')]['bind'](this));this[_0x08fb('0xa')]['on'](_0x08fb('0xb'),this[_0x08fb('0xc')][_0x08fb('0x8')](this));};Beepall['prototype'][_0x08fb('0x6')]=function(){this['squeue'][_0x08fb('0x6')](this[_0x08fb('0x7')][_0x08fb('0x8')](this),this[_0x08fb('0x9')]['bind'](this));};Beepall['prototype']['handleDrained']=function(){this[_0x08fb('0x9')](!![]);};Beepall['prototype'][_0x08fb('0x7')]=function(){var _0x266b95=!![];if(!_['isNil'](this['queue'])&&!_[_0x08fb('0xd')](this[_0x08fb('0xe')][_0x08fb('0xf')])&&this[_0x08fb('0xe')][_0x08fb('0xf')][_0x08fb('0x10')]>0x0){for(var _0x330ea1=0x0,_0x3ab745;_0x330ea1<this[_0x08fb('0xe')][_0x08fb('0xf')][_0x08fb('0x10')];_0x330ea1+=0x1){_0x3ab745=this['queue'][_0x08fb('0xf')][_0x330ea1]['id'];if(_[_0x08fb('0xd')](this[_0x08fb('0x4')]['agents'][_0x3ab745])){logger[_0x08fb('0x11')](_0x08fb('0x12'),this[_0x08fb('0xa')]['id'],_0x3ab745);}else{if(util[_0x08fb('0x13')](this[_0x08fb('0xa')]['id'],this['realtime']['agents'][_0x3ab745],this[_0x08fb('0xa')][_0x08fb('0x14')],!![])){_0x266b95=![];util[_0x08fb('0x15')](this['squeue']['id'],this[_0x08fb('0x4')]['agents'][_0x3ab745],_0x08fb('0x16'));this[_0x08fb('0x4')]['agents'][_0x3ab745][_0x08fb('0x17')]=!![];this[_0x08fb('0x4')]['agents'][_0x3ab745][_0x08fb('0x18')]=this[_0x08fb('0xe')]['name'];util['saveWaitingNotification'](this[_0x08fb('0x4')],this[_0x08fb('0x5')],this[_0x08fb('0xe')][_0x08fb('0xf')][_0x330ea1],this[_0x08fb('0xa')][_0x08fb('0x14')]);util['showNotification'](this['notificationId'],this[_0x08fb('0xa')]['id'],this['realtime'][_0x08fb('0x19')][_0x3ab745],this['queue'],this['routing']);}}}if(_0x266b95){logger[_0x08fb('0x11')](_0x08fb('0x1a'),this[_0x08fb('0xa')]['id']);setTimeout(this[_0x08fb('0x6')][_0x08fb('0x8')](this),0x3e8);}}else{logger[_0x08fb('0x11')](_0x08fb('0x1b'),this['squeue']['id']);setTimeout(this[_0x08fb('0x6')][_0x08fb('0x8')](this),0x3e8);}};Beepall[_0x08fb('0x1c')]['handleTimeout']=function(_0xcaaa27){if(!_[_0x08fb('0xd')](this[_0x08fb('0xe')])&&!_[_0x08fb('0xd')](this[_0x08fb('0xe')][_0x08fb('0xf')])){for(var _0x46c466=0x0,_0xbe2a7c;_0x46c466<this['queue'][_0x08fb('0xf')][_0x08fb('0x10')];_0x46c466+=0x1){_0xbe2a7c=this[_0x08fb('0xe')][_0x08fb('0xf')][_0x46c466]['id'];if(_[_0x08fb('0xd')](this[_0x08fb('0x4')][_0x08fb('0x19')][_0xbe2a7c])){logger[_0x08fb('0x11')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x08fb('0xa')]['id'],_0xbe2a7c);}else{util[_0x08fb('0x1d')](this[_0x08fb('0x3')],this[_0x08fb('0xa')]['id'],this['realtime']['agents'][_0xbe2a7c],this[_0x08fb('0xe')],this[_0x08fb('0x5')]);util['writeLog'](this[_0x08fb('0xa')]['id'],this[_0x08fb('0x4')][_0x08fb('0x19')][_0xbe2a7c],_0xcaaa27?_0x08fb('0x1e'):_0x08fb('0x1f'));this[_0x08fb('0x4')]['agents'][_0xbe2a7c][_0x08fb('0x17')]=![];this['realtime'][_0x08fb('0x19')][_0xbe2a7c][_0x08fb('0x18')]=undefined;util[_0x08fb('0x20')](this[_0x08fb('0x4')],this['routing'],this[_0x08fb('0x4')][_0x08fb('0x19')][_0xbe2a7c],this['squeue']['channel']);}}}if(!_0xcaaa27){setTimeout(this[_0x08fb('0x6')][_0x08fb('0x8')](this),0x3e8);}};function beepall(_0x1a3259,_0x27c924,_0x25cd4a,_0x271d4b){return new Beepall(_0x1a3259,_0x27c924,_0x25cd4a,_0x271d4b);}module[_0x08fb('0x21')]=beepall;