Built motion from commit da617fac.|2.6.6
[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 _0x6611=['debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','agents','channel','writeLog','busy','showNotification','STOP','TIMEOUT','busyQueue','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind','timeout','handleTimeout','drained','handleDrained','prototype','isNil','Agents','length'];(function(_0x5c965e,_0x2556b7){var _0x1e1e49=function(_0x4b717c){while(--_0x4b717c){_0x5c965e['push'](_0x5c965e['shift']());}};_0x1e1e49(++_0x2556b7);}(_0x6611,0xdd));var _0x1661=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0x6611[_0x432682];return _0x463d05;};'use strict';var _=require('lodash');var uuid=require(_0x1661('0x0'));var util=require(_0x1661('0x1'));var logger=require(_0x1661('0x2'))(_0x1661('0x3'));var Beepall=function(_0x3dcfbd,_0x474832,_0x44e418,_0x25bce6){this[_0x1661('0x4')]=uuid['v4']();this[_0x1661('0x5')]=_0x3dcfbd;this[_0x1661('0x6')]=_0x474832;this[_0x1661('0x7')]=_0x44e418;this['routing']=_0x25bce6;this['squeue'][_0x1661('0x8')](this[_0x1661('0x9')]['bind'](this),this['handleTimeout'][_0x1661('0xa')](this));this[_0x1661('0x5')]['on'](_0x1661('0xb'),this[_0x1661('0xc')][_0x1661('0xa')](this));this[_0x1661('0x5')]['on'](_0x1661('0xd'),this[_0x1661('0xe')]['bind'](this));};Beepall[_0x1661('0xf')][_0x1661('0x8')]=function(){this['squeue'][_0x1661('0x8')](this['handleRun'][_0x1661('0xa')](this),this[_0x1661('0xc')][_0x1661('0xa')](this));};Beepall[_0x1661('0xf')][_0x1661('0xe')]=function(){this[_0x1661('0xc')](!![]);};Beepall[_0x1661('0xf')][_0x1661('0x9')]=function(){var _0x2febb5=!![];if(!_[_0x1661('0x10')](this[_0x1661('0x6')])&&!_[_0x1661('0x10')](this[_0x1661('0x6')]['Agents'])&&this['queue'][_0x1661('0x11')][_0x1661('0x12')]>0x0){for(var _0x55ef62=0x0,_0x3b39df;_0x55ef62<this[_0x1661('0x6')][_0x1661('0x11')][_0x1661('0x12')];_0x55ef62+=0x1){_0x3b39df=this['queue'][_0x1661('0x11')][_0x55ef62]['id'];if(_['isNil'](this[_0x1661('0x7')]['agents'][_0x3b39df])){logger[_0x1661('0x13')](_0x1661('0x14'),this['squeue']['id'],_0x3b39df);}else{if(util[_0x1661('0x15')](this['squeue']['id'],this[_0x1661('0x7')][_0x1661('0x16')][_0x3b39df],this[_0x1661('0x5')][_0x1661('0x17')],!![])){_0x2febb5=![];util[_0x1661('0x18')](this[_0x1661('0x5')]['id'],this[_0x1661('0x7')]['agents'][_0x3b39df],'RINGING');this[_0x1661('0x7')][_0x1661('0x16')][_0x3b39df][_0x1661('0x19')]=!![];this[_0x1661('0x7')][_0x1661('0x16')][_0x3b39df]['busyQueue']=this[_0x1661('0x6')]['name'];util[_0x1661('0x1a')](this[_0x1661('0x4')],this[_0x1661('0x5')]['id'],this[_0x1661('0x7')]['agents'][_0x3b39df],this[_0x1661('0x6')],this[_0x1661('0x3')]);}}}if(_0x2febb5){logger[_0x1661('0x13')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0x1661('0x5')]['id']);setTimeout(this[_0x1661('0x8')]['bind'](this),0x3e8);}}else{logger[_0x1661('0x13')]('[%s][QUEUE]\x20EMPTY',this[_0x1661('0x5')]['id']);setTimeout(this[_0x1661('0x8')][_0x1661('0xa')](this),0x3e8);}};Beepall[_0x1661('0xf')][_0x1661('0xc')]=function(_0x3eb848){if(!_[_0x1661('0x10')](this[_0x1661('0x6')])&&!_['isNil'](this[_0x1661('0x6')][_0x1661('0x11')])){for(var _0x5eceb6=0x0,_0x4ee574;_0x5eceb6<this[_0x1661('0x6')]['Agents'][_0x1661('0x12')];_0x5eceb6+=0x1){_0x4ee574=this[_0x1661('0x6')]['Agents'][_0x5eceb6]['id'];if(_[_0x1661('0x10')](this[_0x1661('0x7')][_0x1661('0x16')][_0x4ee574])){logger[_0x1661('0x13')](_0x1661('0x14'),this[_0x1661('0x5')]['id'],_0x4ee574);}else{util['hideNotification'](this[_0x1661('0x4')],this[_0x1661('0x5')]['id'],this['realtime'][_0x1661('0x16')][_0x4ee574],this[_0x1661('0x6')],this['routing']);util[_0x1661('0x18')](this['squeue']['id'],this[_0x1661('0x7')][_0x1661('0x16')][_0x4ee574],_0x3eb848?_0x1661('0x1b'):_0x1661('0x1c'));this[_0x1661('0x7')][_0x1661('0x16')][_0x4ee574][_0x1661('0x19')]=![];this['realtime'][_0x1661('0x16')][_0x4ee574][_0x1661('0x1d')]=undefined;}}}if(!_0x3eb848){setTimeout(this[_0x1661('0x8')][_0x1661('0xa')](this),0x3e8);}};function beepall(_0x5308be,_0x734172,_0x267844,_0x429a51){return new Beepall(_0x5308be,_0x734172,_0x267844,_0x429a51);}module['exports']=beepall;