79cc1869ba4b5c4da1c9507919820ee7b554f9e8
[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 _0x3fec=['squeue','push','handleRun','bind','handleTimeout','timeout','drained','handleDrained','prototype','isNil','Agents','length','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','writeLog','agents','RINGING','busy','busyQueue','name','showNotification','[%s][QUEUE]\x20EMPTY','hideNotification','STOP','TIMEOUT','lodash','../../../../../config/logger','routing','notificationId','queue','realtime'];(function(_0x39c5e0,_0x4e6375){var _0x224d85=function(_0x5b034c){while(--_0x5b034c){_0x39c5e0['push'](_0x39c5e0['shift']());}};_0x224d85(++_0x4e6375);}(_0x3fec,0x1ba));var _0xc3fe=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x3fec[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0xc3fe('0x0'));var uuid=require('uuid');var util=require('./util');var logger=require(_0xc3fe('0x1'))(_0xc3fe('0x2'));var Beepall=function(_0x5adb4c,_0x3e2547,_0x4f85a4,_0x53a208){this[_0xc3fe('0x3')]=uuid['v4']();this['squeue']=_0x5adb4c;this[_0xc3fe('0x4')]=_0x3e2547;this[_0xc3fe('0x5')]=_0x4f85a4;this[_0xc3fe('0x2')]=_0x53a208;this[_0xc3fe('0x6')][_0xc3fe('0x7')](this[_0xc3fe('0x8')][_0xc3fe('0x9')](this),this[_0xc3fe('0xa')][_0xc3fe('0x9')](this));this[_0xc3fe('0x6')]['on'](_0xc3fe('0xb'),this[_0xc3fe('0xa')][_0xc3fe('0x9')](this));this[_0xc3fe('0x6')]['on'](_0xc3fe('0xc'),this[_0xc3fe('0xd')]['bind'](this));};Beepall[_0xc3fe('0xe')][_0xc3fe('0x7')]=function(){this['squeue'][_0xc3fe('0x7')](this[_0xc3fe('0x8')][_0xc3fe('0x9')](this),this[_0xc3fe('0xa')][_0xc3fe('0x9')](this));};Beepall[_0xc3fe('0xe')][_0xc3fe('0xd')]=function(){this[_0xc3fe('0xa')](!![]);};Beepall[_0xc3fe('0xe')][_0xc3fe('0x8')]=function(){var _0x4b8088=!![];if(!_[_0xc3fe('0xf')](this['queue'])&&!_[_0xc3fe('0xf')](this[_0xc3fe('0x4')][_0xc3fe('0x10')])&&this[_0xc3fe('0x4')][_0xc3fe('0x10')][_0xc3fe('0x11')]>0x0){for(var _0x1e291f=0x0,_0x31fdf4;_0x1e291f<this[_0xc3fe('0x4')][_0xc3fe('0x10')][_0xc3fe('0x11')];_0x1e291f+=0x1){_0x31fdf4=this[_0xc3fe('0x4')][_0xc3fe('0x10')][_0x1e291f]['id'];if(_[_0xc3fe('0xf')](this[_0xc3fe('0x5')]['agents'][_0x31fdf4])){logger[_0xc3fe('0x12')](_0xc3fe('0x13'),this[_0xc3fe('0x6')]['id'],_0x31fdf4);}else{if(util['isAgentAvailable'](this[_0xc3fe('0x6')]['id'],this[_0xc3fe('0x5')]['agents'][_0x31fdf4],this['squeue'][_0xc3fe('0x14')],!![])){_0x4b8088=![];util[_0xc3fe('0x15')](this[_0xc3fe('0x6')]['id'],this['realtime'][_0xc3fe('0x16')][_0x31fdf4],_0xc3fe('0x17'));this[_0xc3fe('0x5')][_0xc3fe('0x16')][_0x31fdf4][_0xc3fe('0x18')]=!![];this[_0xc3fe('0x5')][_0xc3fe('0x16')][_0x31fdf4][_0xc3fe('0x19')]=this[_0xc3fe('0x4')][_0xc3fe('0x1a')];util[_0xc3fe('0x1b')](this[_0xc3fe('0x3')],this['squeue']['id'],this[_0xc3fe('0x5')][_0xc3fe('0x16')][_0x31fdf4],this[_0xc3fe('0x4')],this[_0xc3fe('0x2')]);}}}if(_0x4b8088){logger[_0xc3fe('0x12')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0xc3fe('0x6')]['id']);setTimeout(this[_0xc3fe('0x7')][_0xc3fe('0x9')](this),0x3e8);}}else{logger[_0xc3fe('0x12')](_0xc3fe('0x1c'),this[_0xc3fe('0x6')]['id']);setTimeout(this[_0xc3fe('0x7')][_0xc3fe('0x9')](this),0x3e8);}};Beepall[_0xc3fe('0xe')][_0xc3fe('0xa')]=function(_0x391167){if(!_[_0xc3fe('0xf')](this[_0xc3fe('0x4')])&&!_[_0xc3fe('0xf')](this[_0xc3fe('0x4')][_0xc3fe('0x10')])){for(var _0x3cb4a7=0x0,_0xe2117a;_0x3cb4a7<this['queue'][_0xc3fe('0x10')][_0xc3fe('0x11')];_0x3cb4a7+=0x1){_0xe2117a=this[_0xc3fe('0x4')][_0xc3fe('0x10')][_0x3cb4a7]['id'];if(_[_0xc3fe('0xf')](this[_0xc3fe('0x5')][_0xc3fe('0x16')][_0xe2117a])){logger[_0xc3fe('0x12')](_0xc3fe('0x13'),this[_0xc3fe('0x6')]['id'],_0xe2117a);}else{util[_0xc3fe('0x1d')](this['notificationId'],this['squeue']['id'],this['realtime'][_0xc3fe('0x16')][_0xe2117a],this[_0xc3fe('0x4')],this['routing']);util[_0xc3fe('0x15')](this[_0xc3fe('0x6')]['id'],this['realtime']['agents'][_0xe2117a],_0x391167?_0xc3fe('0x1e'):_0xc3fe('0x1f'));this[_0xc3fe('0x5')][_0xc3fe('0x16')][_0xe2117a]['busy']=![];this['realtime'][_0xc3fe('0x16')][_0xe2117a][_0xc3fe('0x19')]=undefined;}}}if(!_0x391167){setTimeout(this[_0xc3fe('0x7')][_0xc3fe('0x9')](this),0x3e8);}};function beepall(_0x5a9711,_0x299b61,_0x484e59,_0x1b0090){return new Beepall(_0x5a9711,_0x299b61,_0x484e59,_0x1b0090);}module['exports']=beepall;