Built motion from commit (unavailable).|2.4.17
[motion2.git] / server / services / routing / server / applications / 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 _0xf79d=['find','agents','timeout','createQueue','atimeout','channel','rules','end','close','info','[%s][AGENT]\x20ROUTING\x20END','agent','error','[%s][AGENT]\x20agent\x20not\x20found\x20%s','log','[%s][QUEUE]\x20%s','stack','validate','lodash','util','seq-queue','routing','./strategy','string','name\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','format','[%s][AGENT][NAME:%s][STATUS:%s]','name','toLowerCase','consequence','length','map','message','join','stop'];(function(_0xace943,_0x463bbc){var _0x3ec4ab=function(_0x2c6a3a){while(--_0x2c6a3a){_0xace943['push'](_0xace943['shift']());}};_0x3ec4ab(++_0x463bbc);}(_0xf79d,0x155));var _0xdf79=function(_0x25042f,_0x30e488){_0x25042f=_0x25042f-0x0;var _0x2ddc20=_0xf79d[_0x25042f];return _0x2ddc20;};'use strict';var schema=require(_0xdf79('0x0'));var _=require(_0xdf79('0x1'));var util=require(_0xdf79('0x2'));var seqqueue=require(_0xdf79('0x3'));var logger=require('../../../../config/logger')(_0xdf79('0x4'));var strategy=require(_0xdf79('0x5'));var queue=schema({'name':{'type':_0xdf79('0x6'),'required':!![],'message':_0xdf79('0x7')},'timeout':{'type':_0xdf79('0x8'),'message':'timeout\x20is\x20a\x20number'}});function writeLog(_0x2f469e,_0x96721,_0x28b03b){return logger['info'](util[_0xdf79('0x9')](_0xdf79('0xa'),_0x2f469e,_0x96721[_0xdf79('0xb')],_0x28b03b));}function handleFindAgent(_0x329136){return function(_0x3c1a18){return _0x3c1a18[_0xdf79('0xb')][_0xdf79('0xc')]()===_0x329136[_0xdf79('0xc')]();};}exports[_0xdf79('0xd')]=function(_0x498022,_0x1efb94,_0x2431a,_0x33b448){return function(_0xc4c07d){try{var _0x22925d={'name':_0x1efb94[0x0],'timeout':_0x1efb94[0x1]};var _0x1d5a08=queue[_0xdf79('0x0')](_0x22925d,{'typecast':!![]});if(_0x1d5a08[_0xdf79('0xe')]){logger['error']('[%s][AGENT]\x20%s',_0x498022,_[_0xdf79('0xf')](_0x1d5a08,_0xdf79('0x10'))[_0xdf79('0x11')](',\x20'));_0xc4c07d[_0xdf79('0x12')]();}else{var _0x3508ba=_[_0xdf79('0x13')](_0x2431a[_0xdf79('0x14')],handleFindAgent(_0x22925d[_0xdf79('0xb')]));if(_0x3508ba){var _0x2d03c5=(_0x22925d[_0xdf79('0x15')]||0xa)*0x3e8;var _0x2ddd2b,_0x5daee8;var _0xf45882=seqqueue[_0xdf79('0x16')](_0x2d03c5);_0xf45882['id']=_0x498022;_0xf45882[_0xdf79('0x17')]=_0x2d03c5;_0xf45882['channel']=_0x33b448[_0xdf79('0x18')];writeLog(_0x498022,_0x3508ba,util[_0xdf79('0x9')]('START:%s',_0x2d03c5));_0x2431a[_0xdf79('0x19')][_0x498022]['on'](_0xdf79('0x1a'),function(){_0xf45882[_0xdf79('0x1b')]();clearTimeout(_0x5daee8);_0x5daee8=undefined;if(_0x2431a['rules'][_0x498022]){delete _0x2431a[_0xdf79('0x19')][_0x498022];}logger['info']('[%s][AGENT]\x20ROUTING\x20STOPPED',_0x498022);_0xc4c07d[_0xdf79('0x12')]();});_0x5daee8=setTimeout(function(){clearTimeout(_0x5daee8);_0xf45882[_0xdf79('0x1b')]();logger[_0xdf79('0x1c')](_0xdf79('0x1d'),_0x498022);_0xc4c07d['next']();},_0x2d03c5);strategy[_0xdf79('0x1e')](_0xf45882,_0x3508ba,_0x2431a,_0x33b448);}else{logger[_0xdf79('0x1f')](_0xdf79('0x20'),_0x498022,_0x22925d[_0xdf79('0xb')]);_0xc4c07d[_0xdf79('0x12')]();}}}catch(_0x3d1f7e){console[_0xdf79('0x21')](_0x3d1f7e);logger[_0xdf79('0x1f')](_0xdf79('0x22'),_0x498022,_0x3d1f7e[_0xdf79('0x23')]);_0xc4c07d[_0xdf79('0x12')]();}};};