dd142325c471d7749f17e344420274c5eaf9b9e2
[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 _0xc5f6=['push','handleDrained','isNil','Agents','length','realtime','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','STOP','exports','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','handleRun','bind','handleTimeout','timeout','drained','prototype'];(function(_0x2ea042,_0x1168e3){var _0x21e517=function(_0x575b30){while(--_0x575b30){_0x2ea042['push'](_0x2ea042['shift']());}};_0x21e517(++_0x1168e3);}(_0xc5f6,0x13d));var _0x6c5f=function(_0x78d7c8,_0x58b406){_0x78d7c8=_0x78d7c8-0x0;var _0x46cd3f=_0xc5f6[_0x78d7c8];return _0x46cd3f;};'use strict';var _=require('lodash');var uuid=require(_0x6c5f('0x0'));var util=require(_0x6c5f('0x1'));var logger=require(_0x6c5f('0x2'))(_0x6c5f('0x3'));var Beepall=function(_0xbfb4fa,_0x58cbfe,_0xfe9914,_0x4fec8f){this[_0x6c5f('0x4')]=uuid['v4']();this[_0x6c5f('0x5')]=_0xbfb4fa;this[_0x6c5f('0x6')]=_0x58cbfe;this['realtime']=_0xfe9914;this[_0x6c5f('0x3')]=_0x4fec8f;this[_0x6c5f('0x5')]['push'](this[_0x6c5f('0x7')][_0x6c5f('0x8')](this),this[_0x6c5f('0x9')][_0x6c5f('0x8')](this));this[_0x6c5f('0x5')]['on'](_0x6c5f('0xa'),this[_0x6c5f('0x9')][_0x6c5f('0x8')](this));this[_0x6c5f('0x5')]['on'](_0x6c5f('0xb'),this['handleDrained'][_0x6c5f('0x8')](this));};Beepall[_0x6c5f('0xc')]['push']=function(){this[_0x6c5f('0x5')][_0x6c5f('0xd')](this[_0x6c5f('0x7')][_0x6c5f('0x8')](this),this[_0x6c5f('0x9')][_0x6c5f('0x8')](this));};Beepall[_0x6c5f('0xc')][_0x6c5f('0xe')]=function(_0x2d0df2){this[_0x6c5f('0x9')](!![]);};Beepall[_0x6c5f('0xc')][_0x6c5f('0x7')]=function(_0x52cab9){var _0x131266=!![];if(!_[_0x6c5f('0xf')](this[_0x6c5f('0x6')])&&!_[_0x6c5f('0xf')](this[_0x6c5f('0x6')][_0x6c5f('0x10')])&&this[_0x6c5f('0x6')][_0x6c5f('0x10')][_0x6c5f('0x11')]>0x0){for(var _0x1565a1=0x0,_0x532a8a;_0x1565a1<this[_0x6c5f('0x6')][_0x6c5f('0x10')][_0x6c5f('0x11')];_0x1565a1+=0x1){_0x532a8a=this[_0x6c5f('0x6')][_0x6c5f('0x10')][_0x1565a1]['id'];if(_[_0x6c5f('0xf')](this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x532a8a])){logger['info'](_0x6c5f('0x14'),this['squeue']['id'],_0x532a8a);}else{if(util[_0x6c5f('0x15')](this[_0x6c5f('0x5')]['id'],this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x532a8a],this[_0x6c5f('0x5')][_0x6c5f('0x16')],!![])){_0x131266=![];util[_0x6c5f('0x17')](this[_0x6c5f('0x5')]['id'],this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x532a8a],_0x6c5f('0x18'));this[_0x6c5f('0x12')]['agents'][_0x532a8a][_0x6c5f('0x19')]=!![];this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x532a8a][_0x6c5f('0x1a')]=this[_0x6c5f('0x6')][_0x6c5f('0x1b')];util[_0x6c5f('0x1c')](this[_0x6c5f('0x4')],this[_0x6c5f('0x5')]['id'],this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x532a8a],this[_0x6c5f('0x6')],this[_0x6c5f('0x3')]);}}}if(_0x131266){logger['info'](_0x6c5f('0x1d'),this[_0x6c5f('0x5')]['id']);setTimeout(this[_0x6c5f('0xd')][_0x6c5f('0x8')](this),0x3e8);}}else{logger['info'](_0x6c5f('0x1e'),this[_0x6c5f('0x5')]['id']);setTimeout(this['push'][_0x6c5f('0x8')](this),0x3e8);}};Beepall[_0x6c5f('0xc')][_0x6c5f('0x9')]=function(_0x3699e9){if(!_[_0x6c5f('0xf')](this['queue'])&&!_[_0x6c5f('0xf')](this[_0x6c5f('0x6')]['Agents'])){for(var _0x108e9f=0x0,_0x2bd683;_0x108e9f<this[_0x6c5f('0x6')][_0x6c5f('0x10')][_0x6c5f('0x11')];_0x108e9f+=0x1){_0x2bd683=this[_0x6c5f('0x6')][_0x6c5f('0x10')][_0x108e9f]['id'];if(_['isNil'](this['realtime'][_0x6c5f('0x13')][_0x2bd683])){logger['info'](_0x6c5f('0x14'),this[_0x6c5f('0x5')]['id'],_0x2bd683);}else{util['hideNotification'](this['notificationId'],this['squeue']['id'],this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x2bd683],this[_0x6c5f('0x6')],this[_0x6c5f('0x3')]);util[_0x6c5f('0x17')](this['squeue']['id'],this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x2bd683],_0x3699e9?_0x6c5f('0x1f'):'TIMEOUT');this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x2bd683][_0x6c5f('0x19')]=![];this[_0x6c5f('0x12')][_0x6c5f('0x13')][_0x2bd683][_0x6c5f('0x1a')]=undefined;}}}if(!_0x3699e9){setTimeout(this[_0x6c5f('0xd')][_0x6c5f('0x8')](this),0x3e8);}};function beepall(_0x1c1409,_0x32a220,_0x406854,_0x31986b){return new Beepall(_0x1c1409,_0x32a220,_0x406854,_0x31986b);}module[_0x6c5f('0x20')]=beepall;