Built motion from commit ce03bc3d.|2.5.39
[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 _0xbe52=['hideNotification','STOP','TIMEOUT','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind','timeout','handleDrained','prototype','handleTimeout','isNil','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','writeLog','RINGING','busy','name','showNotification','[%s][QUEUE]\x20EMPTY'];(function(_0x5dd838,_0x38759c){var _0x5d4efe=function(_0x1ba0b2){while(--_0x1ba0b2){_0x5dd838['push'](_0x5dd838['shift']());}};_0x5d4efe(++_0x38759c);}(_0xbe52,0x164));var _0x2be5=function(_0x17b1f9,_0x38971a){_0x17b1f9=_0x17b1f9-0x0;var _0x199168=_0xbe52[_0x17b1f9];return _0x199168;};'use strict';var _=require(_0x2be5('0x0'));var uuid=require(_0x2be5('0x1'));var util=require(_0x2be5('0x2'));var logger=require(_0x2be5('0x3'))(_0x2be5('0x4'));var Beepall=function(_0x5ecf66,_0x90c88c,_0x166164,_0x3339d3){this[_0x2be5('0x5')]=uuid['v4']();this[_0x2be5('0x6')]=_0x5ecf66;this[_0x2be5('0x7')]=_0x90c88c;this[_0x2be5('0x8')]=_0x166164;this[_0x2be5('0x4')]=_0x3339d3;this[_0x2be5('0x6')][_0x2be5('0x9')](this[_0x2be5('0xa')][_0x2be5('0xb')](this),this['handleTimeout'][_0x2be5('0xb')](this));this[_0x2be5('0x6')]['on'](_0x2be5('0xc'),this['handleTimeout'][_0x2be5('0xb')](this));this['squeue']['on']('drained',this[_0x2be5('0xd')][_0x2be5('0xb')](this));};Beepall[_0x2be5('0xe')][_0x2be5('0x9')]=function(){this['squeue'][_0x2be5('0x9')](this[_0x2be5('0xa')]['bind'](this),this['handleTimeout'][_0x2be5('0xb')](this));};Beepall[_0x2be5('0xe')]['handleDrained']=function(_0x42fe08){this[_0x2be5('0xf')](!![]);};Beepall[_0x2be5('0xe')][_0x2be5('0xa')]=function(_0x38fc4b){var _0x17737d=!![];if(!_['isNil'](this['queue'])&&!_[_0x2be5('0x10')](this['queue'][_0x2be5('0x11')])&&this['queue'][_0x2be5('0x11')][_0x2be5('0x12')]>0x0){for(var _0x35db37=0x0,_0x5c6a02;_0x35db37<this[_0x2be5('0x7')][_0x2be5('0x11')]['length'];_0x35db37+=0x1){_0x5c6a02=this[_0x2be5('0x7')][_0x2be5('0x11')][_0x35db37]['id'];if(_[_0x2be5('0x10')](this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02])){logger[_0x2be5('0x14')](_0x2be5('0x15'),this['squeue']['id'],_0x5c6a02);}else{if(util['isAgentAvailable'](this[_0x2be5('0x6')]['id'],this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02],this[_0x2be5('0x6')]['channel'],!![])){_0x17737d=![];util[_0x2be5('0x16')](this[_0x2be5('0x6')]['id'],this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02],_0x2be5('0x17'));this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02][_0x2be5('0x18')]=!![];this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02]['busyQueue']=this[_0x2be5('0x7')][_0x2be5('0x19')];util[_0x2be5('0x1a')](this['notificationId'],this[_0x2be5('0x6')]['id'],this[_0x2be5('0x8')][_0x2be5('0x13')][_0x5c6a02],this[_0x2be5('0x7')],this[_0x2be5('0x4')]);}}}if(_0x17737d){logger[_0x2be5('0x14')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0x2be5('0x6')]['id']);setTimeout(this[_0x2be5('0x9')][_0x2be5('0xb')](this),0x3e8);}}else{logger[_0x2be5('0x14')](_0x2be5('0x1b'),this[_0x2be5('0x6')]['id']);setTimeout(this[_0x2be5('0x9')]['bind'](this),0x3e8);}};Beepall[_0x2be5('0xe')][_0x2be5('0xf')]=function(_0x52ed0f){if(!_[_0x2be5('0x10')](this[_0x2be5('0x7')])&&!_[_0x2be5('0x10')](this[_0x2be5('0x7')]['Agents'])){for(var _0xf58441=0x0,_0x42efd8;_0xf58441<this[_0x2be5('0x7')]['Agents'][_0x2be5('0x12')];_0xf58441+=0x1){_0x42efd8=this[_0x2be5('0x7')]['Agents'][_0xf58441]['id'];if(_[_0x2be5('0x10')](this[_0x2be5('0x8')][_0x2be5('0x13')][_0x42efd8])){logger[_0x2be5('0x14')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x2be5('0x6')]['id'],_0x42efd8);}else{util[_0x2be5('0x1c')](this[_0x2be5('0x5')],this['squeue']['id'],this['realtime'][_0x2be5('0x13')][_0x42efd8],this[_0x2be5('0x7')],this[_0x2be5('0x4')]);util[_0x2be5('0x16')](this[_0x2be5('0x6')]['id'],this[_0x2be5('0x8')]['agents'][_0x42efd8],_0x52ed0f?_0x2be5('0x1d'):_0x2be5('0x1e'));this['realtime'][_0x2be5('0x13')][_0x42efd8][_0x2be5('0x18')]=![];this[_0x2be5('0x8')]['agents'][_0x42efd8]['busyQueue']=undefined;}}}if(!_0x52ed0f){setTimeout(this[_0x2be5('0x9')][_0x2be5('0xb')](this),0x3e8);}};function beepall(_0xf40e46,_0x1644be,_0x470f1d,_0x1beaff){return new Beepall(_0xf40e46,_0x1644be,_0x470f1d,_0x1beaff);}module[_0x2be5('0x1f')]=beepall;