Built motion from commit e02f907f.|2.6.14
[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 _0x062a=['showNotification','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','TIMEOUT','removeWaitingNotification','lodash','uuid','../../../../../config/logger','routing','queue','realtime','handleRun','bind','squeue','handleDrained','prototype','push','handleTimeout','isNil','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','name'];(function(_0x22aab7,_0x368f0f){var _0x42f7ea=function(_0x167a84){while(--_0x167a84){_0x22aab7['push'](_0x22aab7['shift']());}};_0x42f7ea(++_0x368f0f);}(_0x062a,0x106));var _0xa062=function(_0x3a331e,_0x7db48b){_0x3a331e=_0x3a331e-0x0;var _0x2684a6=_0x062a[_0x3a331e];return _0x2684a6;};'use strict';var _=require(_0xa062('0x0'));var uuid=require(_0xa062('0x1'));var util=require('./util');var logger=require(_0xa062('0x2'))(_0xa062('0x3'));var Beepall=function(_0xc86ebe,_0x507138,_0x4ba9ab,_0x256b48){this['notificationId']=uuid['v4']();this['squeue']=_0xc86ebe;this[_0xa062('0x4')]=_0x507138;this[_0xa062('0x5')]=_0x4ba9ab;this[_0xa062('0x3')]=_0x256b48;this['squeue']['push'](this[_0xa062('0x6')][_0xa062('0x7')](this),this['handleTimeout'][_0xa062('0x7')](this));this['squeue']['on']('timeout',this['handleTimeout'][_0xa062('0x7')](this));this[_0xa062('0x8')]['on']('drained',this[_0xa062('0x9')][_0xa062('0x7')](this));};Beepall[_0xa062('0xa')][_0xa062('0xb')]=function(){this[_0xa062('0x8')][_0xa062('0xb')](this[_0xa062('0x6')][_0xa062('0x7')](this),this[_0xa062('0xc')]['bind'](this));};Beepall[_0xa062('0xa')][_0xa062('0x9')]=function(){this[_0xa062('0xc')](!![]);};Beepall[_0xa062('0xa')][_0xa062('0x6')]=function(){var _0x425e62=!![];if(!_[_0xa062('0xd')](this[_0xa062('0x4')])&&!_[_0xa062('0xd')](this['queue'][_0xa062('0xe')])&&this['queue']['Agents']['length']>0x0){for(var _0x4440af=0x0,_0x5ecbc7;_0x4440af<this[_0xa062('0x4')][_0xa062('0xe')][_0xa062('0xf')];_0x4440af+=0x1){_0x5ecbc7=this[_0xa062('0x4')][_0xa062('0xe')][_0x4440af]['id'];if(_[_0xa062('0xd')](this[_0xa062('0x5')][_0xa062('0x10')][_0x5ecbc7])){logger[_0xa062('0x11')](_0xa062('0x12'),this[_0xa062('0x8')]['id'],_0x5ecbc7);}else{if(util[_0xa062('0x13')](this[_0xa062('0x8')]['id'],this[_0xa062('0x5')][_0xa062('0x10')][_0x5ecbc7],this[_0xa062('0x8')][_0xa062('0x14')],!![])){_0x425e62=![];util[_0xa062('0x15')](this[_0xa062('0x8')]['id'],this[_0xa062('0x5')][_0xa062('0x10')][_0x5ecbc7],_0xa062('0x16'));this[_0xa062('0x5')][_0xa062('0x10')][_0x5ecbc7][_0xa062('0x17')]=!![];this[_0xa062('0x5')]['agents'][_0x5ecbc7][_0xa062('0x18')]=this[_0xa062('0x4')][_0xa062('0x19')];util['saveWaitingNotification'](this[_0xa062('0x5')],this['routing'],this[_0xa062('0x4')][_0xa062('0xe')][_0x4440af],this[_0xa062('0x8')][_0xa062('0x14')]);util[_0xa062('0x1a')](this[_0xa062('0x1b')],this['squeue']['id'],this['realtime']['agents'][_0x5ecbc7],this[_0xa062('0x4')],this[_0xa062('0x3')]);}}}if(_0x425e62){logger[_0xa062('0x11')](_0xa062('0x1c'),this['squeue']['id']);setTimeout(this[_0xa062('0xb')]['bind'](this),0x3e8);}}else{logger[_0xa062('0x11')](_0xa062('0x1d'),this[_0xa062('0x8')]['id']);setTimeout(this[_0xa062('0xb')][_0xa062('0x7')](this),0x3e8);}};Beepall[_0xa062('0xa')][_0xa062('0xc')]=function(_0x1ce3be){if(!_[_0xa062('0xd')](this[_0xa062('0x4')])&&!_[_0xa062('0xd')](this['queue']['Agents'])){for(var _0x22ead3=0x0,_0x3ceb4a;_0x22ead3<this[_0xa062('0x4')][_0xa062('0xe')][_0xa062('0xf')];_0x22ead3+=0x1){_0x3ceb4a=this[_0xa062('0x4')][_0xa062('0xe')][_0x22ead3]['id'];if(_[_0xa062('0xd')](this[_0xa062('0x5')][_0xa062('0x10')][_0x3ceb4a])){logger['debug'](_0xa062('0x12'),this[_0xa062('0x8')]['id'],_0x3ceb4a);}else{util['hideNotification'](this[_0xa062('0x1b')],this[_0xa062('0x8')]['id'],this[_0xa062('0x5')][_0xa062('0x10')][_0x3ceb4a],this['queue'],this['routing']);util[_0xa062('0x15')](this['squeue']['id'],this[_0xa062('0x5')][_0xa062('0x10')][_0x3ceb4a],_0x1ce3be?'STOP':_0xa062('0x1e'));this[_0xa062('0x5')][_0xa062('0x10')][_0x3ceb4a][_0xa062('0x17')]=![];this[_0xa062('0x5')][_0xa062('0x10')][_0x3ceb4a][_0xa062('0x18')]=undefined;util[_0xa062('0x1f')](this[_0xa062('0x5')],this[_0xa062('0x3')],this[_0xa062('0x5')]['agents'][_0x3ceb4a],this['squeue'][_0xa062('0x14')]);}}}if(!_0x1ce3be){setTimeout(this[_0xa062('0xb')][_0xa062('0x7')](this),0x3e8);}};function beepall(_0x1d4542,_0x3e7147,_0x30e3c1,_0x417201){return new Beepall(_0x1d4542,_0x3e7147,_0x30e3c1,_0x417201);}module['exports']=beepall;