Built motion from commit d9028345.|2.5.43
[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 _0x3595=['isNil','queue','Agents','length','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','RINGING','busy','busyQueue','name','showNotification','info','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','TIMEOUT','lodash','uuid','./util','routing','notificationId','realtime','squeue','push','handleRun','bind','handleTimeout','timeout','handleDrained','prototype'];(function(_0x34241b,_0x274142){var _0x4e4182=function(_0x2da0b3){while(--_0x2da0b3){_0x34241b['push'](_0x34241b['shift']());}};_0x4e4182(++_0x274142);}(_0x3595,0x147));var _0x5359=function(_0x3b1a21,_0x2bf60a){_0x3b1a21=_0x3b1a21-0x0;var _0x35f9f7=_0x3595[_0x3b1a21];return _0x35f9f7;};'use strict';var _=require(_0x5359('0x0'));var uuid=require(_0x5359('0x1'));var util=require(_0x5359('0x2'));var logger=require('../../../../../config/logger')(_0x5359('0x3'));var Beepall=function(_0x398ac6,_0xcb2beb,_0x3fd018,_0x1fa814){this[_0x5359('0x4')]=uuid['v4']();this['squeue']=_0x398ac6;this['queue']=_0xcb2beb;this[_0x5359('0x5')]=_0x3fd018;this[_0x5359('0x3')]=_0x1fa814;this[_0x5359('0x6')][_0x5359('0x7')](this[_0x5359('0x8')][_0x5359('0x9')](this),this[_0x5359('0xa')][_0x5359('0x9')](this));this[_0x5359('0x6')]['on'](_0x5359('0xb'),this['handleTimeout']['bind'](this));this['squeue']['on']('drained',this[_0x5359('0xc')][_0x5359('0x9')](this));};Beepall[_0x5359('0xd')][_0x5359('0x7')]=function(){this[_0x5359('0x6')][_0x5359('0x7')](this[_0x5359('0x8')][_0x5359('0x9')](this),this[_0x5359('0xa')][_0x5359('0x9')](this));};Beepall[_0x5359('0xd')][_0x5359('0xc')]=function(_0x3a7e63){this[_0x5359('0xa')](!![]);};Beepall['prototype']['handleRun']=function(_0x445000){var _0x144913=!![];if(!_[_0x5359('0xe')](this[_0x5359('0xf')])&&!_[_0x5359('0xe')](this[_0x5359('0xf')]['Agents'])&&this['queue'][_0x5359('0x10')][_0x5359('0x11')]>0x0){for(var _0x4de994=0x0,_0x10007f;_0x4de994<this[_0x5359('0xf')][_0x5359('0x10')][_0x5359('0x11')];_0x4de994+=0x1){_0x10007f=this['queue']['Agents'][_0x4de994]['id'];if(_['isNil'](this[_0x5359('0x5')][_0x5359('0x12')][_0x10007f])){logger['info'](_0x5359('0x13'),this[_0x5359('0x6')]['id'],_0x10007f);}else{if(util[_0x5359('0x14')](this[_0x5359('0x6')]['id'],this['realtime'][_0x5359('0x12')][_0x10007f],this[_0x5359('0x6')]['channel'],!![])){_0x144913=![];util[_0x5359('0x15')](this[_0x5359('0x6')]['id'],this[_0x5359('0x5')][_0x5359('0x12')][_0x10007f],_0x5359('0x16'));this['realtime']['agents'][_0x10007f][_0x5359('0x17')]=!![];this[_0x5359('0x5')][_0x5359('0x12')][_0x10007f][_0x5359('0x18')]=this[_0x5359('0xf')][_0x5359('0x19')];util[_0x5359('0x1a')](this[_0x5359('0x4')],this[_0x5359('0x6')]['id'],this['realtime'][_0x5359('0x12')][_0x10007f],this[_0x5359('0xf')],this[_0x5359('0x3')]);}}}if(_0x144913){logger[_0x5359('0x1b')](_0x5359('0x1c'),this[_0x5359('0x6')]['id']);setTimeout(this['push'][_0x5359('0x9')](this),0x3e8);}}else{logger['info'](_0x5359('0x1d'),this['squeue']['id']);setTimeout(this[_0x5359('0x7')][_0x5359('0x9')](this),0x3e8);}};Beepall['prototype'][_0x5359('0xa')]=function(_0x5766e3){if(!_[_0x5359('0xe')](this[_0x5359('0xf')])&&!_[_0x5359('0xe')](this[_0x5359('0xf')][_0x5359('0x10')])){for(var _0x3a2552=0x0,_0x4ca6ea;_0x3a2552<this[_0x5359('0xf')][_0x5359('0x10')][_0x5359('0x11')];_0x3a2552+=0x1){_0x4ca6ea=this[_0x5359('0xf')][_0x5359('0x10')][_0x3a2552]['id'];if(_[_0x5359('0xe')](this[_0x5359('0x5')][_0x5359('0x12')][_0x4ca6ea])){logger[_0x5359('0x1b')](_0x5359('0x13'),this[_0x5359('0x6')]['id'],_0x4ca6ea);}else{util['hideNotification'](this[_0x5359('0x4')],this[_0x5359('0x6')]['id'],this['realtime']['agents'][_0x4ca6ea],this[_0x5359('0xf')],this[_0x5359('0x3')]);util[_0x5359('0x15')](this[_0x5359('0x6')]['id'],this['realtime'][_0x5359('0x12')][_0x4ca6ea],_0x5766e3?'STOP':_0x5359('0x1e'));this[_0x5359('0x5')][_0x5359('0x12')][_0x4ca6ea][_0x5359('0x17')]=![];this[_0x5359('0x5')][_0x5359('0x12')][_0x4ca6ea][_0x5359('0x18')]=undefined;}}}if(!_0x5766e3){setTimeout(this[_0x5359('0x7')][_0x5359('0x9')](this),0x3e8);}};function beepall(_0x212c70,_0x7ba0e5,_0x3392c9,_0x56cbd4){return new Beepall(_0x212c70,_0x7ba0e5,_0x3392c9,_0x56cbd4);}module['exports']=beepall;