Built motion from commit (unavailable).|2.2.0
[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 _0x431f=['notificationId','squeue','queue','realtime','handleRun','bind','handleTimeout','drained','handleDrained','prototype','push','isNil','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','RINGING','busy','busyQueue','name','showNotification','[%s][QUEUE]\x20EMPTY','TIMEOUT','exports','uuid','./util','../../../../../config/logger','routing'];(function(_0x28286e,_0xd8c672){var _0x3a253e=function(_0x1830e7){while(--_0x1830e7){_0x28286e['push'](_0x28286e['shift']());}};_0x3a253e(++_0xd8c672);}(_0x431f,0x97));var _0xf431=function(_0x582a5a,_0x344db6){_0x582a5a=_0x582a5a-0x0;var _0x30f7e7=_0x431f[_0x582a5a];return _0x30f7e7;};'use strict';var _=require('lodash');var uuid=require(_0xf431('0x0'));var util=require(_0xf431('0x1'));var logger=require(_0xf431('0x2'))(_0xf431('0x3'));var Beepall=function(_0x59f8e3,_0x45b632,_0x451dfa,_0x14f26b){this[_0xf431('0x4')]=uuid['v4']();this[_0xf431('0x5')]=_0x59f8e3;this[_0xf431('0x6')]=_0x45b632;this[_0xf431('0x7')]=_0x451dfa;this[_0xf431('0x3')]=_0x14f26b;this[_0xf431('0x5')]['push'](this[_0xf431('0x8')][_0xf431('0x9')](this),this[_0xf431('0xa')]['bind'](this));this[_0xf431('0x5')]['on']('timeout',this[_0xf431('0xa')][_0xf431('0x9')](this));this[_0xf431('0x5')]['on'](_0xf431('0xb'),this[_0xf431('0xc')][_0xf431('0x9')](this));};Beepall[_0xf431('0xd')][_0xf431('0xe')]=function(){this[_0xf431('0x5')]['push'](this['handleRun'][_0xf431('0x9')](this),this[_0xf431('0xa')][_0xf431('0x9')](this));};Beepall['prototype'][_0xf431('0xc')]=function(_0x4ed583){this['handleTimeout'](!![]);};Beepall[_0xf431('0xd')][_0xf431('0x8')]=function(_0x54008b){var _0x175345=!![];if(!_['isNil'](this[_0xf431('0x6')])&&!_[_0xf431('0xf')](this[_0xf431('0x6')]['Agents'])&&this[_0xf431('0x6')][_0xf431('0x10')][_0xf431('0x11')]>0x0){for(var _0x34f96b=0x0,_0x31c561;_0x34f96b<this[_0xf431('0x6')][_0xf431('0x10')]['length'];_0x34f96b+=0x1){_0x31c561=this[_0xf431('0x6')]['Agents'][_0x34f96b]['id'];if(_[_0xf431('0xf')](this['realtime'][_0xf431('0x12')][_0x31c561])){logger[_0xf431('0x13')](_0xf431('0x14'),this['squeue']['id'],_0x31c561);}else{if(util[_0xf431('0x15')](this[_0xf431('0x5')]['id'],this['realtime'][_0xf431('0x12')][_0x31c561],this[_0xf431('0x5')]['channel'],!![])){_0x175345=![];util[_0xf431('0x16')](this[_0xf431('0x5')]['id'],this[_0xf431('0x7')][_0xf431('0x12')][_0x31c561],_0xf431('0x17'));this[_0xf431('0x7')][_0xf431('0x12')][_0x31c561][_0xf431('0x18')]=!![];this[_0xf431('0x7')]['agents'][_0x31c561][_0xf431('0x19')]=this[_0xf431('0x6')][_0xf431('0x1a')];util[_0xf431('0x1b')](this[_0xf431('0x4')],this['squeue']['id'],this[_0xf431('0x7')][_0xf431('0x12')][_0x31c561],this[_0xf431('0x6')],this['routing']);}}}if(_0x175345){logger[_0xf431('0x13')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this['squeue']['id']);setTimeout(this[_0xf431('0xe')][_0xf431('0x9')](this),0x3e8);}}else{logger['info'](_0xf431('0x1c'),this[_0xf431('0x5')]['id']);setTimeout(this[_0xf431('0xe')]['bind'](this),0x3e8);}};Beepall[_0xf431('0xd')][_0xf431('0xa')]=function(_0x2b5539){if(!_['isNil'](this[_0xf431('0x6')])&&!_[_0xf431('0xf')](this[_0xf431('0x6')][_0xf431('0x10')])){for(var _0x25c131=0x0,_0x429733;_0x25c131<this[_0xf431('0x6')][_0xf431('0x10')][_0xf431('0x11')];_0x25c131+=0x1){_0x429733=this[_0xf431('0x6')][_0xf431('0x10')][_0x25c131]['id'];if(_[_0xf431('0xf')](this[_0xf431('0x7')][_0xf431('0x12')][_0x429733])){logger[_0xf431('0x13')](_0xf431('0x14'),this[_0xf431('0x5')]['id'],_0x429733);}else{util['hideNotification'](this['notificationId'],this[_0xf431('0x5')]['id'],this['realtime']['agents'][_0x429733],this['queue'],this[_0xf431('0x3')]);util[_0xf431('0x16')](this[_0xf431('0x5')]['id'],this['realtime'][_0xf431('0x12')][_0x429733],_0x2b5539?'STOP':_0xf431('0x1d'));this[_0xf431('0x7')][_0xf431('0x12')][_0x429733][_0xf431('0x18')]=![];this[_0xf431('0x7')]['agents'][_0x429733]['busyQueue']=undefined;}}}if(!_0x2b5539){setTimeout(this[_0xf431('0xe')][_0xf431('0x9')](this),0x3e8);}};function beepall(_0x2fcc12,_0x3f561f,_0x287034,_0x205a7c){return new Beepall(_0x2fcc12,_0x3f561f,_0x287034,_0x205a7c);}module[_0xf431('0x1e')]=beepall;