Built motion from commit 97153652.|2.6.26
[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 _0xac62=['bind','timeout','drained','prototype','handleDrained','isNil','queue','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busyQueue','name','saveWaitingNotification','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','STOP','TIMEOUT','removeWaitingNotification','exports','lodash','./util','../../../../../config/logger','routing','notificationId','squeue','realtime','push','handleRun','handleTimeout'];(function(_0x4f9b18,_0x2cb5ca){var _0x29f20c=function(_0x268b3d){while(--_0x268b3d){_0x4f9b18['push'](_0x4f9b18['shift']());}};_0x29f20c(++_0x2cb5ca);}(_0xac62,0x65));var _0x2ac6=function(_0x44731a,_0x3417bb){_0x44731a=_0x44731a-0x0;var _0x5541bd=_0xac62[_0x44731a];return _0x5541bd;};'use strict';var _=require(_0x2ac6('0x0'));var uuid=require('uuid');var util=require(_0x2ac6('0x1'));var logger=require(_0x2ac6('0x2'))(_0x2ac6('0x3'));var Beepall=function(_0x22d0f6,_0x57c522,_0x486b32,_0x1e0057){this[_0x2ac6('0x4')]=uuid['v4']();this[_0x2ac6('0x5')]=_0x22d0f6;this['queue']=_0x57c522;this[_0x2ac6('0x6')]=_0x486b32;this['routing']=_0x1e0057;this[_0x2ac6('0x5')][_0x2ac6('0x7')](this[_0x2ac6('0x8')]['bind'](this),this[_0x2ac6('0x9')][_0x2ac6('0xa')](this));this['squeue']['on'](_0x2ac6('0xb'),this[_0x2ac6('0x9')][_0x2ac6('0xa')](this));this['squeue']['on'](_0x2ac6('0xc'),this['handleDrained'][_0x2ac6('0xa')](this));};Beepall[_0x2ac6('0xd')]['push']=function(){this[_0x2ac6('0x5')][_0x2ac6('0x7')](this[_0x2ac6('0x8')][_0x2ac6('0xa')](this),this[_0x2ac6('0x9')]['bind'](this));};Beepall[_0x2ac6('0xd')][_0x2ac6('0xe')]=function(){this[_0x2ac6('0x9')](!![]);};Beepall['prototype'][_0x2ac6('0x8')]=function(){var _0x29f807=!![];if(!_[_0x2ac6('0xf')](this[_0x2ac6('0x10')])&&!_['isNil'](this['queue'][_0x2ac6('0x11')])&&this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x2ac6('0x12')]>0x0){for(var _0x77683f=0x0,_0x4e7bd0;_0x77683f<this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x2ac6('0x12')];_0x77683f+=0x1){_0x4e7bd0=this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x77683f]['id'];if(_[_0x2ac6('0xf')](this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x4e7bd0])){logger[_0x2ac6('0x14')](_0x2ac6('0x15'),this['squeue']['id'],_0x4e7bd0);}else{if(util[_0x2ac6('0x16')](this[_0x2ac6('0x5')]['id'],this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x4e7bd0],this[_0x2ac6('0x5')][_0x2ac6('0x17')],!![])){_0x29f807=![];util[_0x2ac6('0x18')](this[_0x2ac6('0x5')]['id'],this[_0x2ac6('0x6')]['agents'][_0x4e7bd0],_0x2ac6('0x19'));this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x4e7bd0]['busy']=!![];this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x4e7bd0][_0x2ac6('0x1a')]=this[_0x2ac6('0x10')][_0x2ac6('0x1b')];util[_0x2ac6('0x1c')](this['realtime'],this[_0x2ac6('0x3')],this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x77683f],this['squeue'][_0x2ac6('0x17')]);util[_0x2ac6('0x1d')](this[_0x2ac6('0x4')],this[_0x2ac6('0x5')]['id'],this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x4e7bd0],this['queue'],this[_0x2ac6('0x3')]);}}}if(_0x29f807){logger[_0x2ac6('0x14')](_0x2ac6('0x1e'),this[_0x2ac6('0x5')]['id']);setTimeout(this['push'][_0x2ac6('0xa')](this),0x3e8);}}else{logger[_0x2ac6('0x14')](_0x2ac6('0x1f'),this[_0x2ac6('0x5')]['id']);setTimeout(this[_0x2ac6('0x7')][_0x2ac6('0xa')](this),0x3e8);}};Beepall[_0x2ac6('0xd')][_0x2ac6('0x9')]=function(_0x5a3f76){if(!_[_0x2ac6('0xf')](this[_0x2ac6('0x10')])&&!_[_0x2ac6('0xf')](this[_0x2ac6('0x10')][_0x2ac6('0x11')])){for(var _0x52d3d1=0x0,_0x5347fe;_0x52d3d1<this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x2ac6('0x12')];_0x52d3d1+=0x1){_0x5347fe=this[_0x2ac6('0x10')][_0x2ac6('0x11')][_0x52d3d1]['id'];if(_[_0x2ac6('0xf')](this[_0x2ac6('0x6')]['agents'][_0x5347fe])){logger[_0x2ac6('0x14')](_0x2ac6('0x15'),this['squeue']['id'],_0x5347fe);}else{util[_0x2ac6('0x20')](this[_0x2ac6('0x4')],this['squeue']['id'],this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x5347fe],this[_0x2ac6('0x10')],this['routing']);util['writeLog'](this[_0x2ac6('0x5')]['id'],this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x5347fe],_0x5a3f76?_0x2ac6('0x21'):_0x2ac6('0x22'));this[_0x2ac6('0x6')][_0x2ac6('0x13')][_0x5347fe]['busy']=![];this[_0x2ac6('0x6')]['agents'][_0x5347fe][_0x2ac6('0x1a')]=undefined;util[_0x2ac6('0x23')](this['realtime'],this[_0x2ac6('0x3')],this['realtime']['agents'][_0x5347fe],this[_0x2ac6('0x5')][_0x2ac6('0x17')]);}}}if(!_0x5a3f76){setTimeout(this[_0x2ac6('0x7')][_0x2ac6('0xa')](this),0x3e8);}};function beepall(_0x3500c0,_0x4bee7b,_0x14891f,_0x1f687e){return new Beepall(_0x3500c0,_0x4bee7b,_0x14891f,_0x1f687e);}module[_0x2ac6('0x24')]=beepall;