Built motion from commit 44b1f254.|2.6.26
[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 _0x295c=['busy','busyQueue','name','saveWaitingNotification','channel','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','debug','[%s][QUEUE]\x20EMPTY','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','writeLog','STOP','../../../../../config/logger','realtime','routing','squeue','handleRun','bind','timeout','handleTimeout','drained','handleDrained','push','prototype','isNil','queue','Agents','length','agents','isAgentAvailable','RINGING'];(function(_0x11ba46,_0x1d6752){var _0x1c8c6f=function(_0x4cf96f){while(--_0x4cf96f){_0x11ba46['push'](_0x11ba46['shift']());}};_0x1c8c6f(++_0x1d6752);}(_0x295c,0x69));var _0xc295=function(_0x31a2b8,_0xafe1cc){_0x31a2b8=_0x31a2b8-0x0;var _0x393c26=_0x295c[_0x31a2b8];return _0x393c26;};'use strict';var _=require('lodash');var uuid=require('uuid');var util=require('./util');var logger=require(_0xc295('0x0'))('routing');var Beepall=function(_0x48769f,_0x125d21,_0x522480,_0x1d5fea){this['notificationId']=uuid['v4']();this['squeue']=_0x48769f;this['queue']=_0x125d21;this[_0xc295('0x1')]=_0x522480;this[_0xc295('0x2')]=_0x1d5fea;this[_0xc295('0x3')]['push'](this[_0xc295('0x4')]['bind'](this),this['handleTimeout'][_0xc295('0x5')](this));this[_0xc295('0x3')]['on'](_0xc295('0x6'),this[_0xc295('0x7')][_0xc295('0x5')](this));this[_0xc295('0x3')]['on'](_0xc295('0x8'),this[_0xc295('0x9')]['bind'](this));};Beepall['prototype'][_0xc295('0xa')]=function(){this[_0xc295('0x3')][_0xc295('0xa')](this[_0xc295('0x4')][_0xc295('0x5')](this),this[_0xc295('0x7')][_0xc295('0x5')](this));};Beepall[_0xc295('0xb')]['handleDrained']=function(){this[_0xc295('0x7')](!![]);};Beepall[_0xc295('0xb')][_0xc295('0x4')]=function(){var _0x29134e=!![];if(!_[_0xc295('0xc')](this[_0xc295('0xd')])&&!_['isNil'](this[_0xc295('0xd')][_0xc295('0xe')])&&this[_0xc295('0xd')][_0xc295('0xe')][_0xc295('0xf')]>0x0){for(var _0x2e73b4=0x0,_0xb3c254;_0x2e73b4<this[_0xc295('0xd')]['Agents']['length'];_0x2e73b4+=0x1){_0xb3c254=this['queue'][_0xc295('0xe')][_0x2e73b4]['id'];if(_['isNil'](this[_0xc295('0x1')][_0xc295('0x10')][_0xb3c254])){logger['debug']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],_0xb3c254);}else{if(util[_0xc295('0x11')](this['squeue']['id'],this[_0xc295('0x1')][_0xc295('0x10')][_0xb3c254],this['squeue']['channel'],!![])){_0x29134e=![];util['writeLog'](this[_0xc295('0x3')]['id'],this['realtime']['agents'][_0xb3c254],_0xc295('0x12'));this[_0xc295('0x1')][_0xc295('0x10')][_0xb3c254][_0xc295('0x13')]=!![];this['realtime'][_0xc295('0x10')][_0xb3c254][_0xc295('0x14')]=this[_0xc295('0xd')][_0xc295('0x15')];util[_0xc295('0x16')](this['realtime'],this[_0xc295('0x2')],this['queue'][_0xc295('0xe')][_0x2e73b4],this[_0xc295('0x3')][_0xc295('0x17')]);util['showNotification'](this[_0xc295('0x18')],this[_0xc295('0x3')]['id'],this[_0xc295('0x1')][_0xc295('0x10')][_0xb3c254],this['queue'],this[_0xc295('0x2')]);}}}if(_0x29134e){logger['debug'](_0xc295('0x19'),this[_0xc295('0x3')]['id']);setTimeout(this[_0xc295('0xa')]['bind'](this),0x3e8);}}else{logger[_0xc295('0x1a')](_0xc295('0x1b'),this[_0xc295('0x3')]['id']);setTimeout(this[_0xc295('0xa')][_0xc295('0x5')](this),0x3e8);}};Beepall['prototype'][_0xc295('0x7')]=function(_0x2d06c0){if(!_['isNil'](this[_0xc295('0xd')])&&!_['isNil'](this['queue'][_0xc295('0xe')])){for(var _0x2ea028=0x0,_0x2586cd;_0x2ea028<this[_0xc295('0xd')][_0xc295('0xe')]['length'];_0x2ea028+=0x1){_0x2586cd=this['queue'][_0xc295('0xe')][_0x2ea028]['id'];if(_[_0xc295('0xc')](this[_0xc295('0x1')]['agents'][_0x2586cd])){logger[_0xc295('0x1a')](_0xc295('0x1c'),this[_0xc295('0x3')]['id'],_0x2586cd);}else{util['hideNotification'](this[_0xc295('0x18')],this[_0xc295('0x3')]['id'],this['realtime'][_0xc295('0x10')][_0x2586cd],this[_0xc295('0xd')],this[_0xc295('0x2')]);util[_0xc295('0x1d')](this[_0xc295('0x3')]['id'],this[_0xc295('0x1')][_0xc295('0x10')][_0x2586cd],_0x2d06c0?_0xc295('0x1e'):'TIMEOUT');this[_0xc295('0x1')][_0xc295('0x10')][_0x2586cd][_0xc295('0x13')]=![];this[_0xc295('0x1')][_0xc295('0x10')][_0x2586cd][_0xc295('0x14')]=undefined;util['removeWaitingNotification'](this[_0xc295('0x1')],this['routing'],this[_0xc295('0x1')][_0xc295('0x10')][_0x2586cd],this[_0xc295('0x3')]['channel']);}}}if(!_0x2d06c0){setTimeout(this[_0xc295('0xa')][_0xc295('0x5')](this),0x3e8);}};function beepall(_0x29f1b3,_0x59bf33,_0x11af2e,_0x12e2f5){return new Beepall(_0x29f1b3,_0x59bf33,_0x11af2e,_0x12e2f5);}module['exports']=beepall;