92434f2825c0e512bc9900fcd55d5db15dc1e7cf
[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 _0x1670=['timeout','drained','handleDrained','prototype','isNil','length','Agents','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','name','showNotification','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','TIMEOUT','exports','lodash','uuid','../../../../../config/logger','queue','realtime','routing','squeue','push','handleRun','bind','handleTimeout'];(function(_0x437ac6,_0x1910b6){var _0x4d8868=function(_0x37a707){while(--_0x37a707){_0x437ac6['push'](_0x437ac6['shift']());}};_0x4d8868(++_0x1910b6);}(_0x1670,0x9a));var _0x0167=function(_0x21e56e,_0x51ae6d){_0x21e56e=_0x21e56e-0x0;var _0x5b89ef=_0x1670[_0x21e56e];return _0x5b89ef;};'use strict';var _=require(_0x0167('0x0'));var uuid=require(_0x0167('0x1'));var util=require('./util');var logger=require(_0x0167('0x2'))('routing');var Beepall=function(_0x1c7a08,_0x45bbfd,_0x377590,_0x6f87ae){this['notificationId']=uuid['v4']();this['squeue']=_0x1c7a08;this[_0x0167('0x3')]=_0x45bbfd;this[_0x0167('0x4')]=_0x377590;this[_0x0167('0x5')]=_0x6f87ae;this[_0x0167('0x6')][_0x0167('0x7')](this[_0x0167('0x8')][_0x0167('0x9')](this),this[_0x0167('0xa')]['bind'](this));this['squeue']['on'](_0x0167('0xb'),this[_0x0167('0xa')][_0x0167('0x9')](this));this[_0x0167('0x6')]['on'](_0x0167('0xc'),this[_0x0167('0xd')][_0x0167('0x9')](this));};Beepall[_0x0167('0xe')][_0x0167('0x7')]=function(){this[_0x0167('0x6')][_0x0167('0x7')](this[_0x0167('0x8')][_0x0167('0x9')](this),this[_0x0167('0xa')]['bind'](this));};Beepall[_0x0167('0xe')]['handleDrained']=function(_0x25e5d4){this['handleTimeout'](!![]);};Beepall[_0x0167('0xe')][_0x0167('0x8')]=function(_0x3fc778){var _0x57c0e0=!![];if(!_['isNil'](this['queue'])&&!_[_0x0167('0xf')](this[_0x0167('0x3')]['Agents'])&&this[_0x0167('0x3')]['Agents']['length']>0x0){for(var _0x38f934=0x0,_0x574f04;_0x38f934<this[_0x0167('0x3')]['Agents'][_0x0167('0x10')];_0x38f934+=0x1){_0x574f04=this[_0x0167('0x3')][_0x0167('0x11')][_0x38f934]['id'];if(_[_0x0167('0xf')](this[_0x0167('0x4')][_0x0167('0x12')][_0x574f04])){logger[_0x0167('0x13')](_0x0167('0x14'),this[_0x0167('0x6')]['id'],_0x574f04);}else{if(util[_0x0167('0x15')](this[_0x0167('0x6')]['id'],this[_0x0167('0x4')]['agents'][_0x574f04],this[_0x0167('0x6')][_0x0167('0x16')],!![])){_0x57c0e0=![];util[_0x0167('0x17')](this['squeue']['id'],this[_0x0167('0x4')][_0x0167('0x12')][_0x574f04],_0x0167('0x18'));this[_0x0167('0x4')]['agents'][_0x574f04][_0x0167('0x19')]=!![];this['realtime'][_0x0167('0x12')][_0x574f04][_0x0167('0x1a')]=this[_0x0167('0x3')][_0x0167('0x1b')];util[_0x0167('0x1c')](this[_0x0167('0x1d')],this[_0x0167('0x6')]['id'],this['realtime'][_0x0167('0x12')][_0x574f04],this[_0x0167('0x3')],this[_0x0167('0x5')]);}}}if(_0x57c0e0){logger['info'](_0x0167('0x1e'),this[_0x0167('0x6')]['id']);setTimeout(this['push'][_0x0167('0x9')](this),0x3e8);}}else{logger[_0x0167('0x13')]('[%s][QUEUE]\x20EMPTY',this[_0x0167('0x6')]['id']);setTimeout(this[_0x0167('0x7')][_0x0167('0x9')](this),0x3e8);}};Beepall['prototype'][_0x0167('0xa')]=function(_0x39b105){if(!_['isNil'](this['queue'])&&!_[_0x0167('0xf')](this[_0x0167('0x3')][_0x0167('0x11')])){for(var _0x1dcfdf=0x0,_0x52414e;_0x1dcfdf<this['queue'][_0x0167('0x11')]['length'];_0x1dcfdf+=0x1){_0x52414e=this['queue'][_0x0167('0x11')][_0x1dcfdf]['id'];if(_[_0x0167('0xf')](this[_0x0167('0x4')][_0x0167('0x12')][_0x52414e])){logger[_0x0167('0x13')](_0x0167('0x14'),this[_0x0167('0x6')]['id'],_0x52414e);}else{util['hideNotification'](this['notificationId'],this[_0x0167('0x6')]['id'],this[_0x0167('0x4')][_0x0167('0x12')][_0x52414e],this[_0x0167('0x3')],this[_0x0167('0x5')]);util[_0x0167('0x17')](this['squeue']['id'],this[_0x0167('0x4')]['agents'][_0x52414e],_0x39b105?'STOP':_0x0167('0x1f'));this[_0x0167('0x4')][_0x0167('0x12')][_0x52414e]['busy']=![];this[_0x0167('0x4')][_0x0167('0x12')][_0x52414e][_0x0167('0x1a')]=undefined;}}}if(!_0x39b105){setTimeout(this[_0x0167('0x7')]['bind'](this),0x3e8);}};function beepall(_0x2f496e,_0x355070,_0x8c2a97,_0x4fa178){return new Beepall(_0x2f496e,_0x355070,_0x8c2a97,_0x4fa178);}module[_0x0167('0x20')]=beepall;