Built motion from commit (unavailable).|2.5.31
[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 _0x4f4f=['squeue','queue','realtime','handleRun','bind','handleTimeout','timeout','drained','push','handleDrained','isNil','Agents','length','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','writeLog','RINGING','name','showNotification','info','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','prototype','TIMEOUT','busy','exports','lodash','uuid','../../../../../config/logger','routing','notificationId'];(function(_0x5963aa,_0x20fee4){var _0x1b7060=function(_0x17259e){while(--_0x17259e){_0x5963aa['push'](_0x5963aa['shift']());}};_0x1b7060(++_0x20fee4);}(_0x4f4f,0xdb));var _0xf4f4=function(_0x311fc0,_0x2c64f0){_0x311fc0=_0x311fc0-0x0;var _0xce2976=_0x4f4f[_0x311fc0];return _0xce2976;};'use strict';var _=require(_0xf4f4('0x0'));var uuid=require(_0xf4f4('0x1'));var util=require('./util');var logger=require(_0xf4f4('0x2'))(_0xf4f4('0x3'));var Beepall=function(_0x910c44,_0xf6489b,_0x33b837,_0x364868){this[_0xf4f4('0x4')]=uuid['v4']();this[_0xf4f4('0x5')]=_0x910c44;this[_0xf4f4('0x6')]=_0xf6489b;this[_0xf4f4('0x7')]=_0x33b837;this[_0xf4f4('0x3')]=_0x364868;this['squeue']['push'](this[_0xf4f4('0x8')][_0xf4f4('0x9')](this),this[_0xf4f4('0xa')][_0xf4f4('0x9')](this));this[_0xf4f4('0x5')]['on'](_0xf4f4('0xb'),this[_0xf4f4('0xa')][_0xf4f4('0x9')](this));this[_0xf4f4('0x5')]['on'](_0xf4f4('0xc'),this['handleDrained'][_0xf4f4('0x9')](this));};Beepall['prototype'][_0xf4f4('0xd')]=function(){this[_0xf4f4('0x5')][_0xf4f4('0xd')](this[_0xf4f4('0x8')][_0xf4f4('0x9')](this),this[_0xf4f4('0xa')][_0xf4f4('0x9')](this));};Beepall['prototype'][_0xf4f4('0xe')]=function(_0x57ff5c){this[_0xf4f4('0xa')](!![]);};Beepall['prototype'][_0xf4f4('0x8')]=function(_0x172ec2){var _0x2bc028=!![];if(!_[_0xf4f4('0xf')](this[_0xf4f4('0x6')])&&!_[_0xf4f4('0xf')](this[_0xf4f4('0x6')][_0xf4f4('0x10')])&&this[_0xf4f4('0x6')]['Agents'][_0xf4f4('0x11')]>0x0){for(var _0x994729=0x0,_0x38ec31;_0x994729<this[_0xf4f4('0x6')][_0xf4f4('0x10')][_0xf4f4('0x11')];_0x994729+=0x1){_0x38ec31=this['queue'][_0xf4f4('0x10')][_0x994729]['id'];if(_[_0xf4f4('0xf')](this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x38ec31])){logger['info'](_0xf4f4('0x13'),this[_0xf4f4('0x5')]['id'],_0x38ec31);}else{if(util['isAgentAvailable'](this[_0xf4f4('0x5')]['id'],this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x38ec31],this[_0xf4f4('0x5')][_0xf4f4('0x14')],!![])){_0x2bc028=![];util[_0xf4f4('0x15')](this['squeue']['id'],this[_0xf4f4('0x7')]['agents'][_0x38ec31],_0xf4f4('0x16'));this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x38ec31]['busy']=!![];this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x38ec31]['busyQueue']=this[_0xf4f4('0x6')][_0xf4f4('0x17')];util[_0xf4f4('0x18')](this[_0xf4f4('0x4')],this[_0xf4f4('0x5')]['id'],this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x38ec31],this[_0xf4f4('0x6')],this[_0xf4f4('0x3')]);}}}if(_0x2bc028){logger[_0xf4f4('0x19')](_0xf4f4('0x1a'),this[_0xf4f4('0x5')]['id']);setTimeout(this[_0xf4f4('0xd')]['bind'](this),0x3e8);}}else{logger[_0xf4f4('0x19')](_0xf4f4('0x1b'),this['squeue']['id']);setTimeout(this[_0xf4f4('0xd')][_0xf4f4('0x9')](this),0x3e8);}};Beepall[_0xf4f4('0x1c')]['handleTimeout']=function(_0x18ef87){if(!_[_0xf4f4('0xf')](this[_0xf4f4('0x6')])&&!_['isNil'](this[_0xf4f4('0x6')]['Agents'])){for(var _0x17e4ac=0x0,_0x4d5bf2;_0x17e4ac<this[_0xf4f4('0x6')][_0xf4f4('0x10')]['length'];_0x17e4ac+=0x1){_0x4d5bf2=this[_0xf4f4('0x6')][_0xf4f4('0x10')][_0x17e4ac]['id'];if(_['isNil'](this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x4d5bf2])){logger['info'](_0xf4f4('0x13'),this[_0xf4f4('0x5')]['id'],_0x4d5bf2);}else{util['hideNotification'](this[_0xf4f4('0x4')],this[_0xf4f4('0x5')]['id'],this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x4d5bf2],this[_0xf4f4('0x6')],this[_0xf4f4('0x3')]);util[_0xf4f4('0x15')](this[_0xf4f4('0x5')]['id'],this[_0xf4f4('0x7')]['agents'][_0x4d5bf2],_0x18ef87?'STOP':_0xf4f4('0x1d'));this[_0xf4f4('0x7')][_0xf4f4('0x12')][_0x4d5bf2][_0xf4f4('0x1e')]=![];this['realtime'][_0xf4f4('0x12')][_0x4d5bf2]['busyQueue']=undefined;}}}if(!_0x18ef87){setTimeout(this['push'][_0xf4f4('0x9')](this),0x3e8);}};function beepall(_0xb47384,_0x23157f,_0x423932,_0x3a0873){return new Beepall(_0xb47384,_0x23157f,_0x423932,_0x3a0873);}module[_0xf4f4('0x1f')]=beepall;