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 _0xa120=['agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','writeLog','RINGING','busyQueue','name','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','length','hideNotification','STOP','TIMEOUT','busy','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','bind','handleTimeout','timeout','handleDrained','prototype','handleRun','isNil','Agents'];(function(_0x97f6db,_0x3c1b27){var _0x396fda=function(_0x4066bc){while(--_0x4066bc){_0x97f6db['push'](_0x97f6db['shift']());}};_0x396fda(++_0x3c1b27);}(_0xa120,0xf6));var _0x0a12=function(_0x52982f,_0x36c33e){_0x52982f=_0x52982f-0x0;var _0x3ac186=_0xa120[_0x52982f];return _0x3ac186;};'use strict';var _=require(_0x0a12('0x0'));var uuid=require(_0x0a12('0x1'));var util=require(_0x0a12('0x2'));var logger=require(_0x0a12('0x3'))(_0x0a12('0x4'));var Beepall=function(_0x8ed316,_0x610e1,_0x3743b8,_0x463a02){this[_0x0a12('0x5')]=uuid['v4']();this[_0x0a12('0x6')]=_0x8ed316;this[_0x0a12('0x7')]=_0x610e1;this[_0x0a12('0x8')]=_0x3743b8;this['routing']=_0x463a02;this[_0x0a12('0x6')][_0x0a12('0x9')](this['handleRun'][_0x0a12('0xa')](this),this[_0x0a12('0xb')][_0x0a12('0xa')](this));this[_0x0a12('0x6')]['on'](_0x0a12('0xc'),this[_0x0a12('0xb')][_0x0a12('0xa')](this));this[_0x0a12('0x6')]['on']('drained',this[_0x0a12('0xd')]['bind'](this));};Beepall[_0x0a12('0xe')][_0x0a12('0x9')]=function(){this[_0x0a12('0x6')][_0x0a12('0x9')](this[_0x0a12('0xf')][_0x0a12('0xa')](this),this[_0x0a12('0xb')][_0x0a12('0xa')](this));};Beepall[_0x0a12('0xe')][_0x0a12('0xd')]=function(_0x8680e){this[_0x0a12('0xb')](!![]);};Beepall['prototype'][_0x0a12('0xf')]=function(_0x52a0b7){var _0x75e4a7=!![];if(!_[_0x0a12('0x10')](this[_0x0a12('0x7')])&&!_[_0x0a12('0x10')](this[_0x0a12('0x7')][_0x0a12('0x11')])&&this['queue'][_0x0a12('0x11')]['length']>0x0){for(var _0x5b30c8=0x0,_0x37e891;_0x5b30c8<this[_0x0a12('0x7')]['Agents']['length'];_0x5b30c8+=0x1){_0x37e891=this['queue'][_0x0a12('0x11')][_0x5b30c8]['id'];if(_[_0x0a12('0x10')](this[_0x0a12('0x8')][_0x0a12('0x12')][_0x37e891])){logger[_0x0a12('0x13')](_0x0a12('0x14'),this[_0x0a12('0x6')]['id'],_0x37e891);}else{if(util['isAgentAvailable'](this[_0x0a12('0x6')]['id'],this[_0x0a12('0x8')][_0x0a12('0x12')][_0x37e891],this['squeue']['channel'],!![])){_0x75e4a7=![];util[_0x0a12('0x15')](this[_0x0a12('0x6')]['id'],this['realtime'][_0x0a12('0x12')][_0x37e891],_0x0a12('0x16'));this[_0x0a12('0x8')][_0x0a12('0x12')][_0x37e891]['busy']=!![];this[_0x0a12('0x8')][_0x0a12('0x12')][_0x37e891][_0x0a12('0x17')]=this[_0x0a12('0x7')][_0x0a12('0x18')];util['showNotification'](this[_0x0a12('0x5')],this[_0x0a12('0x6')]['id'],this[_0x0a12('0x8')]['agents'][_0x37e891],this[_0x0a12('0x7')],this[_0x0a12('0x4')]);}}}if(_0x75e4a7){logger['info'](_0x0a12('0x19'),this[_0x0a12('0x6')]['id']);setTimeout(this['push']['bind'](this),0x3e8);}}else{logger['info'](_0x0a12('0x1a'),this['squeue']['id']);setTimeout(this[_0x0a12('0x9')]['bind'](this),0x3e8);}};Beepall[_0x0a12('0xe')]['handleTimeout']=function(_0x8377dc){if(!_[_0x0a12('0x10')](this['queue'])&&!_[_0x0a12('0x10')](this['queue'][_0x0a12('0x11')])){for(var _0x49fe3e=0x0,_0x1d4d0d;_0x49fe3e<this[_0x0a12('0x7')][_0x0a12('0x11')][_0x0a12('0x1b')];_0x49fe3e+=0x1){_0x1d4d0d=this[_0x0a12('0x7')]['Agents'][_0x49fe3e]['id'];if(_[_0x0a12('0x10')](this[_0x0a12('0x8')][_0x0a12('0x12')][_0x1d4d0d])){logger[_0x0a12('0x13')](_0x0a12('0x14'),this[_0x0a12('0x6')]['id'],_0x1d4d0d);}else{util[_0x0a12('0x1c')](this['notificationId'],this[_0x0a12('0x6')]['id'],this[_0x0a12('0x8')][_0x0a12('0x12')][_0x1d4d0d],this[_0x0a12('0x7')],this['routing']);util['writeLog'](this['squeue']['id'],this[_0x0a12('0x8')][_0x0a12('0x12')][_0x1d4d0d],_0x8377dc?_0x0a12('0x1d'):_0x0a12('0x1e'));this[_0x0a12('0x8')][_0x0a12('0x12')][_0x1d4d0d][_0x0a12('0x1f')]=![];this['realtime'][_0x0a12('0x12')][_0x1d4d0d][_0x0a12('0x17')]=undefined;}}}if(!_0x8377dc){setTimeout(this[_0x0a12('0x9')][_0x0a12('0xa')](this),0x3e8);}};function beepall(_0x35847a,_0x470d6c,_0x33bb83,_0x24d602){return new Beepall(_0x35847a,_0x470d6c,_0x33bb83,_0x24d602);}module[_0x0a12('0x20')]=beepall;