c7e747da884be1ad327f5fa2ea422e0cbc8aaeb3
[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 _0x6c63=['isNil','Agents','length','realtime','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','busy','busyQueue','name','debug','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification','writeLog','STOP','TIMEOUT','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','push','handleRun','bind','timeout','drained','handleDrained','prototype','handleTimeout'];(function(_0x261840,_0x16b995){var _0x4a5327=function(_0x78d8ea){while(--_0x78d8ea){_0x261840['push'](_0x261840['shift']());}};_0x4a5327(++_0x16b995);}(_0x6c63,0x1ee));var _0x36c6=function(_0x3da911,_0x76c861){_0x3da911=_0x3da911-0x0;var _0x1e2f50=_0x6c63[_0x3da911];return _0x1e2f50;};'use strict';var _=require(_0x36c6('0x0'));var uuid=require(_0x36c6('0x1'));var util=require(_0x36c6('0x2'));var logger=require(_0x36c6('0x3'))(_0x36c6('0x4'));var Beepall=function(_0x346c5c,_0x4a80b2,_0x136502,_0x2a605b){this[_0x36c6('0x5')]=uuid['v4']();this[_0x36c6('0x6')]=_0x346c5c;this[_0x36c6('0x7')]=_0x4a80b2;this['realtime']=_0x136502;this[_0x36c6('0x4')]=_0x2a605b;this[_0x36c6('0x6')][_0x36c6('0x8')](this[_0x36c6('0x9')][_0x36c6('0xa')](this),this['handleTimeout'][_0x36c6('0xa')](this));this['squeue']['on'](_0x36c6('0xb'),this['handleTimeout'][_0x36c6('0xa')](this));this[_0x36c6('0x6')]['on'](_0x36c6('0xc'),this[_0x36c6('0xd')][_0x36c6('0xa')](this));};Beepall[_0x36c6('0xe')][_0x36c6('0x8')]=function(){this[_0x36c6('0x6')][_0x36c6('0x8')](this[_0x36c6('0x9')][_0x36c6('0xa')](this),this[_0x36c6('0xf')][_0x36c6('0xa')](this));};Beepall[_0x36c6('0xe')]['handleDrained']=function(){this[_0x36c6('0xf')](!![]);};Beepall[_0x36c6('0xe')][_0x36c6('0x9')]=function(){var _0x531c09=!![];if(!_[_0x36c6('0x10')](this[_0x36c6('0x7')])&&!_[_0x36c6('0x10')](this[_0x36c6('0x7')][_0x36c6('0x11')])&&this[_0x36c6('0x7')][_0x36c6('0x11')][_0x36c6('0x12')]>0x0){for(var _0x3871bc=0x0,_0x310d77;_0x3871bc<this['queue'][_0x36c6('0x11')]['length'];_0x3871bc+=0x1){_0x310d77=this[_0x36c6('0x7')]['Agents'][_0x3871bc]['id'];if(_[_0x36c6('0x10')](this[_0x36c6('0x13')][_0x36c6('0x14')][_0x310d77])){logger['debug'](_0x36c6('0x15'),this[_0x36c6('0x6')]['id'],_0x310d77);}else{if(util[_0x36c6('0x16')](this[_0x36c6('0x6')]['id'],this[_0x36c6('0x13')][_0x36c6('0x14')][_0x310d77],this[_0x36c6('0x6')]['channel'],!![])){_0x531c09=![];util['writeLog'](this[_0x36c6('0x6')]['id'],this[_0x36c6('0x13')]['agents'][_0x310d77],'RINGING');this[_0x36c6('0x13')][_0x36c6('0x14')][_0x310d77][_0x36c6('0x17')]=!![];this[_0x36c6('0x13')][_0x36c6('0x14')][_0x310d77][_0x36c6('0x18')]=this[_0x36c6('0x7')][_0x36c6('0x19')];util['showNotification'](this[_0x36c6('0x5')],this[_0x36c6('0x6')]['id'],this[_0x36c6('0x13')]['agents'][_0x310d77],this[_0x36c6('0x7')],this[_0x36c6('0x4')]);}}}if(_0x531c09){logger[_0x36c6('0x1a')](_0x36c6('0x1b'),this['squeue']['id']);setTimeout(this[_0x36c6('0x8')]['bind'](this),0x3e8);}}else{logger[_0x36c6('0x1a')](_0x36c6('0x1c'),this['squeue']['id']);setTimeout(this['push'][_0x36c6('0xa')](this),0x3e8);}};Beepall[_0x36c6('0xe')][_0x36c6('0xf')]=function(_0x4eae9a){if(!_['isNil'](this[_0x36c6('0x7')])&&!_[_0x36c6('0x10')](this[_0x36c6('0x7')][_0x36c6('0x11')])){for(var _0x27d433=0x0,_0x393894;_0x27d433<this[_0x36c6('0x7')][_0x36c6('0x11')][_0x36c6('0x12')];_0x27d433+=0x1){_0x393894=this[_0x36c6('0x7')][_0x36c6('0x11')][_0x27d433]['id'];if(_[_0x36c6('0x10')](this[_0x36c6('0x13')]['agents'][_0x393894])){logger[_0x36c6('0x1a')](_0x36c6('0x15'),this['squeue']['id'],_0x393894);}else{util[_0x36c6('0x1d')](this[_0x36c6('0x5')],this[_0x36c6('0x6')]['id'],this['realtime']['agents'][_0x393894],this['queue'],this[_0x36c6('0x4')]);util[_0x36c6('0x1e')](this[_0x36c6('0x6')]['id'],this[_0x36c6('0x13')][_0x36c6('0x14')][_0x393894],_0x4eae9a?_0x36c6('0x1f'):_0x36c6('0x20'));this[_0x36c6('0x13')]['agents'][_0x393894]['busy']=![];this[_0x36c6('0x13')][_0x36c6('0x14')][_0x393894][_0x36c6('0x18')]=undefined;}}}if(!_0x4eae9a){setTimeout(this[_0x36c6('0x8')]['bind'](this),0x3e8);}};function beepall(_0x2d2dae,_0x478d63,_0x1e9ba4,_0x58c896){return new Beepall(_0x2d2dae,_0x478d63,_0x1e9ba4,_0x58c896);}module[_0x36c6('0x21')]=beepall;