Built motion from commit b5996064.|2.6.21
[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 _0xf480=['isNil','Agents','length','realtime','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','RINGING','busy','name','saveWaitingNotification','channel','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','STOP','busyQueue','removeWaitingNotification','exports','lodash','uuid','../../../../../config/logger','routing','notificationId','squeue','queue','push','bind','handleTimeout','drained','handleDrained','prototype','handleRun'];(function(_0x360139,_0x5cf060){var _0x3e5e5c=function(_0x583486){while(--_0x583486){_0x360139['push'](_0x360139['shift']());}};_0x3e5e5c(++_0x5cf060);}(_0xf480,0x76));var _0x0f48=function(_0x4fe1e8,_0x43afce){_0x4fe1e8=_0x4fe1e8-0x0;var _0x1791d6=_0xf480[_0x4fe1e8];return _0x1791d6;};'use strict';var _=require(_0x0f48('0x0'));var uuid=require(_0x0f48('0x1'));var util=require('./util');var logger=require(_0x0f48('0x2'))(_0x0f48('0x3'));var Beepall=function(_0x1eeeee,_0x1c877a,_0x39f1f5,_0xf36732){this[_0x0f48('0x4')]=uuid['v4']();this[_0x0f48('0x5')]=_0x1eeeee;this[_0x0f48('0x6')]=_0x1c877a;this['realtime']=_0x39f1f5;this[_0x0f48('0x3')]=_0xf36732;this['squeue'][_0x0f48('0x7')](this['handleRun'][_0x0f48('0x8')](this),this[_0x0f48('0x9')][_0x0f48('0x8')](this));this['squeue']['on']('timeout',this[_0x0f48('0x9')][_0x0f48('0x8')](this));this[_0x0f48('0x5')]['on'](_0x0f48('0xa'),this[_0x0f48('0xb')]['bind'](this));};Beepall[_0x0f48('0xc')]['push']=function(){this[_0x0f48('0x5')][_0x0f48('0x7')](this[_0x0f48('0xd')][_0x0f48('0x8')](this),this[_0x0f48('0x9')][_0x0f48('0x8')](this));};Beepall[_0x0f48('0xc')][_0x0f48('0xb')]=function(){this[_0x0f48('0x9')](!![]);};Beepall[_0x0f48('0xc')][_0x0f48('0xd')]=function(){var _0x1fb04f=!![];if(!_['isNil'](this['queue'])&&!_[_0x0f48('0xe')](this[_0x0f48('0x6')]['Agents'])&&this[_0x0f48('0x6')][_0x0f48('0xf')][_0x0f48('0x10')]>0x0){for(var _0x45ac2c=0x0,_0x50e530;_0x45ac2c<this[_0x0f48('0x6')][_0x0f48('0xf')][_0x0f48('0x10')];_0x45ac2c+=0x1){_0x50e530=this[_0x0f48('0x6')][_0x0f48('0xf')][_0x45ac2c]['id'];if(_[_0x0f48('0xe')](this[_0x0f48('0x11')][_0x0f48('0x12')][_0x50e530])){logger[_0x0f48('0x13')](_0x0f48('0x14'),this['squeue']['id'],_0x50e530);}else{if(util[_0x0f48('0x15')](this['squeue']['id'],this['realtime'][_0x0f48('0x12')][_0x50e530],this[_0x0f48('0x5')]['channel'],!![])){_0x1fb04f=![];util['writeLog'](this[_0x0f48('0x5')]['id'],this[_0x0f48('0x11')]['agents'][_0x50e530],_0x0f48('0x16'));this[_0x0f48('0x11')]['agents'][_0x50e530][_0x0f48('0x17')]=!![];this['realtime'][_0x0f48('0x12')][_0x50e530]['busyQueue']=this[_0x0f48('0x6')][_0x0f48('0x18')];util[_0x0f48('0x19')](this[_0x0f48('0x11')],this['routing'],this[_0x0f48('0x6')][_0x0f48('0xf')][_0x45ac2c],this[_0x0f48('0x5')][_0x0f48('0x1a')]);util[_0x0f48('0x1b')](this['notificationId'],this[_0x0f48('0x5')]['id'],this[_0x0f48('0x11')]['agents'][_0x50e530],this[_0x0f48('0x6')],this[_0x0f48('0x3')]);}}}if(_0x1fb04f){logger[_0x0f48('0x13')](_0x0f48('0x1c'),this['squeue']['id']);setTimeout(this[_0x0f48('0x7')][_0x0f48('0x8')](this),0x3e8);}}else{logger[_0x0f48('0x13')]('[%s][QUEUE]\x20EMPTY',this[_0x0f48('0x5')]['id']);setTimeout(this[_0x0f48('0x7')][_0x0f48('0x8')](this),0x3e8);}};Beepall['prototype'][_0x0f48('0x9')]=function(_0x575f2e){if(!_[_0x0f48('0xe')](this[_0x0f48('0x6')])&&!_['isNil'](this[_0x0f48('0x6')][_0x0f48('0xf')])){for(var _0x16eb54=0x0,_0x4d35bc;_0x16eb54<this['queue'][_0x0f48('0xf')][_0x0f48('0x10')];_0x16eb54+=0x1){_0x4d35bc=this[_0x0f48('0x6')]['Agents'][_0x16eb54]['id'];if(_[_0x0f48('0xe')](this[_0x0f48('0x11')]['agents'][_0x4d35bc])){logger[_0x0f48('0x13')](_0x0f48('0x14'),this['squeue']['id'],_0x4d35bc);}else{util['hideNotification'](this['notificationId'],this['squeue']['id'],this[_0x0f48('0x11')][_0x0f48('0x12')][_0x4d35bc],this['queue'],this[_0x0f48('0x3')]);util['writeLog'](this[_0x0f48('0x5')]['id'],this[_0x0f48('0x11')]['agents'][_0x4d35bc],_0x575f2e?_0x0f48('0x1d'):'TIMEOUT');this[_0x0f48('0x11')][_0x0f48('0x12')][_0x4d35bc][_0x0f48('0x17')]=![];this['realtime']['agents'][_0x4d35bc][_0x0f48('0x1e')]=undefined;util[_0x0f48('0x1f')](this['realtime'],this[_0x0f48('0x3')],this['realtime']['agents'][_0x4d35bc],this[_0x0f48('0x5')][_0x0f48('0x1a')]);}}}if(!_0x575f2e){setTimeout(this['push'][_0x0f48('0x8')](this),0x3e8);}};function beepall(_0x579c5d,_0x52325f,_0x58a1a8,_0x4efd98){return new Beepall(_0x579c5d,_0x52325f,_0x58a1a8,_0x4efd98);}module[_0x0f48('0x20')]=beepall;