Built motion from commit (unavailable).|2.4.4
[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 _0xcb2c=['[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','agents','channel','writeLog','RINGING','busy','busyQueue','name','showNotification','notificationId','routing','[%s][QUEUE]\x20EMPTY','info','hideNotification','exports','../../../../../config/logger','squeue','queue','realtime','push','bind','handleTimeout','timeout','drained','handleDrained','prototype','handleRun','isNil','Agents','length'];(function(_0x4aa009,_0x30ced4){var _0x2d670f=function(_0xaa5fa6){while(--_0xaa5fa6){_0x4aa009['push'](_0x4aa009['shift']());}};_0x2d670f(++_0x30ced4);}(_0xcb2c,0xca));var _0xccb2=function(_0x47b58b,_0x41a189){_0x47b58b=_0x47b58b-0x0;var _0x46bebe=_0xcb2c[_0x47b58b];return _0x46bebe;};'use strict';var _=require('lodash');var uuid=require('uuid');var util=require('./util');var logger=require(_0xccb2('0x0'))('routing');var Beepall=function(_0x3bec15,_0x9de173,_0x1e23cb,_0x3c3151){this['notificationId']=uuid['v4']();this[_0xccb2('0x1')]=_0x3bec15;this[_0xccb2('0x2')]=_0x9de173;this[_0xccb2('0x3')]=_0x1e23cb;this['routing']=_0x3c3151;this['squeue'][_0xccb2('0x4')](this['handleRun'][_0xccb2('0x5')](this),this[_0xccb2('0x6')][_0xccb2('0x5')](this));this[_0xccb2('0x1')]['on'](_0xccb2('0x7'),this[_0xccb2('0x6')][_0xccb2('0x5')](this));this[_0xccb2('0x1')]['on'](_0xccb2('0x8'),this[_0xccb2('0x9')][_0xccb2('0x5')](this));};Beepall[_0xccb2('0xa')][_0xccb2('0x4')]=function(){this[_0xccb2('0x1')]['push'](this['handleRun'][_0xccb2('0x5')](this),this[_0xccb2('0x6')][_0xccb2('0x5')](this));};Beepall[_0xccb2('0xa')][_0xccb2('0x9')]=function(_0x2c0ce2){this[_0xccb2('0x6')](!![]);};Beepall[_0xccb2('0xa')][_0xccb2('0xb')]=function(_0x4d4e5a){var _0x2e90a8=!![];if(!_[_0xccb2('0xc')](this['queue'])&&!_['isNil'](this[_0xccb2('0x2')][_0xccb2('0xd')])&&this['queue'][_0xccb2('0xd')][_0xccb2('0xe')]>0x0){for(var _0x381df8=0x0,_0x24ef60;_0x381df8<this[_0xccb2('0x2')][_0xccb2('0xd')]['length'];_0x381df8+=0x1){_0x24ef60=this[_0xccb2('0x2')]['Agents'][_0x381df8]['id'];if(_[_0xccb2('0xc')](this['realtime']['agents'][_0x24ef60])){logger['info'](_0xccb2('0xf'),this[_0xccb2('0x1')]['id'],_0x24ef60);}else{if(util[_0xccb2('0x10')](this[_0xccb2('0x1')]['id'],this[_0xccb2('0x3')][_0xccb2('0x11')][_0x24ef60],this[_0xccb2('0x1')][_0xccb2('0x12')],!![])){_0x2e90a8=![];util[_0xccb2('0x13')](this[_0xccb2('0x1')]['id'],this[_0xccb2('0x3')][_0xccb2('0x11')][_0x24ef60],_0xccb2('0x14'));this[_0xccb2('0x3')][_0xccb2('0x11')][_0x24ef60][_0xccb2('0x15')]=!![];this[_0xccb2('0x3')]['agents'][_0x24ef60][_0xccb2('0x16')]=this[_0xccb2('0x2')][_0xccb2('0x17')];util[_0xccb2('0x18')](this[_0xccb2('0x19')],this[_0xccb2('0x1')]['id'],this[_0xccb2('0x3')][_0xccb2('0x11')][_0x24ef60],this[_0xccb2('0x2')],this[_0xccb2('0x1a')]);}}}if(_0x2e90a8){logger['info']('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0xccb2('0x1')]['id']);setTimeout(this[_0xccb2('0x4')]['bind'](this),0x3e8);}}else{logger['info'](_0xccb2('0x1b'),this[_0xccb2('0x1')]['id']);setTimeout(this[_0xccb2('0x4')][_0xccb2('0x5')](this),0x3e8);}};Beepall[_0xccb2('0xa')]['handleTimeout']=function(_0xa69ba){if(!_[_0xccb2('0xc')](this['queue'])&&!_[_0xccb2('0xc')](this[_0xccb2('0x2')][_0xccb2('0xd')])){for(var _0x5f008a=0x0,_0x242b92;_0x5f008a<this[_0xccb2('0x2')]['Agents'][_0xccb2('0xe')];_0x5f008a+=0x1){_0x242b92=this[_0xccb2('0x2')][_0xccb2('0xd')][_0x5f008a]['id'];if(_['isNil'](this[_0xccb2('0x3')][_0xccb2('0x11')][_0x242b92])){logger[_0xccb2('0x1c')](_0xccb2('0xf'),this['squeue']['id'],_0x242b92);}else{util[_0xccb2('0x1d')](this[_0xccb2('0x19')],this['squeue']['id'],this[_0xccb2('0x3')][_0xccb2('0x11')][_0x242b92],this[_0xccb2('0x2')],this[_0xccb2('0x1a')]);util[_0xccb2('0x13')](this[_0xccb2('0x1')]['id'],this[_0xccb2('0x3')][_0xccb2('0x11')][_0x242b92],_0xa69ba?'STOP':'TIMEOUT');this[_0xccb2('0x3')]['agents'][_0x242b92][_0xccb2('0x15')]=![];this[_0xccb2('0x3')][_0xccb2('0x11')][_0x242b92][_0xccb2('0x16')]=undefined;}}}if(!_0xa69ba){setTimeout(this['push']['bind'](this),0x3e8);}};function beepall(_0x24810f,_0x1e882c,_0x48f466,_0x56b067){return new Beepall(_0x24810f,_0x1e882c,_0x48f466,_0x56b067);}module[_0xccb2('0x1e')]=beepall;