Built motion from commit 85328c08.|2.5.50
[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 _0x294b=['busy','busyQueue','name','showNotification','notificationId','info','[%s][QUEUE]\x20EMPTY','hideNotification','STOP','exports','lodash','./util','../../../../../config/logger','routing','squeue','queue','realtime','handleRun','timeout','handleTimeout','handleDrained','bind','prototype','push','isNil','Agents','length','agents','isAgentAvailable','channel','writeLog','RINGING'];(function(_0xe0fc7c,_0x3fa8e8){var _0x589d78=function(_0x285f75){while(--_0x285f75){_0xe0fc7c['push'](_0xe0fc7c['shift']());}};_0x589d78(++_0x3fa8e8);}(_0x294b,0xea));var _0xb294=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x294b[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xb294('0x0'));var uuid=require('uuid');var util=require(_0xb294('0x1'));var logger=require(_0xb294('0x2'))(_0xb294('0x3'));var Beepall=function(_0x411640,_0x1cd458,_0x417648,_0x58fe24){this['notificationId']=uuid['v4']();this[_0xb294('0x4')]=_0x411640;this[_0xb294('0x5')]=_0x1cd458;this[_0xb294('0x6')]=_0x417648;this[_0xb294('0x3')]=_0x58fe24;this[_0xb294('0x4')]['push'](this[_0xb294('0x7')]['bind'](this),this['handleTimeout']['bind'](this));this[_0xb294('0x4')]['on'](_0xb294('0x8'),this[_0xb294('0x9')]['bind'](this));this['squeue']['on']('drained',this[_0xb294('0xa')][_0xb294('0xb')](this));};Beepall[_0xb294('0xc')][_0xb294('0xd')]=function(){this[_0xb294('0x4')][_0xb294('0xd')](this[_0xb294('0x7')][_0xb294('0xb')](this),this[_0xb294('0x9')][_0xb294('0xb')](this));};Beepall['prototype']['handleDrained']=function(_0xe8178e){this['handleTimeout'](!![]);};Beepall['prototype'][_0xb294('0x7')]=function(_0x870d74){var _0x46a7b9=!![];if(!_[_0xb294('0xe')](this[_0xb294('0x5')])&&!_[_0xb294('0xe')](this[_0xb294('0x5')][_0xb294('0xf')])&&this[_0xb294('0x5')][_0xb294('0xf')][_0xb294('0x10')]>0x0){for(var _0x51110b=0x0,_0x191b7f;_0x51110b<this[_0xb294('0x5')]['Agents']['length'];_0x51110b+=0x1){_0x191b7f=this[_0xb294('0x5')][_0xb294('0xf')][_0x51110b]['id'];if(_[_0xb294('0xe')](this[_0xb294('0x6')][_0xb294('0x11')][_0x191b7f])){logger['info']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xb294('0x4')]['id'],_0x191b7f);}else{if(util[_0xb294('0x12')](this['squeue']['id'],this[_0xb294('0x6')][_0xb294('0x11')][_0x191b7f],this['squeue'][_0xb294('0x13')],!![])){_0x46a7b9=![];util[_0xb294('0x14')](this[_0xb294('0x4')]['id'],this['realtime']['agents'][_0x191b7f],_0xb294('0x15'));this['realtime'][_0xb294('0x11')][_0x191b7f][_0xb294('0x16')]=!![];this[_0xb294('0x6')]['agents'][_0x191b7f][_0xb294('0x17')]=this['queue'][_0xb294('0x18')];util[_0xb294('0x19')](this[_0xb294('0x1a')],this[_0xb294('0x4')]['id'],this[_0xb294('0x6')][_0xb294('0x11')][_0x191b7f],this[_0xb294('0x5')],this[_0xb294('0x3')]);}}}if(_0x46a7b9){logger[_0xb294('0x1b')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this['squeue']['id']);setTimeout(this[_0xb294('0xd')][_0xb294('0xb')](this),0x3e8);}}else{logger[_0xb294('0x1b')](_0xb294('0x1c'),this['squeue']['id']);setTimeout(this['push'][_0xb294('0xb')](this),0x3e8);}};Beepall[_0xb294('0xc')][_0xb294('0x9')]=function(_0x127ddd){if(!_['isNil'](this['queue'])&&!_['isNil'](this[_0xb294('0x5')][_0xb294('0xf')])){for(var _0x1c6138=0x0,_0x2c925a;_0x1c6138<this[_0xb294('0x5')][_0xb294('0xf')][_0xb294('0x10')];_0x1c6138+=0x1){_0x2c925a=this[_0xb294('0x5')][_0xb294('0xf')][_0x1c6138]['id'];if(_[_0xb294('0xe')](this[_0xb294('0x6')][_0xb294('0x11')][_0x2c925a])){logger[_0xb294('0x1b')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],_0x2c925a);}else{util[_0xb294('0x1d')](this['notificationId'],this[_0xb294('0x4')]['id'],this[_0xb294('0x6')][_0xb294('0x11')][_0x2c925a],this[_0xb294('0x5')],this['routing']);util[_0xb294('0x14')](this[_0xb294('0x4')]['id'],this[_0xb294('0x6')][_0xb294('0x11')][_0x2c925a],_0x127ddd?_0xb294('0x1e'):'TIMEOUT');this['realtime']['agents'][_0x2c925a][_0xb294('0x16')]=![];this[_0xb294('0x6')][_0xb294('0x11')][_0x2c925a][_0xb294('0x17')]=undefined;}}}if(!_0x127ddd){setTimeout(this[_0xb294('0xd')][_0xb294('0xb')](this),0x3e8);}};function beepall(_0x51d772,_0x5df86d,_0x3f2e12,_0x16122d){return new Beepall(_0x51d772,_0x5df86d,_0x3f2e12,_0x16122d);}module[_0xb294('0x1f')]=beepall;