Built motion from commit 25580385.|2.6.2
[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 _0x2e8a=['name','showNotification','notificationId','hideNotification','STOP','TIMEOUT','busy','uuid','./util','routing','realtime','squeue','handleRun','bind','handleTimeout','timeout','drained','handleDrained','push','prototype','isNil','queue','Agents','length','agents','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','channel','writeLog','RINGING','busyQueue'];(function(_0xb30eb,_0x744b17){var _0x543809=function(_0xe9b8eb){while(--_0xe9b8eb){_0xb30eb['push'](_0xb30eb['shift']());}};_0x543809(++_0x744b17);}(_0x2e8a,0xc7));var _0xa2e8=function(_0x13992d,_0x3029ea){_0x13992d=_0x13992d-0x0;var _0x3d15bf=_0x2e8a[_0x13992d];return _0x3d15bf;};'use strict';var _=require('lodash');var uuid=require(_0xa2e8('0x0'));var util=require(_0xa2e8('0x1'));var logger=require('../../../../../config/logger')(_0xa2e8('0x2'));var Beepall=function(_0x2b63d9,_0x4b770c,_0x426f9e,_0x522e76){this['notificationId']=uuid['v4']();this['squeue']=_0x2b63d9;this['queue']=_0x4b770c;this[_0xa2e8('0x3')]=_0x426f9e;this[_0xa2e8('0x2')]=_0x522e76;this[_0xa2e8('0x4')]['push'](this[_0xa2e8('0x5')][_0xa2e8('0x6')](this),this[_0xa2e8('0x7')][_0xa2e8('0x6')](this));this['squeue']['on'](_0xa2e8('0x8'),this['handleTimeout'][_0xa2e8('0x6')](this));this[_0xa2e8('0x4')]['on'](_0xa2e8('0x9'),this[_0xa2e8('0xa')][_0xa2e8('0x6')](this));};Beepall['prototype'][_0xa2e8('0xb')]=function(){this[_0xa2e8('0x4')]['push'](this[_0xa2e8('0x5')]['bind'](this),this[_0xa2e8('0x7')][_0xa2e8('0x6')](this));};Beepall[_0xa2e8('0xc')]['handleDrained']=function(_0x4d03bc){this['handleTimeout'](!![]);};Beepall[_0xa2e8('0xc')]['handleRun']=function(_0x2fdb19){var _0x51494d=!![];if(!_[_0xa2e8('0xd')](this[_0xa2e8('0xe')])&&!_[_0xa2e8('0xd')](this[_0xa2e8('0xe')][_0xa2e8('0xf')])&&this[_0xa2e8('0xe')]['Agents'][_0xa2e8('0x10')]>0x0){for(var _0x53ca1f=0x0,_0x4dfb8c;_0x53ca1f<this[_0xa2e8('0xe')][_0xa2e8('0xf')][_0xa2e8('0x10')];_0x53ca1f+=0x1){_0x4dfb8c=this[_0xa2e8('0xe')][_0xa2e8('0xf')][_0x53ca1f]['id'];if(_['isNil'](this['realtime'][_0xa2e8('0x11')][_0x4dfb8c])){logger[_0xa2e8('0x12')](_0xa2e8('0x13'),this[_0xa2e8('0x4')]['id'],_0x4dfb8c);}else{if(util[_0xa2e8('0x14')](this[_0xa2e8('0x4')]['id'],this['realtime'][_0xa2e8('0x11')][_0x4dfb8c],this[_0xa2e8('0x4')][_0xa2e8('0x15')],!![])){_0x51494d=![];util[_0xa2e8('0x16')](this['squeue']['id'],this['realtime'][_0xa2e8('0x11')][_0x4dfb8c],_0xa2e8('0x17'));this['realtime']['agents'][_0x4dfb8c]['busy']=!![];this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x4dfb8c][_0xa2e8('0x18')]=this[_0xa2e8('0xe')][_0xa2e8('0x19')];util[_0xa2e8('0x1a')](this[_0xa2e8('0x1b')],this[_0xa2e8('0x4')]['id'],this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x4dfb8c],this[_0xa2e8('0xe')],this[_0xa2e8('0x2')]);}}}if(_0x51494d){logger[_0xa2e8('0x12')]('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0xa2e8('0x4')]['id']);setTimeout(this[_0xa2e8('0xb')][_0xa2e8('0x6')](this),0x3e8);}}else{logger[_0xa2e8('0x12')]('[%s][QUEUE]\x20EMPTY',this['squeue']['id']);setTimeout(this[_0xa2e8('0xb')][_0xa2e8('0x6')](this),0x3e8);}};Beepall['prototype'][_0xa2e8('0x7')]=function(_0xdf0f7f){if(!_[_0xa2e8('0xd')](this[_0xa2e8('0xe')])&&!_[_0xa2e8('0xd')](this[_0xa2e8('0xe')][_0xa2e8('0xf')])){for(var _0x4a4904=0x0,_0x580ae1;_0x4a4904<this[_0xa2e8('0xe')][_0xa2e8('0xf')][_0xa2e8('0x10')];_0x4a4904+=0x1){_0x580ae1=this[_0xa2e8('0xe')][_0xa2e8('0xf')][_0x4a4904]['id'];if(_[_0xa2e8('0xd')](this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x580ae1])){logger['info'](_0xa2e8('0x13'),this[_0xa2e8('0x4')]['id'],_0x580ae1);}else{util[_0xa2e8('0x1c')](this['notificationId'],this[_0xa2e8('0x4')]['id'],this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x580ae1],this[_0xa2e8('0xe')],this[_0xa2e8('0x2')]);util[_0xa2e8('0x16')](this[_0xa2e8('0x4')]['id'],this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x580ae1],_0xdf0f7f?_0xa2e8('0x1d'):_0xa2e8('0x1e'));this[_0xa2e8('0x3')]['agents'][_0x580ae1][_0xa2e8('0x1f')]=![];this[_0xa2e8('0x3')][_0xa2e8('0x11')][_0x580ae1][_0xa2e8('0x18')]=undefined;}}}if(!_0xdf0f7f){setTimeout(this[_0xa2e8('0xb')][_0xa2e8('0x6')](this),0x3e8);}};function beepall(_0x347e53,_0x5f3402,_0x5e644c,_0x5755c4){return new Beepall(_0x347e53,_0x5f3402,_0x5e644c,_0x5755c4);}module['exports']=beepall;