Built motion from commit (unavailable).|2.5.6
[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 _0x41bc=['exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','agent','handleRun','bind','timeout','drained','handleDrained','prototype','push','handleTimeout','[%s][AGENT]\x20try\x20with\x20%s','isNil','realtime','agents','forcedOwnership','channel','busy','busyQueue','writeLog','RINGING','info','[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','[%s][AGENT]\x20timeout\x20with\x20%s','hideNotification','STOP','TIMEOUT'];(function(_0xe5442a,_0x2bc5d6){var _0x25688b=function(_0x57eae5){while(--_0x57eae5){_0xe5442a['push'](_0xe5442a['shift']());}};_0x25688b(++_0x2bc5d6);}(_0x41bc,0xef));var _0xc41b=function(_0x49d43f,_0x343f74){_0x49d43f=_0x49d43f-0x0;var _0x4abc1d=_0x41bc[_0x49d43f];return _0x4abc1d;};'use strict';var _=require(_0xc41b('0x0'));var uuid=require(_0xc41b('0x1'));var util=require(_0xc41b('0x2'));var logger=require(_0xc41b('0x3'))(_0xc41b('0x4'));var Agent=function(_0x127cec,_0x3a1b29,_0x3e001a,_0x46fc90){this[_0xc41b('0x5')]=uuid['v4']();this[_0xc41b('0x6')]=_0x127cec;this[_0xc41b('0x7')]=_0x3a1b29;this['realtime']=_0x3e001a;this[_0xc41b('0x4')]=_0x46fc90;this['squeue']['push'](this[_0xc41b('0x8')][_0xc41b('0x9')](this),this['handleTimeout']['bind'](this));this[_0xc41b('0x6')]['on'](_0xc41b('0xa'),this['handleTimeout']['bind'](this));this['squeue']['on'](_0xc41b('0xb'),this[_0xc41b('0xc')][_0xc41b('0x9')](this));};Agent[_0xc41b('0xd')][_0xc41b('0xe')]=function(){this['squeue']['push'](this[_0xc41b('0x8')]['bind'](this),this[_0xc41b('0xf')][_0xc41b('0x9')](this));};Agent[_0xc41b('0xd')][_0xc41b('0xc')]=function(){this[_0xc41b('0xf')](!![]);};Agent[_0xc41b('0xd')][_0xc41b('0x8')]=function(_0x3968a5){logger['info'](_0xc41b('0x10'),this[_0xc41b('0x6')]['id'],this['agent']['id']);if(_[_0xc41b('0x11')](this[_0xc41b('0x12')][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']])){logger['info']('[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xc41b('0x6')]['id'],this['agent']['id']);setTimeout(this[_0xc41b('0xe')][_0xc41b('0x9')](this),0x3e8);}else{if(this[_0xc41b('0x4')][_0xc41b('0x14')]||util['isAgentAvailable'](this[_0xc41b('0x6')]['id'],this[_0xc41b('0x12')]['agents'][this['agent']['id']],this[_0xc41b('0x6')][_0xc41b('0x15')],![])){this['realtime'][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']][_0xc41b('0x16')]=!![];this[_0xc41b('0x12')][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']][_0xc41b('0x17')]=undefined;util['showNotification'](this['notificationId'],this['squeue']['id'],this[_0xc41b('0x12')][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']],null,this[_0xc41b('0x4')]);util[_0xc41b('0x18')](this[_0xc41b('0x6')]['id'],this['realtime'][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']],_0xc41b('0x19')+(this['routing'][_0xc41b('0x14')]?':FORCED':''));}else{logger[_0xc41b('0x1a')](_0xc41b('0x1b'),this[_0xc41b('0x6')]['id'],this['agent']['id']);setTimeout(this[_0xc41b('0xe')]['bind'](this),0x3e8);}}};Agent[_0xc41b('0xd')][_0xc41b('0xf')]=function(_0x491868){if(_[_0xc41b('0x11')](this[_0xc41b('0x12')]['agents'][this[_0xc41b('0x7')]['id']])){return logger[_0xc41b('0x1a')](_0xc41b('0x1c'),this['squeue']['id'],this[_0xc41b('0x7')]['id']);}else{logger['info'](_0xc41b('0x1d'),this['squeue']['id'],this[_0xc41b('0x7')]['id']);util[_0xc41b('0x1e')](this[_0xc41b('0x5')],this[_0xc41b('0x6')]['id'],this['realtime'][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']],null,this[_0xc41b('0x4')]);this[_0xc41b('0x12')][_0xc41b('0x13')][this['agent']['id']][_0xc41b('0x16')]=![];this[_0xc41b('0x12')][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']][_0xc41b('0x17')]=undefined;util['writeLog'](this[_0xc41b('0x6')]['id'],this[_0xc41b('0x12')][_0xc41b('0x13')][this[_0xc41b('0x7')]['id']],_0x491868?_0xc41b('0x1f'):_0xc41b('0x20'));}if(!_0x491868){setTimeout(this[_0xc41b('0xe')][_0xc41b('0x9')](this),0x3e8);}};function agent(_0x13a555,_0x4434d0,_0x113e57,_0x2db201){return new Agent(_0x13a555,_0x4434d0,_0x113e57,_0x2db201);}module[_0xc41b('0x21')]=agent;