Built motion from commit (unavailable).|2.4.6
[motion2.git] / server / services / routing / server / applications / strategy / rrmemory.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 _0x2a92=['exports','./util','../../../../../config/logger','routing','queue','realtime','squeue','push','handleRun','bind','module','timeout','drained','handleDrained','prototype','handleTimeout','handleCheckReject','isAgentAvailable','agents','agentId','[%s][QUEUE]\x20available\x20again\x20%s','intervals','done','[%s][QUEUE]\x20try\x20with\x20%s','isNil','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','busyQueue','name','showNotification','writeLog','[%s][QUEUE]\x20timeout\x20with\x20%s','hideNotification','busy'];(function(_0x4174a3,_0x51e7cf){var _0x323d14=function(_0x4daef6){while(--_0x4daef6){_0x4174a3['push'](_0x4174a3['shift']());}};_0x323d14(++_0x51e7cf);}(_0x2a92,0x182));var _0x22a9=function(_0x27efcf,_0x320952){_0x27efcf=_0x27efcf-0x0;var _0xdb0237=_0x2a92[_0x27efcf];return _0xdb0237;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require('uuid');var util=require(_0x22a9('0x0'));var logger=require(_0x22a9('0x1'))(_0x22a9('0x2'));var RRMemory=function(_0x5d3416,_0x2334de,_0x764c3d,_0x30911b){this['notificationId']=uuid['v4']();this['squeue']=_0x5d3416;this[_0x22a9('0x3')]=_0x2334de;this[_0x22a9('0x4')]=_0x764c3d;this[_0x22a9('0x2')]=_0x30911b;this['intervals']={};this[_0x22a9('0x5')][_0x22a9('0x6')](this[_0x22a9('0x7')][_0x22a9('0x8')](this),this['handleTimeout'][_0x22a9('0x8')](this),this[_0x22a9('0x9')]);this[_0x22a9('0x5')]['on'](_0x22a9('0xa'),this['handleTimeout'][_0x22a9('0x8')](this));this[_0x22a9('0x5')]['on'](_0x22a9('0xb'),this[_0x22a9('0xc')][_0x22a9('0x8')](this));};RRMemory[_0x22a9('0xd')]['push']=function(){this['squeue'][_0x22a9('0x6')](this[_0x22a9('0x7')]['bind'](this),this[_0x22a9('0xe')][_0x22a9('0x8')](this));};RRMemory[_0x22a9('0xd')][_0x22a9('0xc')]=function(_0x15b165){this[_0x22a9('0xe')](!![]);};RRMemory[_0x22a9('0xd')][_0x22a9('0xf')]=function(_0x178d63){if(util[_0x22a9('0x10')](this[_0x22a9('0x5')]['id'],this[_0x22a9('0x4')][_0x22a9('0x11')][this[_0x22a9('0x12')]],this[_0x22a9('0x5')]['channel'],!![])){logger['info'](_0x22a9('0x13'),this['squeue']['id'],this['agentId']);clearInterval(this[_0x22a9('0x14')][this['agentId']]);_0x178d63[_0x22a9('0x15')]();setTimeout(this[_0x22a9('0x6')][_0x22a9('0x8')](this),0x3e8);}};RRMemory[_0x22a9('0xd')][_0x22a9('0x7')]=function(_0x535b30){this[_0x22a9('0x12')]=rr(this['queue']['mapAgentsId']);logger['info'](_0x22a9('0x16'),this['squeue']['id'],this[_0x22a9('0x12')]);if(_[_0x22a9('0x17')](this[_0x22a9('0x4')][_0x22a9('0x11')][this[_0x22a9('0x12')]])){logger[_0x22a9('0x18')](_0x22a9('0x19'),this[_0x22a9('0x5')]['id'],this[_0x22a9('0x12')]);_0x535b30[_0x22a9('0x15')]();setTimeout(this[_0x22a9('0x6')][_0x22a9('0x8')](this),0x3e8);}else{if(util[_0x22a9('0x10')](this['squeue']['id'],this[_0x22a9('0x4')]['agents'][this['agentId']],this[_0x22a9('0x5')][_0x22a9('0x1a')],!![])){this[_0x22a9('0x4')][_0x22a9('0x11')][this[_0x22a9('0x12')]]['busy']=!![];this[_0x22a9('0x4')][_0x22a9('0x11')][this['agentId']][_0x22a9('0x1b')]=this[_0x22a9('0x3')][_0x22a9('0x1c')];util[_0x22a9('0x1d')](this['notificationId'],this[_0x22a9('0x5')]['id'],this[_0x22a9('0x4')][_0x22a9('0x11')][this['agentId']],this[_0x22a9('0x3')],this[_0x22a9('0x2')]);util[_0x22a9('0x1e')](this[_0x22a9('0x5')]['id'],this[_0x22a9('0x4')][_0x22a9('0x11')][this['agentId']],'RINGING');this[_0x22a9('0x14')][this[_0x22a9('0x12')]]=setInterval(this['handleCheckReject']['bind'](this,_0x535b30),0x3e8);}else{logger[_0x22a9('0x18')]('[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s',this[_0x22a9('0x5')]['id'],this['agentId']);_0x535b30[_0x22a9('0x15')]();setTimeout(this['push'][_0x22a9('0x8')](this),0x3e8);}}};RRMemory[_0x22a9('0xd')][_0x22a9('0xe')]=function(_0x135323){logger[_0x22a9('0x18')](_0x22a9('0x1f'),this[_0x22a9('0x5')]['id'],this[_0x22a9('0x12')]);if(_[_0x22a9('0x17')](this[_0x22a9('0x4')][_0x22a9('0x11')][this[_0x22a9('0x12')]])){logger[_0x22a9('0x18')](_0x22a9('0x19'),this[_0x22a9('0x5')]['id'],this[_0x22a9('0x12')]);}else{clearInterval(this[_0x22a9('0x14')][this[_0x22a9('0x12')]]);util[_0x22a9('0x20')](this['notificationId'],this[_0x22a9('0x5')]['id'],this[_0x22a9('0x4')][_0x22a9('0x11')][this[_0x22a9('0x12')]],this[_0x22a9('0x3')],this[_0x22a9('0x2')]);util[_0x22a9('0x1e')](this[_0x22a9('0x5')]['id'],this[_0x22a9('0x4')]['agents'][this[_0x22a9('0x12')]],'TIMEOUT');this['realtime'][_0x22a9('0x11')][this[_0x22a9('0x12')]][_0x22a9('0x21')]=![];this[_0x22a9('0x4')]['agents'][this['agentId']][_0x22a9('0x1b')]=undefined;}if(!_0x135323){setTimeout(this['push'][_0x22a9('0x8')](this),0x3e8);}};function rrmemory(_0x43e0d2,_0x3416bf,_0x2ea13e,_0xdd2846){return new RRMemory(_0x43e0d2,_0x3416bf,_0x2ea13e,_0xdd2846);}module[_0x22a9('0x22')]=rrmemory;