6be1a337eb79bb8e752187ee1b9dbc4e595516fc
[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 _0xc4f0=['hideNotification','notificationId','STOP','TIMEOUT','./util','routing','squeue','queue','realtime','push','handleRun','handleTimeout','timeout','bind','drained','handleDrained','prototype','isNil','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busy','busyQueue','name','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY'];(function(_0x5dad62,_0x4470c5){var _0x1a6890=function(_0x59fac5){while(--_0x59fac5){_0x5dad62['push'](_0x5dad62['shift']());}};_0x1a6890(++_0x4470c5);}(_0xc4f0,0x164));var _0x0c4f=function(_0x1df5a5,_0x5aa8b4){_0x1df5a5=_0x1df5a5-0x0;var _0x20aea4=_0xc4f0[_0x1df5a5];return _0x20aea4;};'use strict';var _=require('lodash');var uuid=require('uuid');var util=require(_0x0c4f('0x0'));var logger=require('../../../../../config/logger')(_0x0c4f('0x1'));var Beepall=function(_0x2ee6e6,_0x36d035,_0x1bc9a6,_0x3cf817){this['notificationId']=uuid['v4']();this[_0x0c4f('0x2')]=_0x2ee6e6;this[_0x0c4f('0x3')]=_0x36d035;this[_0x0c4f('0x4')]=_0x1bc9a6;this[_0x0c4f('0x1')]=_0x3cf817;this[_0x0c4f('0x2')][_0x0c4f('0x5')](this[_0x0c4f('0x6')]['bind'](this),this[_0x0c4f('0x7')]['bind'](this));this[_0x0c4f('0x2')]['on'](_0x0c4f('0x8'),this['handleTimeout'][_0x0c4f('0x9')](this));this[_0x0c4f('0x2')]['on'](_0x0c4f('0xa'),this[_0x0c4f('0xb')][_0x0c4f('0x9')](this));};Beepall[_0x0c4f('0xc')]['push']=function(){this[_0x0c4f('0x2')]['push'](this['handleRun'][_0x0c4f('0x9')](this),this[_0x0c4f('0x7')][_0x0c4f('0x9')](this));};Beepall[_0x0c4f('0xc')][_0x0c4f('0xb')]=function(_0x43efb0){this['handleTimeout'](!![]);};Beepall[_0x0c4f('0xc')][_0x0c4f('0x6')]=function(_0x29ab02){var _0x3a118d=!![];if(!_[_0x0c4f('0xd')](this[_0x0c4f('0x3')])&&!_['isNil'](this['queue'][_0x0c4f('0xe')])&&this['queue'][_0x0c4f('0xe')][_0x0c4f('0xf')]>0x0){for(var _0x11fcf2=0x0,_0x421a19;_0x11fcf2<this[_0x0c4f('0x3')]['Agents'][_0x0c4f('0xf')];_0x11fcf2+=0x1){_0x421a19=this[_0x0c4f('0x3')]['Agents'][_0x11fcf2]['id'];if(_[_0x0c4f('0xd')](this[_0x0c4f('0x4')][_0x0c4f('0x10')][_0x421a19])){logger[_0x0c4f('0x11')](_0x0c4f('0x12'),this[_0x0c4f('0x2')]['id'],_0x421a19);}else{if(util[_0x0c4f('0x13')](this['squeue']['id'],this['realtime'][_0x0c4f('0x10')][_0x421a19],this[_0x0c4f('0x2')][_0x0c4f('0x14')],!![])){_0x3a118d=![];util[_0x0c4f('0x15')](this['squeue']['id'],this[_0x0c4f('0x4')]['agents'][_0x421a19],_0x0c4f('0x16'));this[_0x0c4f('0x4')][_0x0c4f('0x10')][_0x421a19][_0x0c4f('0x17')]=!![];this[_0x0c4f('0x4')][_0x0c4f('0x10')][_0x421a19][_0x0c4f('0x18')]=this[_0x0c4f('0x3')][_0x0c4f('0x19')];util['showNotification'](this['notificationId'],this[_0x0c4f('0x2')]['id'],this['realtime'][_0x0c4f('0x10')][_0x421a19],this[_0x0c4f('0x3')],this['routing']);}}}if(_0x3a118d){logger[_0x0c4f('0x11')](_0x0c4f('0x1a'),this[_0x0c4f('0x2')]['id']);setTimeout(this['push'][_0x0c4f('0x9')](this),0x3e8);}}else{logger[_0x0c4f('0x11')](_0x0c4f('0x1b'),this['squeue']['id']);setTimeout(this[_0x0c4f('0x5')][_0x0c4f('0x9')](this),0x3e8);}};Beepall[_0x0c4f('0xc')][_0x0c4f('0x7')]=function(_0x373f3f){if(!_['isNil'](this['queue'])&&!_[_0x0c4f('0xd')](this[_0x0c4f('0x3')][_0x0c4f('0xe')])){for(var _0xd2585e=0x0,_0x3d1f88;_0xd2585e<this['queue']['Agents']['length'];_0xd2585e+=0x1){_0x3d1f88=this['queue'][_0x0c4f('0xe')][_0xd2585e]['id'];if(_[_0x0c4f('0xd')](this[_0x0c4f('0x4')]['agents'][_0x3d1f88])){logger['info'](_0x0c4f('0x12'),this['squeue']['id'],_0x3d1f88);}else{util[_0x0c4f('0x1c')](this[_0x0c4f('0x1d')],this[_0x0c4f('0x2')]['id'],this[_0x0c4f('0x4')]['agents'][_0x3d1f88],this[_0x0c4f('0x3')],this[_0x0c4f('0x1')]);util[_0x0c4f('0x15')](this[_0x0c4f('0x2')]['id'],this['realtime'][_0x0c4f('0x10')][_0x3d1f88],_0x373f3f?_0x0c4f('0x1e'):_0x0c4f('0x1f'));this[_0x0c4f('0x4')]['agents'][_0x3d1f88][_0x0c4f('0x17')]=![];this['realtime'][_0x0c4f('0x10')][_0x3d1f88][_0x0c4f('0x18')]=undefined;}}}if(!_0x373f3f){setTimeout(this['push'][_0x0c4f('0x9')](this),0x3e8);}};function beepall(_0x5b91f8,_0x3b2510,_0xc8c883,_0x11cf34){return new Beepall(_0x5b91f8,_0x3b2510,_0xc8c883,_0x11cf34);}module['exports']=beepall;