45a0d4998d9c907c9e8b10740ad50a84066f27e8
[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 _0x4d07=['debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','RINGING','busy','busyQueue','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','TIMEOUT','channel','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','bind','handleTimeout','timeout','drained','prototype','handleRun','handleDrained','isNil','Agents','length','agents'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x4d07,0x103));var _0x74d0=function(_0x40af98,_0x741324){_0x40af98=_0x40af98-0x0;var _0x570ba3=_0x4d07[_0x40af98];return _0x570ba3;};'use strict';var _=require(_0x74d0('0x0'));var uuid=require(_0x74d0('0x1'));var util=require(_0x74d0('0x2'));var logger=require(_0x74d0('0x3'))(_0x74d0('0x4'));var Beepall=function(_0x1bbbc5,_0x2d16ad,_0x454860,_0xb95b1){this[_0x74d0('0x5')]=uuid['v4']();this[_0x74d0('0x6')]=_0x1bbbc5;this[_0x74d0('0x7')]=_0x2d16ad;this[_0x74d0('0x8')]=_0x454860;this['routing']=_0xb95b1;this[_0x74d0('0x6')][_0x74d0('0x9')](this['handleRun'][_0x74d0('0xa')](this),this[_0x74d0('0xb')][_0x74d0('0xa')](this));this[_0x74d0('0x6')]['on'](_0x74d0('0xc'),this[_0x74d0('0xb')][_0x74d0('0xa')](this));this[_0x74d0('0x6')]['on'](_0x74d0('0xd'),this['handleDrained'][_0x74d0('0xa')](this));};Beepall[_0x74d0('0xe')][_0x74d0('0x9')]=function(){this[_0x74d0('0x6')][_0x74d0('0x9')](this[_0x74d0('0xf')][_0x74d0('0xa')](this),this[_0x74d0('0xb')]['bind'](this));};Beepall[_0x74d0('0xe')][_0x74d0('0x10')]=function(){this[_0x74d0('0xb')](!![]);};Beepall['prototype'][_0x74d0('0xf')]=function(){var _0x469e8c=!![];if(!_[_0x74d0('0x11')](this['queue'])&&!_[_0x74d0('0x11')](this[_0x74d0('0x7')][_0x74d0('0x12')])&&this[_0x74d0('0x7')]['Agents']['length']>0x0){for(var _0x599af3=0x0,_0x583805;_0x599af3<this[_0x74d0('0x7')]['Agents'][_0x74d0('0x13')];_0x599af3+=0x1){_0x583805=this[_0x74d0('0x7')][_0x74d0('0x12')][_0x599af3]['id'];if(_[_0x74d0('0x11')](this[_0x74d0('0x8')][_0x74d0('0x14')][_0x583805])){logger[_0x74d0('0x15')](_0x74d0('0x16'),this[_0x74d0('0x6')]['id'],_0x583805);}else{if(util[_0x74d0('0x17')](this[_0x74d0('0x6')]['id'],this[_0x74d0('0x8')][_0x74d0('0x14')][_0x583805],this[_0x74d0('0x6')]['channel'],!![])){_0x469e8c=![];util[_0x74d0('0x18')](this[_0x74d0('0x6')]['id'],this[_0x74d0('0x8')]['agents'][_0x583805],_0x74d0('0x19'));this['realtime'][_0x74d0('0x14')][_0x583805][_0x74d0('0x1a')]=!![];this['realtime']['agents'][_0x583805][_0x74d0('0x1b')]=this[_0x74d0('0x7')][_0x74d0('0x1c')];util['saveWaitingNotification'](this[_0x74d0('0x8')],this[_0x74d0('0x4')],this['queue']['Agents'][_0x599af3],this[_0x74d0('0x6')]['channel']);util[_0x74d0('0x1d')](this['notificationId'],this[_0x74d0('0x6')]['id'],this[_0x74d0('0x8')]['agents'][_0x583805],this[_0x74d0('0x7')],this[_0x74d0('0x4')]);}}}if(_0x469e8c){logger[_0x74d0('0x15')](_0x74d0('0x1e'),this[_0x74d0('0x6')]['id']);setTimeout(this[_0x74d0('0x9')][_0x74d0('0xa')](this),0x3e8);}}else{logger[_0x74d0('0x15')](_0x74d0('0x1f'),this[_0x74d0('0x6')]['id']);setTimeout(this[_0x74d0('0x9')][_0x74d0('0xa')](this),0x3e8);}};Beepall[_0x74d0('0xe')][_0x74d0('0xb')]=function(_0x3ee4e0){if(!_[_0x74d0('0x11')](this['queue'])&&!_[_0x74d0('0x11')](this[_0x74d0('0x7')][_0x74d0('0x12')])){for(var _0x2ca4c6=0x0,_0x4f5bd3;_0x2ca4c6<this[_0x74d0('0x7')][_0x74d0('0x12')]['length'];_0x2ca4c6+=0x1){_0x4f5bd3=this[_0x74d0('0x7')][_0x74d0('0x12')][_0x2ca4c6]['id'];if(_['isNil'](this[_0x74d0('0x8')]['agents'][_0x4f5bd3])){logger['debug'](_0x74d0('0x16'),this['squeue']['id'],_0x4f5bd3);}else{util[_0x74d0('0x20')](this[_0x74d0('0x5')],this[_0x74d0('0x6')]['id'],this[_0x74d0('0x8')][_0x74d0('0x14')][_0x4f5bd3],this[_0x74d0('0x7')],this['routing']);util[_0x74d0('0x18')](this[_0x74d0('0x6')]['id'],this[_0x74d0('0x8')][_0x74d0('0x14')][_0x4f5bd3],_0x3ee4e0?'STOP':_0x74d0('0x21'));this['realtime']['agents'][_0x4f5bd3]['busy']=![];this[_0x74d0('0x8')][_0x74d0('0x14')][_0x4f5bd3][_0x74d0('0x1b')]=undefined;util['removeWaitingNotification'](this[_0x74d0('0x8')],this[_0x74d0('0x4')],this['realtime'][_0x74d0('0x14')][_0x4f5bd3],this[_0x74d0('0x6')][_0x74d0('0x22')]);}}}if(!_0x3ee4e0){setTimeout(this[_0x74d0('0x9')][_0x74d0('0xa')](this),0x3e8);}};function beepall(_0x4647f8,_0xb1521e,_0x483e22,_0x41d696){return new Beepall(_0x4647f8,_0xb1521e,_0x483e22,_0x41d696);}module['exports']=beepall;