Built motion from commit (unavailable).|2.5.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 _0x2e09=['lodash','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','handleRun','bind','handleTimeout','drained','handleDrained','prototype','isNil','Agents','length','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','agents','busyQueue','name','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','info','hideNotification','writeLog','STOP','TIMEOUT','exports'];(function(_0x5826b3,_0xa91fe5){var _0x127e43=function(_0x2e5d2d){while(--_0x2e5d2d){_0x5826b3['push'](_0x5826b3['shift']());}};_0x127e43(++_0xa91fe5);}(_0x2e09,0xc6));var _0x92e0=function(_0x5cc6be,_0x458982){_0x5cc6be=_0x5cc6be-0x0;var _0x1e719e=_0x2e09[_0x5cc6be];return _0x1e719e;};'use strict';var _=require(_0x92e0('0x0'));var uuid=require('uuid');var util=require(_0x92e0('0x1'));var logger=require(_0x92e0('0x2'))(_0x92e0('0x3'));var Beepall=function(_0x2d8e08,_0x10382b,_0x3d551c,_0x2a1390){this[_0x92e0('0x4')]=uuid['v4']();this[_0x92e0('0x5')]=_0x2d8e08;this[_0x92e0('0x6')]=_0x10382b;this[_0x92e0('0x7')]=_0x3d551c;this['routing']=_0x2a1390;this[_0x92e0('0x5')][_0x92e0('0x8')](this[_0x92e0('0x9')][_0x92e0('0xa')](this),this[_0x92e0('0xb')]['bind'](this));this['squeue']['on']('timeout',this[_0x92e0('0xb')][_0x92e0('0xa')](this));this[_0x92e0('0x5')]['on'](_0x92e0('0xc'),this[_0x92e0('0xd')][_0x92e0('0xa')](this));};Beepall[_0x92e0('0xe')][_0x92e0('0x8')]=function(){this[_0x92e0('0x5')]['push'](this['handleRun'][_0x92e0('0xa')](this),this[_0x92e0('0xb')][_0x92e0('0xa')](this));};Beepall[_0x92e0('0xe')][_0x92e0('0xd')]=function(_0x51ec20){this[_0x92e0('0xb')](!![]);};Beepall[_0x92e0('0xe')][_0x92e0('0x9')]=function(_0x3a996c){var _0x1a8cea=!![];if(!_[_0x92e0('0xf')](this[_0x92e0('0x6')])&&!_[_0x92e0('0xf')](this[_0x92e0('0x6')][_0x92e0('0x10')])&&this[_0x92e0('0x6')][_0x92e0('0x10')][_0x92e0('0x11')]>0x0){for(var _0x48b9a0=0x0,_0x3adf13;_0x48b9a0<this['queue'][_0x92e0('0x10')]['length'];_0x48b9a0+=0x1){_0x3adf13=this[_0x92e0('0x6')][_0x92e0('0x10')][_0x48b9a0]['id'];if(_[_0x92e0('0xf')](this[_0x92e0('0x7')]['agents'][_0x3adf13])){logger['info'](_0x92e0('0x12'),this[_0x92e0('0x5')]['id'],_0x3adf13);}else{if(util[_0x92e0('0x13')](this[_0x92e0('0x5')]['id'],this[_0x92e0('0x7')]['agents'][_0x3adf13],this[_0x92e0('0x5')][_0x92e0('0x14')],!![])){_0x1a8cea=![];util['writeLog'](this['squeue']['id'],this[_0x92e0('0x7')][_0x92e0('0x15')][_0x3adf13],'RINGING');this[_0x92e0('0x7')][_0x92e0('0x15')][_0x3adf13]['busy']=!![];this['realtime']['agents'][_0x3adf13][_0x92e0('0x16')]=this[_0x92e0('0x6')][_0x92e0('0x17')];util[_0x92e0('0x18')](this[_0x92e0('0x4')],this['squeue']['id'],this[_0x92e0('0x7')][_0x92e0('0x15')][_0x3adf13],this[_0x92e0('0x6')],this['routing']);}}}if(_0x1a8cea){logger['info'](_0x92e0('0x19'),this[_0x92e0('0x5')]['id']);setTimeout(this[_0x92e0('0x8')][_0x92e0('0xa')](this),0x3e8);}}else{logger['info'](_0x92e0('0x1a'),this[_0x92e0('0x5')]['id']);setTimeout(this[_0x92e0('0x8')][_0x92e0('0xa')](this),0x3e8);}};Beepall[_0x92e0('0xe')][_0x92e0('0xb')]=function(_0x42ac54){if(!_[_0x92e0('0xf')](this[_0x92e0('0x6')])&&!_[_0x92e0('0xf')](this[_0x92e0('0x6')][_0x92e0('0x10')])){for(var _0x360829=0x0,_0x2cd605;_0x360829<this[_0x92e0('0x6')][_0x92e0('0x10')][_0x92e0('0x11')];_0x360829+=0x1){_0x2cd605=this[_0x92e0('0x6')][_0x92e0('0x10')][_0x360829]['id'];if(_['isNil'](this[_0x92e0('0x7')]['agents'][_0x2cd605])){logger[_0x92e0('0x1b')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],_0x2cd605);}else{util[_0x92e0('0x1c')](this[_0x92e0('0x4')],this['squeue']['id'],this['realtime'][_0x92e0('0x15')][_0x2cd605],this[_0x92e0('0x6')],this[_0x92e0('0x3')]);util[_0x92e0('0x1d')](this[_0x92e0('0x5')]['id'],this[_0x92e0('0x7')][_0x92e0('0x15')][_0x2cd605],_0x42ac54?_0x92e0('0x1e'):_0x92e0('0x1f'));this[_0x92e0('0x7')][_0x92e0('0x15')][_0x2cd605]['busy']=![];this[_0x92e0('0x7')]['agents'][_0x2cd605]['busyQueue']=undefined;}}}if(!_0x42ac54){setTimeout(this['push'][_0x92e0('0xa')](this),0x3e8);}};function beepall(_0xe71a0d,_0x5aa1c6,_0x1d08a0,_0x4f3968){return new Beepall(_0xe71a0d,_0x5aa1c6,_0x1d08a0,_0x4f3968);}module[_0x92e0('0x20')]=beepall;