865edf75a47296d543fca066ade3adc5049b8102
[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 _0x6fc4=['prototype','handleDrained','isNil','Agents','length','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','showNotification','info','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','STOP','TIMEOUT','exports','lodash','uuid','routing','notificationId','squeue','queue','realtime','push','handleTimeout','bind','timeout','drained','handleRun'];(function(_0x5bac7d,_0x53aedf){var _0x4a5249=function(_0xa55dbd){while(--_0xa55dbd){_0x5bac7d['push'](_0x5bac7d['shift']());}};_0x4a5249(++_0x53aedf);}(_0x6fc4,0x1a0));var _0x46fc=function(_0x3dd8dd,_0x369f8e){_0x3dd8dd=_0x3dd8dd-0x0;var _0x33e300=_0x6fc4[_0x3dd8dd];return _0x33e300;};'use strict';var _=require(_0x46fc('0x0'));var uuid=require(_0x46fc('0x1'));var util=require('./util');var logger=require('../../../../../config/logger')(_0x46fc('0x2'));var Beepall=function(_0x5caf97,_0x47e69d,_0x4e3ca5,_0x34e479){this[_0x46fc('0x3')]=uuid['v4']();this[_0x46fc('0x4')]=_0x5caf97;this[_0x46fc('0x5')]=_0x47e69d;this[_0x46fc('0x6')]=_0x4e3ca5;this[_0x46fc('0x2')]=_0x34e479;this[_0x46fc('0x4')][_0x46fc('0x7')](this['handleRun']['bind'](this),this[_0x46fc('0x8')][_0x46fc('0x9')](this));this[_0x46fc('0x4')]['on'](_0x46fc('0xa'),this['handleTimeout']['bind'](this));this[_0x46fc('0x4')]['on'](_0x46fc('0xb'),this['handleDrained'][_0x46fc('0x9')](this));};Beepall['prototype'][_0x46fc('0x7')]=function(){this[_0x46fc('0x4')][_0x46fc('0x7')](this[_0x46fc('0xc')][_0x46fc('0x9')](this),this[_0x46fc('0x8')][_0x46fc('0x9')](this));};Beepall[_0x46fc('0xd')][_0x46fc('0xe')]=function(_0x139971){this[_0x46fc('0x8')](!![]);};Beepall[_0x46fc('0xd')][_0x46fc('0xc')]=function(_0x426e17){var _0xafb8b9=!![];if(!_[_0x46fc('0xf')](this[_0x46fc('0x5')])&&!_[_0x46fc('0xf')](this['queue'][_0x46fc('0x10')])&&this[_0x46fc('0x5')][_0x46fc('0x10')][_0x46fc('0x11')]>0x0){for(var _0xd40ad2=0x0,_0x5baa81;_0xd40ad2<this[_0x46fc('0x5')][_0x46fc('0x10')][_0x46fc('0x11')];_0xd40ad2+=0x1){_0x5baa81=this[_0x46fc('0x5')][_0x46fc('0x10')][_0xd40ad2]['id'];if(_[_0x46fc('0xf')](this['realtime'][_0x46fc('0x12')][_0x5baa81])){logger['info'](_0x46fc('0x13'),this[_0x46fc('0x4')]['id'],_0x5baa81);}else{if(util[_0x46fc('0x14')](this[_0x46fc('0x4')]['id'],this['realtime']['agents'][_0x5baa81],this[_0x46fc('0x4')][_0x46fc('0x15')],!![])){_0xafb8b9=![];util[_0x46fc('0x16')](this['squeue']['id'],this['realtime'][_0x46fc('0x12')][_0x5baa81],_0x46fc('0x17'));this['realtime'][_0x46fc('0x12')][_0x5baa81][_0x46fc('0x18')]=!![];this[_0x46fc('0x6')][_0x46fc('0x12')][_0x5baa81][_0x46fc('0x19')]=this[_0x46fc('0x5')]['name'];util[_0x46fc('0x1a')](this[_0x46fc('0x3')],this['squeue']['id'],this[_0x46fc('0x6')][_0x46fc('0x12')][_0x5baa81],this['queue'],this[_0x46fc('0x2')]);}}}if(_0xafb8b9){logger[_0x46fc('0x1b')](_0x46fc('0x1c'),this[_0x46fc('0x4')]['id']);setTimeout(this[_0x46fc('0x7')][_0x46fc('0x9')](this),0x3e8);}}else{logger[_0x46fc('0x1b')](_0x46fc('0x1d'),this[_0x46fc('0x4')]['id']);setTimeout(this[_0x46fc('0x7')][_0x46fc('0x9')](this),0x3e8);}};Beepall[_0x46fc('0xd')][_0x46fc('0x8')]=function(_0x1a618c){if(!_[_0x46fc('0xf')](this[_0x46fc('0x5')])&&!_['isNil'](this[_0x46fc('0x5')][_0x46fc('0x10')])){for(var _0x3f00fb=0x0,_0x2c9c1b;_0x3f00fb<this[_0x46fc('0x5')][_0x46fc('0x10')]['length'];_0x3f00fb+=0x1){_0x2c9c1b=this[_0x46fc('0x5')][_0x46fc('0x10')][_0x3f00fb]['id'];if(_[_0x46fc('0xf')](this[_0x46fc('0x6')][_0x46fc('0x12')][_0x2c9c1b])){logger[_0x46fc('0x1b')](_0x46fc('0x13'),this['squeue']['id'],_0x2c9c1b);}else{util['hideNotification'](this[_0x46fc('0x3')],this[_0x46fc('0x4')]['id'],this[_0x46fc('0x6')][_0x46fc('0x12')][_0x2c9c1b],this['queue'],this[_0x46fc('0x2')]);util[_0x46fc('0x16')](this[_0x46fc('0x4')]['id'],this[_0x46fc('0x6')][_0x46fc('0x12')][_0x2c9c1b],_0x1a618c?_0x46fc('0x1e'):_0x46fc('0x1f'));this[_0x46fc('0x6')][_0x46fc('0x12')][_0x2c9c1b][_0x46fc('0x18')]=![];this['realtime'][_0x46fc('0x12')][_0x2c9c1b][_0x46fc('0x19')]=undefined;}}}if(!_0x1a618c){setTimeout(this[_0x46fc('0x7')][_0x46fc('0x9')](this),0x3e8);}};function beepall(_0x453eea,_0xa85ff6,_0x5bc0e4,_0x208203){return new Beepall(_0x453eea,_0xa85ff6,_0x5bc0e4,_0x208203);}module[_0x46fc('0x20')]=beepall;