Built motion from commit (unavailable).|2.0.78
[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 _0x05b6=['writeLog','RINGING','busy','busyQueue','name','showNotification','info','[%s][QUEUE]\x20EMPTY','TIMEOUT','hideNotification','exports','lodash','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','length','floor','qtimeout','atimeout','module','push','handleRun','bind','handleTimeout','drained','prototype','done','isNil','Agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','agents'];(function(_0xd22d95,_0xc59f8f){var _0x15d7a3=function(_0x3db95c){while(--_0x3db95c){_0xd22d95['push'](_0xd22d95['shift']());}};_0x15d7a3(++_0xc59f8f);}(_0x05b6,0x74));var _0x605b=function(_0x598bc1,_0x543990){_0x598bc1=_0x598bc1-0x0;var _0x14625d=_0x05b6[_0x598bc1];return _0x14625d;};'use strict';var _=require(_0x605b('0x0'));var uuid=require('uuid');var util=require(_0x605b('0x1'));var logger=require(_0x605b('0x2'))(_0x605b('0x3'));var Beepall=function(_0x4f59a3,_0x32c184,_0xb2ff0a,_0x307937){this[_0x605b('0x4')]=uuid['v4']();this[_0x605b('0x5')]=_0x4f59a3;this[_0x605b('0x6')]=_0x32c184;this[_0x605b('0x7')]=_0xb2ff0a;this[_0x605b('0x3')]=_0x307937;this[_0x605b('0x8')]=Math[_0x605b('0x9')](this[_0x605b('0x5')][_0x605b('0xa')]/this[_0x605b('0x5')][_0x605b('0xb')]);this[_0x605b('0xc')]=this['squeue'][_0x605b('0xa')]%this['squeue']['atimeout'];for(var _0x5148e5=0x0;_0x5148e5<this[_0x605b('0x8')];_0x5148e5+=0x1){this[_0x605b('0x5')][_0x605b('0xd')](this[_0x605b('0xe')][_0x605b('0xf')](this),this[_0x605b('0x10')][_0x605b('0xf')](this));}this[_0x605b('0x5')][_0x605b('0xd')](this[_0x605b('0xe')][_0x605b('0xf')](this),this[_0x605b('0x10')][_0x605b('0xf')](this),this[_0x605b('0xc')]);this['squeue']['on'](_0x605b('0x11'),this[_0x605b('0x10')]['bind'](this));};Beepall['prototype']['push']=function(){this[_0x605b('0x5')][_0x605b('0xd')](this['handleRun'][_0x605b('0xf')](this),this[_0x605b('0x10')][_0x605b('0xf')](this));};Beepall[_0x605b('0x12')][_0x605b('0x13')]=function(_0x5974f8){if(_0x5974f8){setTimeout(this[_0x605b('0xd')][_0x605b('0xf')](this),0x3e8);_0x5974f8['done']();}};Beepall[_0x605b('0x12')]['handleRun']=function(_0x2a6a74){var _0x258154=!![];if(!_[_0x605b('0x14')](this['queue'])&&!_[_0x605b('0x14')](this[_0x605b('0x6')][_0x605b('0x15')])&&this[_0x605b('0x6')][_0x605b('0x15')][_0x605b('0x8')]>0x0){for(var _0x2d7cd6=0x0,_0x48adf5;_0x2d7cd6<this[_0x605b('0x6')][_0x605b('0x15')][_0x605b('0x8')];_0x2d7cd6+=0x1){_0x48adf5=this[_0x605b('0x6')][_0x605b('0x15')][_0x2d7cd6]['id'];if(_[_0x605b('0x14')](this[_0x605b('0x7')]['agents'][_0x48adf5])){logger['info'](_0x605b('0x16'),this['squeue']['id'],_0x48adf5);}else{if(util['isAgentAvailable'](this[_0x605b('0x5')]['id'],this[_0x605b('0x7')][_0x605b('0x17')][_0x48adf5],this['squeue']['channel'],!![])){_0x258154=![];util[_0x605b('0x18')](this['squeue']['id'],this[_0x605b('0x7')]['agents'][_0x48adf5],_0x605b('0x19'));this[_0x605b('0x7')]['agents'][_0x48adf5][_0x605b('0x1a')]=!![];this['realtime'][_0x605b('0x17')][_0x48adf5][_0x605b('0x1b')]=this[_0x605b('0x6')][_0x605b('0x1c')];util[_0x605b('0x1d')](this[_0x605b('0x4')],this[_0x605b('0x5')]['id'],this[_0x605b('0x7')][_0x605b('0x17')][_0x48adf5],this[_0x605b('0x6')],this['routing']);}}}if(_0x258154){this[_0x605b('0x13')](_0x2a6a74);}}else{logger[_0x605b('0x1e')](_0x605b('0x1f'),this[_0x605b('0x5')]['id']);this['done'](_0x2a6a74);}};Beepall[_0x605b('0x12')][_0x605b('0x10')]=function(){if(!_[_0x605b('0x14')](this['queue'])&&!_[_0x605b('0x14')](this[_0x605b('0x6')]['Agents'])){for(var _0x2f9ec1=0x0,_0x5498d4;_0x2f9ec1<this[_0x605b('0x6')]['Agents'][_0x605b('0x8')];_0x2f9ec1+=0x1){_0x5498d4=this[_0x605b('0x6')][_0x605b('0x15')][_0x2f9ec1]['id'];if(_['isNil'](this[_0x605b('0x7')][_0x605b('0x17')][_0x5498d4])){logger[_0x605b('0x1e')](_0x605b('0x16'),this[_0x605b('0x5')]['id'],_0x5498d4);}else{util[_0x605b('0x18')](this[_0x605b('0x5')]['id'],this[_0x605b('0x7')]['agents'][_0x5498d4],_0x605b('0x20'));this[_0x605b('0x7')]['agents'][_0x5498d4]['busy']=![];this['realtime'][_0x605b('0x17')][_0x5498d4][_0x605b('0x1b')]=undefined;util[_0x605b('0x21')](this[_0x605b('0x4')],this[_0x605b('0x5')]['id'],this[_0x605b('0x7')]['agents'][_0x5498d4],this[_0x605b('0x6')],this[_0x605b('0x3')]);}}}};function beepall(_0x13a6a7,_0x31b7de,_0xce2eff,_0x29ecb1){return new Beepall(_0x13a6a7,_0x31b7de,_0xce2eff,_0x29ecb1);}module[_0x605b('0x22')]=beepall;