Built motion from commit f3da74b7.|2.5.36
[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 _0xf88f=['exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','realtime','push','handleRun','bind','timeout','handleTimeout','drained','handleDrained','prototype','isNil','queue','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','writeLog','RINGING','busy','busyQueue','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','TIMEOUT'];(function(_0x13300a,_0x1b80aa){var _0xeecb0c=function(_0x10372f){while(--_0x10372f){_0x13300a['push'](_0x13300a['shift']());}};_0xeecb0c(++_0x1b80aa);}(_0xf88f,0x1bb));var _0xff88=function(_0x3d489b,_0x420673){_0x3d489b=_0x3d489b-0x0;var _0x538fff=_0xf88f[_0x3d489b];return _0x538fff;};'use strict';var _=require(_0xff88('0x0'));var uuid=require(_0xff88('0x1'));var util=require(_0xff88('0x2'));var logger=require(_0xff88('0x3'))(_0xff88('0x4'));var Beepall=function(_0x25c2a8,_0x184827,_0x47b3fe,_0x1bcee9){this[_0xff88('0x5')]=uuid['v4']();this[_0xff88('0x6')]=_0x25c2a8;this['queue']=_0x184827;this[_0xff88('0x7')]=_0x47b3fe;this[_0xff88('0x4')]=_0x1bcee9;this[_0xff88('0x6')][_0xff88('0x8')](this[_0xff88('0x9')][_0xff88('0xa')](this),this['handleTimeout'][_0xff88('0xa')](this));this[_0xff88('0x6')]['on'](_0xff88('0xb'),this[_0xff88('0xc')][_0xff88('0xa')](this));this[_0xff88('0x6')]['on'](_0xff88('0xd'),this[_0xff88('0xe')][_0xff88('0xa')](this));};Beepall[_0xff88('0xf')][_0xff88('0x8')]=function(){this[_0xff88('0x6')][_0xff88('0x8')](this[_0xff88('0x9')][_0xff88('0xa')](this),this['handleTimeout'][_0xff88('0xa')](this));};Beepall[_0xff88('0xf')][_0xff88('0xe')]=function(_0x50b341){this[_0xff88('0xc')](!![]);};Beepall[_0xff88('0xf')][_0xff88('0x9')]=function(_0x116712){var _0xcd256f=!![];if(!_[_0xff88('0x10')](this[_0xff88('0x11')])&&!_[_0xff88('0x10')](this['queue'][_0xff88('0x12')])&&this[_0xff88('0x11')]['Agents']['length']>0x0){for(var _0x1181a1=0x0,_0x23fbfc;_0x1181a1<this['queue'][_0xff88('0x12')][_0xff88('0x13')];_0x1181a1+=0x1){_0x23fbfc=this['queue'][_0xff88('0x12')][_0x1181a1]['id'];if(_[_0xff88('0x10')](this[_0xff88('0x7')][_0xff88('0x14')][_0x23fbfc])){logger[_0xff88('0x15')](_0xff88('0x16'),this[_0xff88('0x6')]['id'],_0x23fbfc);}else{if(util['isAgentAvailable'](this[_0xff88('0x6')]['id'],this[_0xff88('0x7')][_0xff88('0x14')][_0x23fbfc],this[_0xff88('0x6')][_0xff88('0x17')],!![])){_0xcd256f=![];util[_0xff88('0x18')](this['squeue']['id'],this[_0xff88('0x7')][_0xff88('0x14')][_0x23fbfc],_0xff88('0x19'));this[_0xff88('0x7')][_0xff88('0x14')][_0x23fbfc][_0xff88('0x1a')]=!![];this[_0xff88('0x7')]['agents'][_0x23fbfc][_0xff88('0x1b')]=this[_0xff88('0x11')]['name'];util[_0xff88('0x1c')](this[_0xff88('0x5')],this[_0xff88('0x6')]['id'],this['realtime'][_0xff88('0x14')][_0x23fbfc],this[_0xff88('0x11')],this['routing']);}}}if(_0xcd256f){logger[_0xff88('0x15')](_0xff88('0x1d'),this['squeue']['id']);setTimeout(this[_0xff88('0x8')][_0xff88('0xa')](this),0x3e8);}}else{logger[_0xff88('0x15')](_0xff88('0x1e'),this[_0xff88('0x6')]['id']);setTimeout(this[_0xff88('0x8')]['bind'](this),0x3e8);}};Beepall[_0xff88('0xf')][_0xff88('0xc')]=function(_0x58d521){if(!_[_0xff88('0x10')](this[_0xff88('0x11')])&&!_[_0xff88('0x10')](this[_0xff88('0x11')][_0xff88('0x12')])){for(var _0x68a5c0=0x0,_0x4e7569;_0x68a5c0<this[_0xff88('0x11')][_0xff88('0x12')][_0xff88('0x13')];_0x68a5c0+=0x1){_0x4e7569=this['queue'][_0xff88('0x12')][_0x68a5c0]['id'];if(_[_0xff88('0x10')](this[_0xff88('0x7')]['agents'][_0x4e7569])){logger['info'](_0xff88('0x16'),this[_0xff88('0x6')]['id'],_0x4e7569);}else{util[_0xff88('0x1f')](this[_0xff88('0x5')],this[_0xff88('0x6')]['id'],this[_0xff88('0x7')][_0xff88('0x14')][_0x4e7569],this[_0xff88('0x11')],this[_0xff88('0x4')]);util[_0xff88('0x18')](this[_0xff88('0x6')]['id'],this['realtime'][_0xff88('0x14')][_0x4e7569],_0x58d521?'STOP':_0xff88('0x20'));this[_0xff88('0x7')]['agents'][_0x4e7569][_0xff88('0x1a')]=![];this[_0xff88('0x7')][_0xff88('0x14')][_0x4e7569]['busyQueue']=undefined;}}}if(!_0x58d521){setTimeout(this[_0xff88('0x8')][_0xff88('0xa')](this),0x3e8);}};function beepall(_0x28ce5a,_0x46dd29,_0x127c5a,_0x3eecd4){return new Beepall(_0x28ce5a,_0x46dd29,_0x127c5a,_0x3eecd4);}module[_0xff88('0x21')]=beepall;