Built motion from commit c738b9ac.|2.6.25
[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 _0xcf38=['notificationId','squeue','queue','routing','push','handleRun','handleTimeout','bind','timeout','drained','handleDrained','prototype','isNil','Agents','length','realtime','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','writeLog','RINGING','busy','name','saveWaitingNotification','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','hideNotification','STOP','TIMEOUT','busyQueue','uuid','../../../../../config/logger'];(function(_0xd95342,_0xb75bf6){var _0x54d694=function(_0x1190c1){while(--_0x1190c1){_0xd95342['push'](_0xd95342['shift']());}};_0x54d694(++_0xb75bf6);}(_0xcf38,0x169));var _0x8cf3=function(_0x17b2ab,_0x43a8dd){_0x17b2ab=_0x17b2ab-0x0;var _0x242a20=_0xcf38[_0x17b2ab];return _0x242a20;};'use strict';var _=require('lodash');var uuid=require(_0x8cf3('0x0'));var util=require('./util');var logger=require(_0x8cf3('0x1'))('routing');var Beepall=function(_0x2f8723,_0x4a4d4b,_0x209ddd,_0x49ae89){this[_0x8cf3('0x2')]=uuid['v4']();this[_0x8cf3('0x3')]=_0x2f8723;this[_0x8cf3('0x4')]=_0x4a4d4b;this['realtime']=_0x209ddd;this[_0x8cf3('0x5')]=_0x49ae89;this[_0x8cf3('0x3')][_0x8cf3('0x6')](this[_0x8cf3('0x7')]['bind'](this),this[_0x8cf3('0x8')][_0x8cf3('0x9')](this));this[_0x8cf3('0x3')]['on'](_0x8cf3('0xa'),this['handleTimeout'][_0x8cf3('0x9')](this));this['squeue']['on'](_0x8cf3('0xb'),this[_0x8cf3('0xc')]['bind'](this));};Beepall['prototype'][_0x8cf3('0x6')]=function(){this[_0x8cf3('0x3')][_0x8cf3('0x6')](this[_0x8cf3('0x7')]['bind'](this),this[_0x8cf3('0x8')]['bind'](this));};Beepall[_0x8cf3('0xd')][_0x8cf3('0xc')]=function(){this[_0x8cf3('0x8')](!![]);};Beepall[_0x8cf3('0xd')][_0x8cf3('0x7')]=function(){var _0x34580a=!![];if(!_[_0x8cf3('0xe')](this[_0x8cf3('0x4')])&&!_[_0x8cf3('0xe')](this['queue'][_0x8cf3('0xf')])&&this[_0x8cf3('0x4')]['Agents'][_0x8cf3('0x10')]>0x0){for(var _0x55333f=0x0,_0x4f7215;_0x55333f<this['queue'][_0x8cf3('0xf')][_0x8cf3('0x10')];_0x55333f+=0x1){_0x4f7215=this[_0x8cf3('0x4')][_0x8cf3('0xf')][_0x55333f]['id'];if(_[_0x8cf3('0xe')](this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x4f7215])){logger[_0x8cf3('0x13')](_0x8cf3('0x14'),this['squeue']['id'],_0x4f7215);}else{if(util['isAgentAvailable'](this[_0x8cf3('0x3')]['id'],this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x4f7215],this[_0x8cf3('0x3')][_0x8cf3('0x15')],!![])){_0x34580a=![];util[_0x8cf3('0x16')](this[_0x8cf3('0x3')]['id'],this['realtime'][_0x8cf3('0x12')][_0x4f7215],_0x8cf3('0x17'));this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x4f7215][_0x8cf3('0x18')]=!![];this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x4f7215]['busyQueue']=this['queue'][_0x8cf3('0x19')];util[_0x8cf3('0x1a')](this[_0x8cf3('0x11')],this[_0x8cf3('0x5')],this[_0x8cf3('0x4')][_0x8cf3('0xf')][_0x55333f],this[_0x8cf3('0x3')][_0x8cf3('0x15')]);util[_0x8cf3('0x1b')](this[_0x8cf3('0x2')],this[_0x8cf3('0x3')]['id'],this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x4f7215],this[_0x8cf3('0x4')],this[_0x8cf3('0x5')]);}}}if(_0x34580a){logger[_0x8cf3('0x13')](_0x8cf3('0x1c'),this['squeue']['id']);setTimeout(this[_0x8cf3('0x6')][_0x8cf3('0x9')](this),0x3e8);}}else{logger[_0x8cf3('0x13')]('[%s][QUEUE]\x20EMPTY',this[_0x8cf3('0x3')]['id']);setTimeout(this[_0x8cf3('0x6')][_0x8cf3('0x9')](this),0x3e8);}};Beepall[_0x8cf3('0xd')][_0x8cf3('0x8')]=function(_0x5aaf0a){if(!_[_0x8cf3('0xe')](this['queue'])&&!_[_0x8cf3('0xe')](this[_0x8cf3('0x4')][_0x8cf3('0xf')])){for(var _0x227901=0x0,_0x17c07e;_0x227901<this['queue'][_0x8cf3('0xf')][_0x8cf3('0x10')];_0x227901+=0x1){_0x17c07e=this[_0x8cf3('0x4')][_0x8cf3('0xf')][_0x227901]['id'];if(_[_0x8cf3('0xe')](this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x17c07e])){logger[_0x8cf3('0x13')](_0x8cf3('0x14'),this[_0x8cf3('0x3')]['id'],_0x17c07e);}else{util[_0x8cf3('0x1d')](this[_0x8cf3('0x2')],this[_0x8cf3('0x3')]['id'],this['realtime']['agents'][_0x17c07e],this[_0x8cf3('0x4')],this[_0x8cf3('0x5')]);util[_0x8cf3('0x16')](this[_0x8cf3('0x3')]['id'],this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x17c07e],_0x5aaf0a?_0x8cf3('0x1e'):_0x8cf3('0x1f'));this['realtime'][_0x8cf3('0x12')][_0x17c07e][_0x8cf3('0x18')]=![];this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x17c07e][_0x8cf3('0x20')]=undefined;util['removeWaitingNotification'](this[_0x8cf3('0x11')],this['routing'],this[_0x8cf3('0x11')][_0x8cf3('0x12')][_0x17c07e],this[_0x8cf3('0x3')][_0x8cf3('0x15')]);}}}if(!_0x5aaf0a){setTimeout(this[_0x8cf3('0x6')][_0x8cf3('0x9')](this),0x3e8);}};function beepall(_0x508814,_0x7ea748,_0x1289ab,_0x3bd2f0){return new Beepall(_0x508814,_0x7ea748,_0x1289ab,_0x3bd2f0);}module['exports']=beepall;