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 _0x8afd=['exports','lodash','uuid','./util','../../../../../config/logger','queue','realtime','routing','squeue','handleRun','bind','handleTimeout','timeout','handleDrained','push','isNil','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','RINGING','busy','busyQueue','name','showNotification','notificationId','[%s][QUEUE]\x20EMPTY','prototype','STOP','TIMEOUT'];(function(_0x27a0a9,_0x1e7dd1){var _0x11cb3b=function(_0x5a9aa3){while(--_0x5a9aa3){_0x27a0a9['push'](_0x27a0a9['shift']());}};_0x11cb3b(++_0x1e7dd1);}(_0x8afd,0x121));var _0xd8af=function(_0x1a3b59,_0x350596){_0x1a3b59=_0x1a3b59-0x0;var _0x11b88d=_0x8afd[_0x1a3b59];return _0x11b88d;};'use strict';var _=require(_0xd8af('0x0'));var uuid=require(_0xd8af('0x1'));var util=require(_0xd8af('0x2'));var logger=require(_0xd8af('0x3'))('routing');var Beepall=function(_0x6586f4,_0x4cc810,_0xa3b75a,_0x5f022b){this['notificationId']=uuid['v4']();this['squeue']=_0x6586f4;this[_0xd8af('0x4')]=_0x4cc810;this[_0xd8af('0x5')]=_0xa3b75a;this[_0xd8af('0x6')]=_0x5f022b;this[_0xd8af('0x7')]['push'](this[_0xd8af('0x8')][_0xd8af('0x9')](this),this[_0xd8af('0xa')]['bind'](this));this[_0xd8af('0x7')]['on'](_0xd8af('0xb'),this[_0xd8af('0xa')][_0xd8af('0x9')](this));this[_0xd8af('0x7')]['on']('drained',this[_0xd8af('0xc')][_0xd8af('0x9')](this));};Beepall['prototype'][_0xd8af('0xd')]=function(){this[_0xd8af('0x7')][_0xd8af('0xd')](this[_0xd8af('0x8')]['bind'](this),this[_0xd8af('0xa')][_0xd8af('0x9')](this));};Beepall['prototype'][_0xd8af('0xc')]=function(_0x2499a0){this['handleTimeout'](!![]);};Beepall['prototype'][_0xd8af('0x8')]=function(_0x52f5ab){var _0x28ddda=!![];if(!_['isNil'](this[_0xd8af('0x4')])&&!_[_0xd8af('0xe')](this[_0xd8af('0x4')][_0xd8af('0xf')])&&this[_0xd8af('0x4')][_0xd8af('0xf')][_0xd8af('0x10')]>0x0){for(var _0x30906c=0x0,_0x29b875;_0x30906c<this[_0xd8af('0x4')][_0xd8af('0xf')][_0xd8af('0x10')];_0x30906c+=0x1){_0x29b875=this[_0xd8af('0x4')]['Agents'][_0x30906c]['id'];if(_[_0xd8af('0xe')](this[_0xd8af('0x5')][_0xd8af('0x11')][_0x29b875])){logger[_0xd8af('0x12')](_0xd8af('0x13'),this[_0xd8af('0x7')]['id'],_0x29b875);}else{if(util[_0xd8af('0x14')](this['squeue']['id'],this['realtime'][_0xd8af('0x11')][_0x29b875],this[_0xd8af('0x7')]['channel'],!![])){_0x28ddda=![];util['writeLog'](this['squeue']['id'],this[_0xd8af('0x5')][_0xd8af('0x11')][_0x29b875],_0xd8af('0x15'));this[_0xd8af('0x5')][_0xd8af('0x11')][_0x29b875][_0xd8af('0x16')]=!![];this[_0xd8af('0x5')]['agents'][_0x29b875][_0xd8af('0x17')]=this[_0xd8af('0x4')][_0xd8af('0x18')];util[_0xd8af('0x19')](this[_0xd8af('0x1a')],this[_0xd8af('0x7')]['id'],this[_0xd8af('0x5')][_0xd8af('0x11')][_0x29b875],this[_0xd8af('0x4')],this[_0xd8af('0x6')]);}}}if(_0x28ddda){logger[_0xd8af('0x12')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0xd8af('0x7')]['id']);setTimeout(this['push'][_0xd8af('0x9')](this),0x3e8);}}else{logger[_0xd8af('0x12')](_0xd8af('0x1b'),this[_0xd8af('0x7')]['id']);setTimeout(this[_0xd8af('0xd')][_0xd8af('0x9')](this),0x3e8);}};Beepall[_0xd8af('0x1c')][_0xd8af('0xa')]=function(_0x2d37f6){if(!_[_0xd8af('0xe')](this[_0xd8af('0x4')])&&!_[_0xd8af('0xe')](this[_0xd8af('0x4')]['Agents'])){for(var _0x2aba62=0x0,_0x4456ac;_0x2aba62<this[_0xd8af('0x4')]['Agents'][_0xd8af('0x10')];_0x2aba62+=0x1){_0x4456ac=this[_0xd8af('0x4')][_0xd8af('0xf')][_0x2aba62]['id'];if(_['isNil'](this[_0xd8af('0x5')][_0xd8af('0x11')][_0x4456ac])){logger[_0xd8af('0x12')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xd8af('0x7')]['id'],_0x4456ac);}else{util['hideNotification'](this[_0xd8af('0x1a')],this[_0xd8af('0x7')]['id'],this['realtime']['agents'][_0x4456ac],this[_0xd8af('0x4')],this[_0xd8af('0x6')]);util['writeLog'](this[_0xd8af('0x7')]['id'],this[_0xd8af('0x5')][_0xd8af('0x11')][_0x4456ac],_0x2d37f6?_0xd8af('0x1d'):_0xd8af('0x1e'));this[_0xd8af('0x5')][_0xd8af('0x11')][_0x4456ac][_0xd8af('0x16')]=![];this[_0xd8af('0x5')][_0xd8af('0x11')][_0x4456ac]['busyQueue']=undefined;}}}if(!_0x2d37f6){setTimeout(this[_0xd8af('0xd')]['bind'](this),0x3e8);}};function beepall(_0x5d5a9b,_0x1fc51d,_0x17aa4c,_0x7ff4d2){return new Beepall(_0x5d5a9b,_0x1fc51d,_0x17aa4c,_0x7ff4d2);}module[_0xd8af('0x1f')]=beepall;