d1dc80eb3689c0c6e3cd714edec89371ff059ec5
[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 _0x7ef8=['showNotification','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','writeLog','TIMEOUT','busy','removeWaitingNotification','exports','lodash','uuid','../../../../../config/logger','routing','queue','squeue','push','handleRun','handleTimeout','bind','timeout','drained','handleDrained','prototype','isNil','Agents','length','realtime','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','RINGING','busyQueue','name','saveWaitingNotification','channel'];(function(_0xefc37a,_0x6aa74c){var _0x125b15=function(_0x3500f7){while(--_0x3500f7){_0xefc37a['push'](_0xefc37a['shift']());}};_0x125b15(++_0x6aa74c);}(_0x7ef8,0xe8));var _0x87ef=function(_0x1ef5bb,_0x1f6f91){_0x1ef5bb=_0x1ef5bb-0x0;var _0x1083eb=_0x7ef8[_0x1ef5bb];return _0x1083eb;};'use strict';var _=require(_0x87ef('0x0'));var uuid=require(_0x87ef('0x1'));var util=require('./util');var logger=require(_0x87ef('0x2'))(_0x87ef('0x3'));var Beepall=function(_0x23dc74,_0x1f2c1a,_0x4b74f8,_0x1b5001){this['notificationId']=uuid['v4']();this['squeue']=_0x23dc74;this[_0x87ef('0x4')]=_0x1f2c1a;this['realtime']=_0x4b74f8;this[_0x87ef('0x3')]=_0x1b5001;this[_0x87ef('0x5')][_0x87ef('0x6')](this[_0x87ef('0x7')]['bind'](this),this[_0x87ef('0x8')][_0x87ef('0x9')](this));this[_0x87ef('0x5')]['on'](_0x87ef('0xa'),this['handleTimeout'][_0x87ef('0x9')](this));this[_0x87ef('0x5')]['on'](_0x87ef('0xb'),this[_0x87ef('0xc')][_0x87ef('0x9')](this));};Beepall['prototype'][_0x87ef('0x6')]=function(){this[_0x87ef('0x5')][_0x87ef('0x6')](this[_0x87ef('0x7')]['bind'](this),this[_0x87ef('0x8')]['bind'](this));};Beepall['prototype'][_0x87ef('0xc')]=function(){this[_0x87ef('0x8')](!![]);};Beepall[_0x87ef('0xd')][_0x87ef('0x7')]=function(){var _0x2a69eb=!![];if(!_[_0x87ef('0xe')](this[_0x87ef('0x4')])&&!_[_0x87ef('0xe')](this[_0x87ef('0x4')][_0x87ef('0xf')])&&this['queue'][_0x87ef('0xf')][_0x87ef('0x10')]>0x0){for(var _0x56f48e=0x0,_0x206955;_0x56f48e<this['queue']['Agents'][_0x87ef('0x10')];_0x56f48e+=0x1){_0x206955=this[_0x87ef('0x4')][_0x87ef('0xf')][_0x56f48e]['id'];if(_[_0x87ef('0xe')](this[_0x87ef('0x11')][_0x87ef('0x12')][_0x206955])){logger[_0x87ef('0x13')](_0x87ef('0x14'),this[_0x87ef('0x5')]['id'],_0x206955);}else{if(util[_0x87ef('0x15')](this[_0x87ef('0x5')]['id'],this['realtime'][_0x87ef('0x12')][_0x206955],this['squeue']['channel'],!![])){_0x2a69eb=![];util['writeLog'](this[_0x87ef('0x5')]['id'],this['realtime'][_0x87ef('0x12')][_0x206955],_0x87ef('0x16'));this['realtime'][_0x87ef('0x12')][_0x206955]['busy']=!![];this[_0x87ef('0x11')][_0x87ef('0x12')][_0x206955][_0x87ef('0x17')]=this[_0x87ef('0x4')][_0x87ef('0x18')];util[_0x87ef('0x19')](this['realtime'],this['routing'],this[_0x87ef('0x4')][_0x87ef('0xf')][_0x56f48e],this[_0x87ef('0x5')][_0x87ef('0x1a')]);util[_0x87ef('0x1b')](this[_0x87ef('0x1c')],this['squeue']['id'],this[_0x87ef('0x11')][_0x87ef('0x12')][_0x206955],this[_0x87ef('0x4')],this[_0x87ef('0x3')]);}}}if(_0x2a69eb){logger['debug'](_0x87ef('0x1d'),this[_0x87ef('0x5')]['id']);setTimeout(this[_0x87ef('0x6')][_0x87ef('0x9')](this),0x3e8);}}else{logger[_0x87ef('0x13')](_0x87ef('0x1e'),this[_0x87ef('0x5')]['id']);setTimeout(this['push']['bind'](this),0x3e8);}};Beepall[_0x87ef('0xd')][_0x87ef('0x8')]=function(_0x2aa9b){if(!_[_0x87ef('0xe')](this[_0x87ef('0x4')])&&!_[_0x87ef('0xe')](this['queue'][_0x87ef('0xf')])){for(var _0x3f16ae=0x0,_0x4748d8;_0x3f16ae<this[_0x87ef('0x4')][_0x87ef('0xf')][_0x87ef('0x10')];_0x3f16ae+=0x1){_0x4748d8=this['queue'][_0x87ef('0xf')][_0x3f16ae]['id'];if(_[_0x87ef('0xe')](this[_0x87ef('0x11')][_0x87ef('0x12')][_0x4748d8])){logger[_0x87ef('0x13')](_0x87ef('0x14'),this[_0x87ef('0x5')]['id'],_0x4748d8);}else{util[_0x87ef('0x1f')](this[_0x87ef('0x1c')],this['squeue']['id'],this['realtime'][_0x87ef('0x12')][_0x4748d8],this[_0x87ef('0x4')],this[_0x87ef('0x3')]);util[_0x87ef('0x20')](this[_0x87ef('0x5')]['id'],this['realtime'][_0x87ef('0x12')][_0x4748d8],_0x2aa9b?'STOP':_0x87ef('0x21'));this['realtime'][_0x87ef('0x12')][_0x4748d8][_0x87ef('0x22')]=![];this[_0x87ef('0x11')][_0x87ef('0x12')][_0x4748d8][_0x87ef('0x17')]=undefined;util[_0x87ef('0x23')](this[_0x87ef('0x11')],this[_0x87ef('0x3')],this[_0x87ef('0x11')][_0x87ef('0x12')][_0x4748d8],this['squeue'][_0x87ef('0x1a')]);}}}if(!_0x2aa9b){setTimeout(this[_0x87ef('0x6')][_0x87ef('0x9')](this),0x3e8);}};function beepall(_0x322d91,_0xdad064,_0x14118b,_0x278162){return new Beepall(_0x322d91,_0xdad064,_0x14118b,_0x278162);}module[_0x87ef('0x24')]=beepall;