Built motion from commit (unavailable).|2.4.3
[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 _0x1689=['timeout','drained','handleDrained','handleRun','prototype','isNil','queue','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','RINGING','busy','busyQueue','showNotification','hideNotification','notificationId','STOP','TIMEOUT','exports','lodash','uuid','./util','../../../../../config/logger','routing','squeue','realtime','push','bind','handleTimeout'];(function(_0x5ca927,_0x38c385){var _0x1eb900=function(_0x15fa00){while(--_0x15fa00){_0x5ca927['push'](_0x5ca927['shift']());}};_0x1eb900(++_0x38c385);}(_0x1689,0x182));var _0x9168=function(_0xdc91b9,_0x5c7440){_0xdc91b9=_0xdc91b9-0x0;var _0x1d6516=_0x1689[_0xdc91b9];return _0x1d6516;};'use strict';var _=require(_0x9168('0x0'));var uuid=require(_0x9168('0x1'));var util=require(_0x9168('0x2'));var logger=require(_0x9168('0x3'))(_0x9168('0x4'));var Beepall=function(_0x170c8a,_0x2ab555,_0x1f6e75,_0xeb8ab6){this['notificationId']=uuid['v4']();this[_0x9168('0x5')]=_0x170c8a;this['queue']=_0x2ab555;this[_0x9168('0x6')]=_0x1f6e75;this['routing']=_0xeb8ab6;this[_0x9168('0x5')][_0x9168('0x7')](this['handleRun'][_0x9168('0x8')](this),this[_0x9168('0x9')][_0x9168('0x8')](this));this['squeue']['on'](_0x9168('0xa'),this[_0x9168('0x9')][_0x9168('0x8')](this));this[_0x9168('0x5')]['on'](_0x9168('0xb'),this[_0x9168('0xc')][_0x9168('0x8')](this));};Beepall['prototype'][_0x9168('0x7')]=function(){this[_0x9168('0x5')][_0x9168('0x7')](this[_0x9168('0xd')][_0x9168('0x8')](this),this[_0x9168('0x9')][_0x9168('0x8')](this));};Beepall[_0x9168('0xe')]['handleDrained']=function(_0x5ce4ae){this[_0x9168('0x9')](!![]);};Beepall[_0x9168('0xe')]['handleRun']=function(_0x41a1ed){var _0x46bc0c=!![];if(!_['isNil'](this['queue'])&&!_[_0x9168('0xf')](this[_0x9168('0x10')][_0x9168('0x11')])&&this[_0x9168('0x10')]['Agents'][_0x9168('0x12')]>0x0){for(var _0x23bd8a=0x0,_0x4f31b3;_0x23bd8a<this[_0x9168('0x10')]['Agents'][_0x9168('0x12')];_0x23bd8a+=0x1){_0x4f31b3=this['queue'][_0x9168('0x11')][_0x23bd8a]['id'];if(_[_0x9168('0xf')](this[_0x9168('0x6')][_0x9168('0x13')][_0x4f31b3])){logger[_0x9168('0x14')](_0x9168('0x15'),this[_0x9168('0x5')]['id'],_0x4f31b3);}else{if(util[_0x9168('0x16')](this['squeue']['id'],this[_0x9168('0x6')][_0x9168('0x13')][_0x4f31b3],this['squeue']['channel'],!![])){_0x46bc0c=![];util[_0x9168('0x17')](this[_0x9168('0x5')]['id'],this['realtime'][_0x9168('0x13')][_0x4f31b3],_0x9168('0x18'));this[_0x9168('0x6')][_0x9168('0x13')][_0x4f31b3][_0x9168('0x19')]=!![];this[_0x9168('0x6')][_0x9168('0x13')][_0x4f31b3][_0x9168('0x1a')]=this['queue']['name'];util[_0x9168('0x1b')](this['notificationId'],this[_0x9168('0x5')]['id'],this[_0x9168('0x6')][_0x9168('0x13')][_0x4f31b3],this[_0x9168('0x10')],this['routing']);}}}if(_0x46bc0c){logger[_0x9168('0x14')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this['squeue']['id']);setTimeout(this[_0x9168('0x7')][_0x9168('0x8')](this),0x3e8);}}else{logger[_0x9168('0x14')]('[%s][QUEUE]\x20EMPTY',this[_0x9168('0x5')]['id']);setTimeout(this[_0x9168('0x7')][_0x9168('0x8')](this),0x3e8);}};Beepall['prototype'][_0x9168('0x9')]=function(_0x642b35){if(!_['isNil'](this[_0x9168('0x10')])&&!_[_0x9168('0xf')](this[_0x9168('0x10')][_0x9168('0x11')])){for(var _0xe32f4c=0x0,_0x325aae;_0xe32f4c<this[_0x9168('0x10')][_0x9168('0x11')][_0x9168('0x12')];_0xe32f4c+=0x1){_0x325aae=this[_0x9168('0x10')][_0x9168('0x11')][_0xe32f4c]['id'];if(_[_0x9168('0xf')](this[_0x9168('0x6')][_0x9168('0x13')][_0x325aae])){logger[_0x9168('0x14')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x9168('0x5')]['id'],_0x325aae);}else{util[_0x9168('0x1c')](this[_0x9168('0x1d')],this['squeue']['id'],this[_0x9168('0x6')][_0x9168('0x13')][_0x325aae],this[_0x9168('0x10')],this[_0x9168('0x4')]);util[_0x9168('0x17')](this[_0x9168('0x5')]['id'],this[_0x9168('0x6')][_0x9168('0x13')][_0x325aae],_0x642b35?_0x9168('0x1e'):_0x9168('0x1f'));this[_0x9168('0x6')][_0x9168('0x13')][_0x325aae][_0x9168('0x19')]=![];this[_0x9168('0x6')]['agents'][_0x325aae][_0x9168('0x1a')]=undefined;}}}if(!_0x642b35){setTimeout(this[_0x9168('0x7')]['bind'](this),0x3e8);}};function beepall(_0x16befe,_0xbb7f7d,_0x8ece97,_0x4c0330){return new Beepall(_0x16befe,_0xbb7f7d,_0x8ece97,_0x4c0330);}module[_0x9168('0x20')]=beepall;