Built motion from commit 10af8726.|2.6.34
[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 _0x1a37=['timeout','handleTimeout','bind','drained','handleDrained','prototype','isNil','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','realtime','channel','writeLog','RINGING','busy','name','saveWaitingNotification','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','STOP','TIMEOUT','removeWaitingNotification','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','queue','squeue','push','handleRun'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0x1a37,0xb4));var _0x71a3=function(_0x381589,_0x27a707){_0x381589=_0x381589-0x0;var _0x2a075d=_0x1a37[_0x381589];return _0x2a075d;};'use strict';var _=require(_0x71a3('0x0'));var uuid=require(_0x71a3('0x1'));var util=require(_0x71a3('0x2'));var logger=require(_0x71a3('0x3'))(_0x71a3('0x4'));var Beepall=function(_0x20d8a7,_0x348395,_0xbe3243,_0x29c54f){this[_0x71a3('0x5')]=uuid['v4']();this['squeue']=_0x20d8a7;this[_0x71a3('0x6')]=_0x348395;this['realtime']=_0xbe3243;this[_0x71a3('0x4')]=_0x29c54f;this[_0x71a3('0x7')][_0x71a3('0x8')](this[_0x71a3('0x9')]['bind'](this),this['handleTimeout']['bind'](this));this['squeue']['on'](_0x71a3('0xa'),this[_0x71a3('0xb')][_0x71a3('0xc')](this));this[_0x71a3('0x7')]['on'](_0x71a3('0xd'),this[_0x71a3('0xe')][_0x71a3('0xc')](this));};Beepall[_0x71a3('0xf')]['push']=function(){this['squeue']['push'](this[_0x71a3('0x9')][_0x71a3('0xc')](this),this[_0x71a3('0xb')][_0x71a3('0xc')](this));};Beepall[_0x71a3('0xf')][_0x71a3('0xe')]=function(){this[_0x71a3('0xb')](!![]);};Beepall[_0x71a3('0xf')][_0x71a3('0x9')]=function(){var _0x203ee1=!![];if(!_[_0x71a3('0x10')](this['queue'])&&!_[_0x71a3('0x10')](this[_0x71a3('0x6')]['Agents'])&&this['queue'][_0x71a3('0x11')][_0x71a3('0x12')]>0x0){for(var _0xee797f=0x0,_0x201ed8;_0xee797f<this[_0x71a3('0x6')][_0x71a3('0x11')]['length'];_0xee797f+=0x1){_0x201ed8=this[_0x71a3('0x6')][_0x71a3('0x11')][_0xee797f]['id'];if(_['isNil'](this['realtime'][_0x71a3('0x13')][_0x201ed8])){logger[_0x71a3('0x14')](_0x71a3('0x15'),this[_0x71a3('0x7')]['id'],_0x201ed8);}else{if(util[_0x71a3('0x16')](this['squeue']['id'],this[_0x71a3('0x17')][_0x71a3('0x13')][_0x201ed8],this[_0x71a3('0x7')][_0x71a3('0x18')],!![])){_0x203ee1=![];util[_0x71a3('0x19')](this['squeue']['id'],this[_0x71a3('0x17')]['agents'][_0x201ed8],_0x71a3('0x1a'));this[_0x71a3('0x17')][_0x71a3('0x13')][_0x201ed8][_0x71a3('0x1b')]=!![];this[_0x71a3('0x17')][_0x71a3('0x13')][_0x201ed8]['busyQueue']=this[_0x71a3('0x6')][_0x71a3('0x1c')];util[_0x71a3('0x1d')](this[_0x71a3('0x17')],this[_0x71a3('0x4')],this['queue'][_0x71a3('0x11')][_0xee797f],this[_0x71a3('0x7')]['channel']);util[_0x71a3('0x1e')](this['notificationId'],this[_0x71a3('0x7')]['id'],this[_0x71a3('0x17')][_0x71a3('0x13')][_0x201ed8],this[_0x71a3('0x6')],this[_0x71a3('0x4')]);}}}if(_0x203ee1){logger[_0x71a3('0x14')](_0x71a3('0x1f'),this[_0x71a3('0x7')]['id']);setTimeout(this[_0x71a3('0x8')][_0x71a3('0xc')](this),0x3e8);}}else{logger[_0x71a3('0x14')](_0x71a3('0x20'),this['squeue']['id']);setTimeout(this[_0x71a3('0x8')][_0x71a3('0xc')](this),0x3e8);}};Beepall[_0x71a3('0xf')][_0x71a3('0xb')]=function(_0x4a750c){if(!_[_0x71a3('0x10')](this[_0x71a3('0x6')])&&!_[_0x71a3('0x10')](this[_0x71a3('0x6')][_0x71a3('0x11')])){for(var _0xa82e46=0x0,_0x1d09bd;_0xa82e46<this['queue'][_0x71a3('0x11')][_0x71a3('0x12')];_0xa82e46+=0x1){_0x1d09bd=this[_0x71a3('0x6')][_0x71a3('0x11')][_0xa82e46]['id'];if(_[_0x71a3('0x10')](this[_0x71a3('0x17')][_0x71a3('0x13')][_0x1d09bd])){logger[_0x71a3('0x14')](_0x71a3('0x15'),this[_0x71a3('0x7')]['id'],_0x1d09bd);}else{util[_0x71a3('0x21')](this[_0x71a3('0x5')],this[_0x71a3('0x7')]['id'],this['realtime']['agents'][_0x1d09bd],this[_0x71a3('0x6')],this[_0x71a3('0x4')]);util['writeLog'](this[_0x71a3('0x7')]['id'],this[_0x71a3('0x17')]['agents'][_0x1d09bd],_0x4a750c?_0x71a3('0x22'):_0x71a3('0x23'));this[_0x71a3('0x17')][_0x71a3('0x13')][_0x1d09bd][_0x71a3('0x1b')]=![];this[_0x71a3('0x17')][_0x71a3('0x13')][_0x1d09bd]['busyQueue']=undefined;util[_0x71a3('0x24')](this[_0x71a3('0x17')],this[_0x71a3('0x4')],this['realtime'][_0x71a3('0x13')][_0x1d09bd],this[_0x71a3('0x7')][_0x71a3('0x18')]);}}}if(!_0x4a750c){setTimeout(this[_0x71a3('0x8')][_0x71a3('0xc')](this),0x3e8);}};function beepall(_0x54d03b,_0x5d91d4,_0x994e65,_0x2b3197){return new Beepall(_0x54d03b,_0x5d91d4,_0x994e65,_0x2b3197);}module[_0x71a3('0x25')]=beepall;