Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / routing / server / applications / strategy / agent.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 _0xbec5=['bind','handleTimeout','drained','handleDrained','prototype','debug','[%s][AGENT]\x20try\x20with\x20%s','isNil','realtime','agents','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','forcedOwnership','isAgentAvailable','busy','saveWaitingNotification','channel','showNotification','writeLog','RINGING','[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available','[%s][AGENT]\x20timeout\x20with\x20%s','hideNotification','busyQueue','removeWaitingNotification','STOP','lodash','uuid','../../../../../config/logger','routing','notificationId','squeue','agent','push','handleRun'];(function(_0x4fce10,_0x596096){var _0x180848=function(_0x26c514){while(--_0x26c514){_0x4fce10['push'](_0x4fce10['shift']());}};_0x180848(++_0x596096);}(_0xbec5,0xe5));var _0x5bec=function(_0x5cb1af,_0x4bdc8c){_0x5cb1af=_0x5cb1af-0x0;var _0x8d7940=_0xbec5[_0x5cb1af];return _0x8d7940;};'use strict';var _=require(_0x5bec('0x0'));var uuid=require(_0x5bec('0x1'));var util=require('./util');var logger=require(_0x5bec('0x2'))(_0x5bec('0x3'));var Agent=function(_0x276b9e,_0x3859a1,_0x244027,_0x4ee982){this[_0x5bec('0x4')]=uuid['v4']();this[_0x5bec('0x5')]=_0x276b9e;this[_0x5bec('0x6')]=_0x3859a1;this['realtime']=_0x244027;this[_0x5bec('0x3')]=_0x4ee982;this[_0x5bec('0x5')][_0x5bec('0x7')](this[_0x5bec('0x8')][_0x5bec('0x9')](this),this[_0x5bec('0xa')][_0x5bec('0x9')](this));this[_0x5bec('0x5')]['on']('timeout',this[_0x5bec('0xa')]['bind'](this));this[_0x5bec('0x5')]['on'](_0x5bec('0xb'),this[_0x5bec('0xc')]['bind'](this));};Agent[_0x5bec('0xd')][_0x5bec('0x7')]=function(){this[_0x5bec('0x5')]['push'](this[_0x5bec('0x8')][_0x5bec('0x9')](this),this['handleTimeout'][_0x5bec('0x9')](this));};Agent[_0x5bec('0xd')][_0x5bec('0xc')]=function(){this[_0x5bec('0xa')](!![]);};Agent[_0x5bec('0xd')][_0x5bec('0x8')]=function(){logger[_0x5bec('0xe')](_0x5bec('0xf'),this[_0x5bec('0x5')]['id'],this[_0x5bec('0x6')]['id']);if(_[_0x5bec('0x10')](this[_0x5bec('0x11')][_0x5bec('0x12')][this['agent']['id']])){logger['debug'](_0x5bec('0x13'),this[_0x5bec('0x5')]['id'],this[_0x5bec('0x6')]['id']);setTimeout(this[_0x5bec('0x7')]['bind'](this),0x3e8);}else{if(this['routing'][_0x5bec('0x14')]||util[_0x5bec('0x15')](this['squeue']['id'],this[_0x5bec('0x11')][_0x5bec('0x12')][this[_0x5bec('0x6')]['id']],this[_0x5bec('0x5')]['channel'],![])){this[_0x5bec('0x11')]['agents'][this[_0x5bec('0x6')]['id']][_0x5bec('0x16')]=!![];this[_0x5bec('0x11')][_0x5bec('0x12')][this[_0x5bec('0x6')]['id']]['busyQueue']=undefined;util[_0x5bec('0x17')](this['realtime'],this[_0x5bec('0x3')],this[_0x5bec('0x6')],this['squeue'][_0x5bec('0x18')]);util[_0x5bec('0x19')](this['notificationId'],this[_0x5bec('0x5')]['id'],this[_0x5bec('0x11')][_0x5bec('0x12')][this[_0x5bec('0x6')]['id']],null,this[_0x5bec('0x3')]);util[_0x5bec('0x1a')](this[_0x5bec('0x5')]['id'],this['realtime']['agents'][this['agent']['id']],_0x5bec('0x1b')+(this[_0x5bec('0x3')][_0x5bec('0x14')]?':FORCED':''));}else{logger[_0x5bec('0xe')](_0x5bec('0x1c'),this['squeue']['id'],this[_0x5bec('0x6')]['id']);setTimeout(this[_0x5bec('0x7')]['bind'](this),0x3e8);}}};Agent['prototype'][_0x5bec('0xa')]=function(_0x2a82d5){if(_[_0x5bec('0x10')](this[_0x5bec('0x11')][_0x5bec('0x12')][this[_0x5bec('0x6')]['id']])){return logger['debug'](_0x5bec('0x13'),this['squeue']['id'],this[_0x5bec('0x6')]['id']);}else{logger[_0x5bec('0xe')](_0x5bec('0x1d'),this[_0x5bec('0x5')]['id'],this['agent']['id']);util[_0x5bec('0x1e')](this[_0x5bec('0x4')],this[_0x5bec('0x5')]['id'],this['realtime'][_0x5bec('0x12')][this['agent']['id']],null,this[_0x5bec('0x3')]);this[_0x5bec('0x11')][_0x5bec('0x12')][this['agent']['id']][_0x5bec('0x16')]=![];this[_0x5bec('0x11')]['agents'][this[_0x5bec('0x6')]['id']][_0x5bec('0x1f')]=undefined;util[_0x5bec('0x20')](this[_0x5bec('0x11')],this[_0x5bec('0x3')],this['agent'],this[_0x5bec('0x5')]['channel']);util[_0x5bec('0x1a')](this[_0x5bec('0x5')]['id'],this[_0x5bec('0x11')][_0x5bec('0x12')][this[_0x5bec('0x6')]['id']],_0x2a82d5?_0x5bec('0x21'):'TIMEOUT');}if(!_0x2a82d5){setTimeout(this[_0x5bec('0x7')][_0x5bec('0x9')](this),0x3e8);}};function agent(_0x1d42b0,_0x5de683,_0x40db29,_0x355707){return new Agent(_0x1d42b0,_0x5de683,_0x40db29,_0x355707);}module['exports']=agent;