6562c54088b7d3dc4fdacab7793c4b9b755303e1
[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 _0x7268=['busy','busyQueue','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','hideNotification','TIMEOUT','exports','lodash','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind','handleTimeout','timeout','drained','handleDrained','isNil','Agents','length','info','isAgentAvailable','agents','channel','writeLog','RINGING'];(function(_0xc1bff7,_0x5d17cc){var _0x4c9cc7=function(_0x2a5f80){while(--_0x2a5f80){_0xc1bff7['push'](_0xc1bff7['shift']());}};_0x4c9cc7(++_0x5d17cc);}(_0x7268,0x1a2));var _0x8726=function(_0xb0acb,_0x322550){_0xb0acb=_0xb0acb-0x0;var _0x3ec04f=_0x7268[_0xb0acb];return _0x3ec04f;};'use strict';var _=require(_0x8726('0x0'));var uuid=require('uuid');var util=require(_0x8726('0x1'));var logger=require(_0x8726('0x2'))(_0x8726('0x3'));var Beepall=function(_0x4cb4e0,_0x558ca8,_0x3df7ec,_0x384868){this[_0x8726('0x4')]=uuid['v4']();this[_0x8726('0x5')]=_0x4cb4e0;this[_0x8726('0x6')]=_0x558ca8;this[_0x8726('0x7')]=_0x3df7ec;this[_0x8726('0x3')]=_0x384868;this[_0x8726('0x5')][_0x8726('0x8')](this[_0x8726('0x9')][_0x8726('0xa')](this),this[_0x8726('0xb')][_0x8726('0xa')](this));this[_0x8726('0x5')]['on'](_0x8726('0xc'),this[_0x8726('0xb')][_0x8726('0xa')](this));this[_0x8726('0x5')]['on'](_0x8726('0xd'),this['handleDrained'][_0x8726('0xa')](this));};Beepall['prototype'][_0x8726('0x8')]=function(){this['squeue'][_0x8726('0x8')](this[_0x8726('0x9')][_0x8726('0xa')](this),this[_0x8726('0xb')]['bind'](this));};Beepall['prototype'][_0x8726('0xe')]=function(_0x2c08d8){this[_0x8726('0xb')](!![]);};Beepall['prototype']['handleRun']=function(_0x50a3c3){var _0x11cf2d=!![];if(!_[_0x8726('0xf')](this[_0x8726('0x6')])&&!_['isNil'](this[_0x8726('0x6')][_0x8726('0x10')])&&this[_0x8726('0x6')][_0x8726('0x10')]['length']>0x0){for(var _0x148d8a=0x0,_0x21c4c5;_0x148d8a<this[_0x8726('0x6')][_0x8726('0x10')][_0x8726('0x11')];_0x148d8a+=0x1){_0x21c4c5=this['queue'][_0x8726('0x10')][_0x148d8a]['id'];if(_[_0x8726('0xf')](this[_0x8726('0x7')]['agents'][_0x21c4c5])){logger[_0x8726('0x12')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8726('0x5')]['id'],_0x21c4c5);}else{if(util[_0x8726('0x13')](this['squeue']['id'],this[_0x8726('0x7')][_0x8726('0x14')][_0x21c4c5],this[_0x8726('0x5')][_0x8726('0x15')],!![])){_0x11cf2d=![];util[_0x8726('0x16')](this[_0x8726('0x5')]['id'],this[_0x8726('0x7')][_0x8726('0x14')][_0x21c4c5],_0x8726('0x17'));this['realtime'][_0x8726('0x14')][_0x21c4c5][_0x8726('0x18')]=!![];this[_0x8726('0x7')]['agents'][_0x21c4c5][_0x8726('0x19')]=this[_0x8726('0x6')][_0x8726('0x1a')];util[_0x8726('0x1b')](this[_0x8726('0x4')],this[_0x8726('0x5')]['id'],this[_0x8726('0x7')][_0x8726('0x14')][_0x21c4c5],this['queue'],this['routing']);}}}if(_0x11cf2d){logger[_0x8726('0x12')](_0x8726('0x1c'),this[_0x8726('0x5')]['id']);setTimeout(this[_0x8726('0x8')][_0x8726('0xa')](this),0x3e8);}}else{logger['info'](_0x8726('0x1d'),this[_0x8726('0x5')]['id']);setTimeout(this[_0x8726('0x8')][_0x8726('0xa')](this),0x3e8);}};Beepall['prototype'][_0x8726('0xb')]=function(_0x8757cf){if(!_[_0x8726('0xf')](this[_0x8726('0x6')])&&!_[_0x8726('0xf')](this[_0x8726('0x6')]['Agents'])){for(var _0x2f8339=0x0,_0x1844cb;_0x2f8339<this[_0x8726('0x6')]['Agents'][_0x8726('0x11')];_0x2f8339+=0x1){_0x1844cb=this['queue'][_0x8726('0x10')][_0x2f8339]['id'];if(_['isNil'](this['realtime'][_0x8726('0x14')][_0x1844cb])){logger['info'](_0x8726('0x1e'),this[_0x8726('0x5')]['id'],_0x1844cb);}else{util[_0x8726('0x1f')](this['notificationId'],this[_0x8726('0x5')]['id'],this[_0x8726('0x7')][_0x8726('0x14')][_0x1844cb],this[_0x8726('0x6')],this[_0x8726('0x3')]);util[_0x8726('0x16')](this[_0x8726('0x5')]['id'],this[_0x8726('0x7')][_0x8726('0x14')][_0x1844cb],_0x8757cf?'STOP':_0x8726('0x20'));this['realtime'][_0x8726('0x14')][_0x1844cb]['busy']=![];this[_0x8726('0x7')][_0x8726('0x14')][_0x1844cb][_0x8726('0x19')]=undefined;}}}if(!_0x8757cf){setTimeout(this[_0x8726('0x8')][_0x8726('0xa')](this),0x3e8);}};function beepall(_0x4b229a,_0x35ec94,_0x3407ae,_0x4957dc){return new Beepall(_0x4b229a,_0x35ec94,_0x3407ae,_0x4957dc);}module[_0x8726('0x21')]=beepall;