Built motion from commit 96f8de6d.|2.6.3
[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 _0xa2c8=['handleDrained','prototype','push','isNil','Agents','length','agents','info','channel','writeLog','RINGING','busyQueue','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','notificationId','STOP','TIMEOUT','busy','lodash','uuid','./util','../../../../../config/logger','routing','queue','realtime','squeue','handleRun','bind','handleTimeout','drained'];(function(_0x350ca8,_0x5530a8){var _0x194742=function(_0x3277a9){while(--_0x3277a9){_0x350ca8['push'](_0x350ca8['shift']());}};_0x194742(++_0x5530a8);}(_0xa2c8,0x99));var _0x8a2c=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xa2c8[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x8a2c('0x0'));var uuid=require(_0x8a2c('0x1'));var util=require(_0x8a2c('0x2'));var logger=require(_0x8a2c('0x3'))(_0x8a2c('0x4'));var Beepall=function(_0x67da9d,_0x48d4f9,_0x1b1142,_0x590508){this['notificationId']=uuid['v4']();this['squeue']=_0x67da9d;this[_0x8a2c('0x5')]=_0x48d4f9;this[_0x8a2c('0x6')]=_0x1b1142;this[_0x8a2c('0x4')]=_0x590508;this[_0x8a2c('0x7')]['push'](this[_0x8a2c('0x8')][_0x8a2c('0x9')](this),this[_0x8a2c('0xa')]['bind'](this));this['squeue']['on']('timeout',this[_0x8a2c('0xa')][_0x8a2c('0x9')](this));this['squeue']['on'](_0x8a2c('0xb'),this[_0x8a2c('0xc')][_0x8a2c('0x9')](this));};Beepall[_0x8a2c('0xd')][_0x8a2c('0xe')]=function(){this[_0x8a2c('0x7')]['push'](this[_0x8a2c('0x8')][_0x8a2c('0x9')](this),this['handleTimeout'][_0x8a2c('0x9')](this));};Beepall[_0x8a2c('0xd')]['handleDrained']=function(_0x5a1fa7){this['handleTimeout'](!![]);};Beepall['prototype'][_0x8a2c('0x8')]=function(_0x16c114){var _0x30b3c2=!![];if(!_['isNil'](this['queue'])&&!_[_0x8a2c('0xf')](this[_0x8a2c('0x5')][_0x8a2c('0x10')])&&this[_0x8a2c('0x5')][_0x8a2c('0x10')][_0x8a2c('0x11')]>0x0){for(var _0x3d82a5=0x0,_0x3e18f1;_0x3d82a5<this['queue']['Agents'][_0x8a2c('0x11')];_0x3d82a5+=0x1){_0x3e18f1=this[_0x8a2c('0x5')][_0x8a2c('0x10')][_0x3d82a5]['id'];if(_[_0x8a2c('0xf')](this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x3e18f1])){logger[_0x8a2c('0x13')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8a2c('0x7')]['id'],_0x3e18f1);}else{if(util['isAgentAvailable'](this[_0x8a2c('0x7')]['id'],this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x3e18f1],this[_0x8a2c('0x7')][_0x8a2c('0x14')],!![])){_0x30b3c2=![];util[_0x8a2c('0x15')](this[_0x8a2c('0x7')]['id'],this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x3e18f1],_0x8a2c('0x16'));this['realtime'][_0x8a2c('0x12')][_0x3e18f1]['busy']=!![];this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x3e18f1][_0x8a2c('0x17')]=this[_0x8a2c('0x5')][_0x8a2c('0x18')];util[_0x8a2c('0x19')](this['notificationId'],this['squeue']['id'],this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x3e18f1],this[_0x8a2c('0x5')],this[_0x8a2c('0x4')]);}}}if(_0x30b3c2){logger['info'](_0x8a2c('0x1a'),this[_0x8a2c('0x7')]['id']);setTimeout(this[_0x8a2c('0xe')][_0x8a2c('0x9')](this),0x3e8);}}else{logger[_0x8a2c('0x13')](_0x8a2c('0x1b'),this['squeue']['id']);setTimeout(this[_0x8a2c('0xe')][_0x8a2c('0x9')](this),0x3e8);}};Beepall[_0x8a2c('0xd')]['handleTimeout']=function(_0x2414c5){if(!_['isNil'](this[_0x8a2c('0x5')])&&!_['isNil'](this['queue'][_0x8a2c('0x10')])){for(var _0x2be286=0x0,_0x5edce2;_0x2be286<this[_0x8a2c('0x5')][_0x8a2c('0x10')][_0x8a2c('0x11')];_0x2be286+=0x1){_0x5edce2=this['queue'][_0x8a2c('0x10')][_0x2be286]['id'];if(_[_0x8a2c('0xf')](this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x5edce2])){logger[_0x8a2c('0x13')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8a2c('0x7')]['id'],_0x5edce2);}else{util[_0x8a2c('0x1c')](this[_0x8a2c('0x1d')],this[_0x8a2c('0x7')]['id'],this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x5edce2],this['queue'],this[_0x8a2c('0x4')]);util[_0x8a2c('0x15')](this['squeue']['id'],this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x5edce2],_0x2414c5?_0x8a2c('0x1e'):_0x8a2c('0x1f'));this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x5edce2][_0x8a2c('0x20')]=![];this[_0x8a2c('0x6')][_0x8a2c('0x12')][_0x5edce2]['busyQueue']=undefined;}}}if(!_0x2414c5){setTimeout(this[_0x8a2c('0xe')][_0x8a2c('0x9')](this),0x3e8);}};function beepall(_0x3cfc18,_0x46245a,_0x1cdda8,_0x3b6d81){return new Beepall(_0x3cfc18,_0x46245a,_0x1cdda8,_0x3b6d81);}module['exports']=beepall;