d3f63de4e79392b91688f240d6b7099b09275aee
[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 _0x72f1=['prototype','isNil','Agents','length','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','writeLog','name','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','info','STOP','busy','exports','lodash','uuid','routing','queue','realtime','squeue','handleRun','bind','handleTimeout','drained','handleDrained','push'];(function(_0x818b09,_0x14c01b){var _0x3d1ac9=function(_0xd11002){while(--_0xd11002){_0x818b09['push'](_0x818b09['shift']());}};_0x3d1ac9(++_0x14c01b);}(_0x72f1,0xf0));var _0x172f=function(_0x247aad,_0x325fe7){_0x247aad=_0x247aad-0x0;var _0x3c895f=_0x72f1[_0x247aad];return _0x3c895f;};'use strict';var _=require(_0x172f('0x0'));var uuid=require(_0x172f('0x1'));var util=require('./util');var logger=require('../../../../../config/logger')(_0x172f('0x2'));var Beepall=function(_0x2630ea,_0x4f7e33,_0x1bcdc8,_0x1b463a){this['notificationId']=uuid['v4']();this['squeue']=_0x2630ea;this[_0x172f('0x3')]=_0x4f7e33;this[_0x172f('0x4')]=_0x1bcdc8;this[_0x172f('0x2')]=_0x1b463a;this[_0x172f('0x5')]['push'](this[_0x172f('0x6')][_0x172f('0x7')](this),this[_0x172f('0x8')]['bind'](this));this[_0x172f('0x5')]['on']('timeout',this['handleTimeout'][_0x172f('0x7')](this));this[_0x172f('0x5')]['on'](_0x172f('0x9'),this[_0x172f('0xa')][_0x172f('0x7')](this));};Beepall['prototype'][_0x172f('0xb')]=function(){this[_0x172f('0x5')][_0x172f('0xb')](this[_0x172f('0x6')][_0x172f('0x7')](this),this['handleTimeout'][_0x172f('0x7')](this));};Beepall[_0x172f('0xc')][_0x172f('0xa')]=function(_0x29daf6){this['handleTimeout'](!![]);};Beepall['prototype'][_0x172f('0x6')]=function(_0x184333){var _0xba525b=!![];if(!_['isNil'](this[_0x172f('0x3')])&&!_[_0x172f('0xd')](this['queue'][_0x172f('0xe')])&&this[_0x172f('0x3')][_0x172f('0xe')][_0x172f('0xf')]>0x0){for(var _0x1229ed=0x0,_0x14cb68;_0x1229ed<this[_0x172f('0x3')][_0x172f('0xe')][_0x172f('0xf')];_0x1229ed+=0x1){_0x14cb68=this[_0x172f('0x3')]['Agents'][_0x1229ed]['id'];if(_[_0x172f('0xd')](this['realtime'][_0x172f('0x10')][_0x14cb68])){logger['info'](_0x172f('0x11'),this[_0x172f('0x5')]['id'],_0x14cb68);}else{if(util['isAgentAvailable'](this[_0x172f('0x5')]['id'],this['realtime'][_0x172f('0x10')][_0x14cb68],this['squeue'][_0x172f('0x12')],!![])){_0xba525b=![];util[_0x172f('0x13')](this[_0x172f('0x5')]['id'],this[_0x172f('0x4')]['agents'][_0x14cb68],'RINGING');this[_0x172f('0x4')][_0x172f('0x10')][_0x14cb68]['busy']=!![];this[_0x172f('0x4')][_0x172f('0x10')][_0x14cb68]['busyQueue']=this['queue'][_0x172f('0x14')];util['showNotification'](this[_0x172f('0x15')],this['squeue']['id'],this[_0x172f('0x4')]['agents'][_0x14cb68],this[_0x172f('0x3')],this[_0x172f('0x2')]);}}}if(_0xba525b){logger['info'](_0x172f('0x16'),this['squeue']['id']);setTimeout(this[_0x172f('0xb')][_0x172f('0x7')](this),0x3e8);}}else{logger['info'](_0x172f('0x17'),this['squeue']['id']);setTimeout(this[_0x172f('0xb')]['bind'](this),0x3e8);}};Beepall['prototype'][_0x172f('0x8')]=function(_0x420574){if(!_[_0x172f('0xd')](this[_0x172f('0x3')])&&!_[_0x172f('0xd')](this[_0x172f('0x3')][_0x172f('0xe')])){for(var _0x787f60=0x0,_0x139c27;_0x787f60<this[_0x172f('0x3')][_0x172f('0xe')]['length'];_0x787f60+=0x1){_0x139c27=this[_0x172f('0x3')]['Agents'][_0x787f60]['id'];if(_[_0x172f('0xd')](this[_0x172f('0x4')][_0x172f('0x10')][_0x139c27])){logger[_0x172f('0x18')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],_0x139c27);}else{util['hideNotification'](this[_0x172f('0x15')],this['squeue']['id'],this[_0x172f('0x4')]['agents'][_0x139c27],this[_0x172f('0x3')],this[_0x172f('0x2')]);util[_0x172f('0x13')](this[_0x172f('0x5')]['id'],this[_0x172f('0x4')][_0x172f('0x10')][_0x139c27],_0x420574?_0x172f('0x19'):'TIMEOUT');this['realtime']['agents'][_0x139c27][_0x172f('0x1a')]=![];this[_0x172f('0x4')][_0x172f('0x10')][_0x139c27]['busyQueue']=undefined;}}}if(!_0x420574){setTimeout(this[_0x172f('0xb')][_0x172f('0x7')](this),0x3e8);}};function beepall(_0x2e63c4,_0x48af0c,_0x59c1bc,_0x1d0fde){return new Beepall(_0x2e63c4,_0x48af0c,_0x59c1bc,_0x1d0fde);}module[_0x172f('0x1b')]=beepall;