Built motion from commit 3c2ce842.|2.6.31
[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 _0x0150=['Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','RINGING','busy','busyQueue','name','saveWaitingNotification','showNotification','[%s][QUEUE]\x20EMPTY','STOP','TIMEOUT','lodash','uuid','./util','routing','squeue','queue','realtime','bind','handleTimeout','drained','push','handleRun','prototype','isNil'];(function(_0x21481c,_0x1b51ba){var _0x5dd77a=function(_0x4ee13c){while(--_0x4ee13c){_0x21481c['push'](_0x21481c['shift']());}};_0x5dd77a(++_0x1b51ba);}(_0x0150,0x16b));var _0x0015=function(_0x561c13,_0x58b172){_0x561c13=_0x561c13-0x0;var _0x3ed4dd=_0x0150[_0x561c13];return _0x3ed4dd;};'use strict';var _=require(_0x0015('0x0'));var uuid=require(_0x0015('0x1'));var util=require(_0x0015('0x2'));var logger=require('../../../../../config/logger')(_0x0015('0x3'));var Beepall=function(_0xd3aa30,_0x1ea2a8,_0x10a483,_0x3594d0){this['notificationId']=uuid['v4']();this[_0x0015('0x4')]=_0xd3aa30;this[_0x0015('0x5')]=_0x1ea2a8;this[_0x0015('0x6')]=_0x10a483;this[_0x0015('0x3')]=_0x3594d0;this[_0x0015('0x4')]['push'](this['handleRun'][_0x0015('0x7')](this),this[_0x0015('0x8')]['bind'](this));this[_0x0015('0x4')]['on']('timeout',this[_0x0015('0x8')][_0x0015('0x7')](this));this['squeue']['on'](_0x0015('0x9'),this['handleDrained'][_0x0015('0x7')](this));};Beepall['prototype'][_0x0015('0xa')]=function(){this['squeue'][_0x0015('0xa')](this[_0x0015('0xb')][_0x0015('0x7')](this),this[_0x0015('0x8')]['bind'](this));};Beepall['prototype']['handleDrained']=function(){this[_0x0015('0x8')](!![]);};Beepall[_0x0015('0xc')][_0x0015('0xb')]=function(){var _0x1bd397=!![];if(!_[_0x0015('0xd')](this[_0x0015('0x5')])&&!_['isNil'](this[_0x0015('0x5')]['Agents'])&&this['queue'][_0x0015('0xe')][_0x0015('0xf')]>0x0){for(var _0x4b8846=0x0,_0x1cb288;_0x4b8846<this['queue'][_0x0015('0xe')][_0x0015('0xf')];_0x4b8846+=0x1){_0x1cb288=this[_0x0015('0x5')][_0x0015('0xe')][_0x4b8846]['id'];if(_[_0x0015('0xd')](this[_0x0015('0x6')][_0x0015('0x10')][_0x1cb288])){logger[_0x0015('0x11')](_0x0015('0x12'),this[_0x0015('0x4')]['id'],_0x1cb288);}else{if(util[_0x0015('0x13')](this[_0x0015('0x4')]['id'],this[_0x0015('0x6')]['agents'][_0x1cb288],this[_0x0015('0x4')]['channel'],!![])){_0x1bd397=![];util['writeLog'](this['squeue']['id'],this['realtime'][_0x0015('0x10')][_0x1cb288],_0x0015('0x14'));this['realtime']['agents'][_0x1cb288][_0x0015('0x15')]=!![];this[_0x0015('0x6')]['agents'][_0x1cb288][_0x0015('0x16')]=this[_0x0015('0x5')][_0x0015('0x17')];util[_0x0015('0x18')](this['realtime'],this[_0x0015('0x3')],this['queue'][_0x0015('0xe')][_0x4b8846],this[_0x0015('0x4')]['channel']);util[_0x0015('0x19')](this['notificationId'],this[_0x0015('0x4')]['id'],this[_0x0015('0x6')]['agents'][_0x1cb288],this[_0x0015('0x5')],this[_0x0015('0x3')]);}}}if(_0x1bd397){logger[_0x0015('0x11')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0x0015('0x4')]['id']);setTimeout(this[_0x0015('0xa')][_0x0015('0x7')](this),0x3e8);}}else{logger['debug'](_0x0015('0x1a'),this['squeue']['id']);setTimeout(this['push'][_0x0015('0x7')](this),0x3e8);}};Beepall[_0x0015('0xc')][_0x0015('0x8')]=function(_0x55984){if(!_[_0x0015('0xd')](this[_0x0015('0x5')])&&!_[_0x0015('0xd')](this[_0x0015('0x5')][_0x0015('0xe')])){for(var _0x465850=0x0,_0x46d739;_0x465850<this[_0x0015('0x5')]['Agents'][_0x0015('0xf')];_0x465850+=0x1){_0x46d739=this[_0x0015('0x5')][_0x0015('0xe')][_0x465850]['id'];if(_[_0x0015('0xd')](this[_0x0015('0x6')][_0x0015('0x10')][_0x46d739])){logger[_0x0015('0x11')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x0015('0x4')]['id'],_0x46d739);}else{util['hideNotification'](this['notificationId'],this['squeue']['id'],this['realtime'][_0x0015('0x10')][_0x46d739],this[_0x0015('0x5')],this[_0x0015('0x3')]);util['writeLog'](this['squeue']['id'],this[_0x0015('0x6')][_0x0015('0x10')][_0x46d739],_0x55984?_0x0015('0x1b'):_0x0015('0x1c'));this[_0x0015('0x6')][_0x0015('0x10')][_0x46d739]['busy']=![];this[_0x0015('0x6')][_0x0015('0x10')][_0x46d739][_0x0015('0x16')]=undefined;util['removeWaitingNotification'](this[_0x0015('0x6')],this['routing'],this['realtime'][_0x0015('0x10')][_0x46d739],this[_0x0015('0x4')]['channel']);}}}if(!_0x55984){setTimeout(this[_0x0015('0xa')]['bind'](this),0x3e8);}};function beepall(_0x1d4966,_0xad9a1f,_0x2b835d,_0x5e777e){return new Beepall(_0x1d4966,_0xad9a1f,_0x2b835d,_0x5e777e);}module['exports']=beepall;