Built motion from commit 87cd5f02.|2.5.48
[motion2.git] / server / services / xdr / agents.controller.js
index ec43a10..0fccfe0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x146f=['forIn','answered_elsewhere','[%s][agents][agentcomplete]','[%s][agents][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','agentcompleteAt','diffTime','complete','blindtransfer','transfereruniqueid','[%s][agents][blindtransfer]','[%s][agents][blindtransfer]\x20agent:%s\x20transferuniqueid:%s','transfer','blind','extension','transferuniqueid','origtransfereruniqueid','secondtransfereruniqueid','[%s][agents][attendedtransfer]\x20agent:%s','transfertype','ATTENDED','transferexten','origtransfererexten','transfereeuniqueid','agententerreason','clone','calleridname','transfertargetuniqueid','[%s][agents][attendedtransfer]','hangup','[%s][agents][hangup]','cause','rejected','indexOf','splice','agent','[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s','./utils','info','[%s][agents][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','channel','membername','calleridnum','connectedlinenum','queue','getVoiceQueueByName','then','type','agentacw','agentcomplete','acwtime','request','CreateVoiceAgentReport','uniqueid','destuniqueid','agentcalled','debug','[%s][agents][agentcalled]','agentcalledAt','now','called','connectedlinename','[%s][agents][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','error','agentringnoanswer','isNil','format','agentringnoanswerAt','lastevent','timeout','holdtime','ringtime','talktime','[%s][agents][agentringnoanswer]','queuecallerabandon','includes','[%s][agents][queuecallerabandon]','abandoned','reason','[%s][agents][agentconnect]','agentconnectAt'];(function(_0x36884e,_0x48008f){var _0x1cc367=function(_0x388a78){while(--_0x388a78){_0x36884e['push'](_0x36884e['shift']());}};_0x1cc367(++_0x48008f);}(_0x146f,0x164));var _0xf146=function(_0x4e21b8,_0x746758){_0x4e21b8=_0x4e21b8-0x0;var _0x18289c=_0x146f[_0x4e21b8];return _0x18289c;};'use strict';var _=require('lodash');var util=require('util');var utils=require(_0xf146('0x0'));var agents={};var transfers={};var unanswered=[];function writeDB(_0x283857,_0x44134f){utils[_0xf146('0x1')](util['format'](_0xf146('0x2'),_0x283857['uniqueid'],_0x283857[_0xf146('0x3')],_0x283857['queue'],_0x283857[_0xf146('0x4')],_0x283857['interface'],_0x283857[_0xf146('0x5')],_0x283857[_0xf146('0x6')],_0x283857['lastevent']));if(_0x283857[_0xf146('0x7')]){utils[_0xf146('0x8')](_0x283857[_0xf146('0x7')])[_0xf146('0x9')](function(_0x995dd5){if(_0x995dd5){_0x283857[_0xf146('0xa')]=_0x995dd5[_0xf146('0xa')];_0x283857[_0xf146('0xb')]=_0x283857[_0xf146('0xc')]?_0x995dd5['acw']:![];_0x283857[_0xf146('0xd')]=_0x283857[_0xf146('0xb')]?_0x995dd5['acwTimeout']:0x0;}utils[_0xf146('0xe')]('CreateVoiceAgentReport',_0x283857);});}else{utils[_0xf146('0xe')](_0xf146('0xf'),_0x283857);}if(_0x44134f){delete transfers[_0x283857[_0xf146('0x10')]];}else{delete agents[_0x283857[_0xf146('0x11')]];}}exports[_0xf146('0x12')]=function(_0x5bfe96){try{utils[_0xf146('0x13')](util['format'](_0xf146('0x14'),_0x5bfe96[_0xf146('0x10')]),_0x5bfe96);agents[_0x5bfe96[_0xf146('0x11')]]=_0x5bfe96;agents[_0x5bfe96['destuniqueid']][_0xf146('0x15')]=utils[_0xf146('0x16')]();agents[_0x5bfe96['destuniqueid']]['lastevent']=_0xf146('0x17');agents[_0x5bfe96['destuniqueid']][_0xf146('0x6')]=null;agents[_0x5bfe96[_0xf146('0x11')]][_0xf146('0x18')]=null;utils[_0xf146('0x1')](util['format'](_0xf146('0x19'),_0x5bfe96[_0xf146('0x10')],agents[_0x5bfe96[_0xf146('0x11')]][_0xf146('0x4')],_0x5bfe96['destuniqueid']));}catch(_0x2815fa){utils[_0xf146('0x1a')](util['format'](_0xf146('0x14'),_0x5bfe96[_0xf146('0x10')]),_0x2815fa);}};exports[_0xf146('0x1b')]=function(_0xa0f9e5){try{if(!_[_0xf146('0x1c')](agents[_0xa0f9e5['destuniqueid']])){utils[_0xf146('0x13')](util[_0xf146('0x1d')]('[%s][agents][agentringnoanswer]',_0xa0f9e5[_0xf146('0x10')]),_0xa0f9e5);utils[_0xf146('0x1')](util['format']('[%s][agents][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:timeout',_0xa0f9e5[_0xf146('0x10')],agents[_0xa0f9e5[_0xf146('0x11')]][_0xf146('0x4')],_0xa0f9e5[_0xf146('0x11')]));agents[_0xa0f9e5[_0xf146('0x11')]][_0xf146('0x1b')]=!![];agents[_0xa0f9e5['destuniqueid']][_0xf146('0x1e')]=utils[_0xf146('0x16')]();agents[_0xa0f9e5[_0xf146('0x11')]][_0xf146('0x1f')]=_0xf146('0x20');agents[_0xa0f9e5[_0xf146('0x11')]]['reason']=_0xf146('0x20');agents[_0xa0f9e5[_0xf146('0x11')]][_0xf146('0x21')]=_0xa0f9e5[_0xf146('0x22')]?parseInt(_0xa0f9e5[_0xf146('0x22')])/0x3e8:0x0;agents[_0xa0f9e5['destuniqueid']][_0xf146('0x23')]=0x0;unanswered['push'](_0xa0f9e5[_0xf146('0x11')]);}}catch(_0x88efbe){utils['error'](util[_0xf146('0x1d')](_0xf146('0x24'),_0xa0f9e5[_0xf146('0x10')]),_0x88efbe);}};exports[_0xf146('0x25')]=function(_0x29417e){try{_['forIn'](agents,function(_0x4e678f,_0x814671){if(_0x4e678f['uniqueid']==_0x29417e[_0xf146('0x10')]&&!_[_0xf146('0x26')](unanswered,_0x4e678f['destuniqueid'])){utils[_0xf146('0x13')](util[_0xf146('0x1d')](_0xf146('0x27'),_0x29417e[_0xf146('0x10')]),_0x29417e);utils['info'](util['format']('[%s][agents][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned',_0x29417e[_0xf146('0x10')],_0x4e678f['membername'],_0x4e678f['destuniqueid']));_0x4e678f[_0xf146('0x1b')]=!![];_0x4e678f[_0xf146('0x1e')]=utils['now']();_0x4e678f[_0xf146('0x1f')]=_0xf146('0x28');_0x4e678f[_0xf146('0x29')]=_0xf146('0x28');_0x4e678f[_0xf146('0x21')]=_0x29417e['holdtime'];_0x4e678f['talktime']=0x0;writeDB(_0x4e678f);}});}catch(_0x296775){utils[_0xf146('0x1a')](util['format'](_0xf146('0x27'),_0x29417e['uniqueid']),_0x296775);}};exports['agentconnect']=function(_0x27ceaa){try{if(agents[_0x27ceaa['destuniqueid']]){utils['debug'](util[_0xf146('0x1d')](_0xf146('0x2a'),_0x27ceaa[_0xf146('0x10')]),_0x27ceaa);utils['info'](util[_0xf146('0x1d')]('[%s][agents][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect',_0x27ceaa[_0xf146('0x10')],agents[_0x27ceaa[_0xf146('0x11')]][_0xf146('0x4')],_0x27ceaa[_0xf146('0x11')]));agents[_0x27ceaa[_0xf146('0x11')]][_0xf146('0x2b')]=utils[_0xf146('0x16')]();agents[_0x27ceaa[_0xf146('0x11')]][_0xf146('0x6')]=_0x27ceaa[_0xf146('0x6')];agents[_0x27ceaa['destuniqueid']][_0xf146('0x18')]=_0x27ceaa['connectedlinename'];agents[_0x27ceaa[_0xf146('0x11')]][_0xf146('0x21')]=_0x27ceaa[_0xf146('0x22')];agents[_0x27ceaa['destuniqueid']][_0xf146('0x1f')]='connect';_[_0xf146('0x2c')](agents,function(_0x263ba3,_0x4b98da){if(_0x263ba3[_0xf146('0x11')]!=_0x27ceaa[_0xf146('0x11')]&&_0x263ba3[_0xf146('0x10')]==_0x27ceaa[_0xf146('0x10')]){_0x263ba3[_0xf146('0x23')]=0x0;_0x263ba3[_0xf146('0x21')]=_0x27ceaa[_0xf146('0x22')];_0x263ba3[_0xf146('0x1b')]=!![];_0x263ba3[_0xf146('0x1e')]=utils[_0xf146('0x16')]();_0x263ba3['lastevent']=_0xf146('0x2d');_0x263ba3['reason']=_0xf146('0x2d');_0x263ba3['answeredelsewheredestinationuniqueid']=_0x27ceaa[_0xf146('0x11')];_0x263ba3['answeredelsewheremembername']=_0x27ceaa[_0xf146('0x4')];writeDB(_0x263ba3);}});}}catch(_0x4c16b7){utils[_0xf146('0x1a')](util[_0xf146('0x1d')](_0xf146('0x2a'),_0x27ceaa[_0xf146('0x10')]),_0x4c16b7);}};exports[_0xf146('0xc')]=function(_0x3e7a94){try{if(!_[_0xf146('0x1c')](agents[_0x3e7a94[_0xf146('0x11')]])){utils[_0xf146('0x13')](util[_0xf146('0x1d')](_0xf146('0x2e'),_0x3e7a94[_0xf146('0x10')]),_0x3e7a94);utils['info'](util[_0xf146('0x1d')](_0xf146('0x2f'),_0x3e7a94[_0xf146('0x10')],agents[_0x3e7a94['destuniqueid']][_0xf146('0x4')],_0x3e7a94[_0xf146('0x11')]));agents[_0x3e7a94[_0xf146('0x11')]][_0xf146('0xc')]=!![];agents[_0x3e7a94['destuniqueid']][_0xf146('0x30')]=utils[_0xf146('0x16')]();agents[_0x3e7a94[_0xf146('0x11')]][_0xf146('0x23')]=utils[_0xf146('0x31')](agents[_0x3e7a94[_0xf146('0x11')]][_0xf146('0x30')],agents[_0x3e7a94[_0xf146('0x11')]][_0xf146('0x2b')]);agents[_0x3e7a94[_0xf146('0x11')]][_0xf146('0x29')]=_0x3e7a94[_0xf146('0x29')];agents[_0x3e7a94['destuniqueid']][_0xf146('0x1f')]=_0xf146('0x32');writeDB(agents[_0x3e7a94['destuniqueid']]);}}catch(_0x1baf0f){utils[_0xf146('0x1a')](util[_0xf146('0x1d')](_0xf146('0x2e'),_0x3e7a94['uniqueid']),_0x1baf0f);}};exports[_0xf146('0x33')]=function(_0x4b67f2){try{if(!_[_0xf146('0x1c')](agents[_0x4b67f2[_0xf146('0x34')]])){utils[_0xf146('0x13')](util[_0xf146('0x1d')](_0xf146('0x35'),_0x4b67f2[_0xf146('0x10')]),_0x4b67f2);utils[_0xf146('0x1')](util['format'](_0xf146('0x36'),_0x4b67f2[_0xf146('0x10')],agents[_0x4b67f2[_0xf146('0x34')]][_0xf146('0x4')],agents[_0x4b67f2[_0xf146('0x34')]]['uniqueid']));agents[_0x4b67f2[_0xf146('0x34')]][_0xf146('0x37')]=!![];agents[_0x4b67f2[_0xf146('0x34')]]['transfertype']=_0xf146('0x38');agents[_0x4b67f2[_0xf146('0x34')]]['transferexten']=_0x4b67f2[_0xf146('0x39')];agents[_0x4b67f2['transfereruniqueid']][_0xf146('0x3a')]=agents[_0x4b67f2[_0xf146('0x34')]][_0xf146('0x10')];}}catch(_0x28ba38){utils[_0xf146('0x1a')](util[_0xf146('0x1d')](_0xf146('0x35'),_0x4b67f2[_0xf146('0x10')]),_0x28ba38);}};exports['attendedtransfer']=function(_0x5d1f8a){try{utils['debug'](util[_0xf146('0x1d')]('[%s][agents][attendedtransfer]',_0x5d1f8a['origtransfereruniqueid']),_0x5d1f8a);if(_0x5d1f8a[_0xf146('0x3b')]==_0x5d1f8a['origtransfererlinkedid']){if(!_[_0xf146('0x1c')](agents[_0x5d1f8a[_0xf146('0x3c')]])){utils['info'](util[_0xf146('0x1d')](_0xf146('0x3d'),_0x5d1f8a[_0xf146('0x3b')],agents[_0x5d1f8a['secondtransfereruniqueid']][_0xf146('0x4')]));agents[_0x5d1f8a['secondtransfereruniqueid']][_0xf146('0x37')]=!![];agents[_0x5d1f8a[_0xf146('0x3c')]][_0xf146('0x3e')]=_0xf146('0x3f');agents[_0x5d1f8a[_0xf146('0x3c')]][_0xf146('0x40')]=_0x5d1f8a[_0xf146('0x41')];agents[_0x5d1f8a[_0xf146('0x3c')]]['transferuniqueid']=_0x5d1f8a[_0xf146('0x3b')];}if(_0x5d1f8a[_0xf146('0x42')]&&agents[_0x5d1f8a[_0xf146('0x42')]]){agents[_0x5d1f8a[_0xf146('0x42')]][_0xf146('0x43')]=0x1;transfers[_0x5d1f8a[_0xf146('0x42')]]=_[_0xf146('0x44')](agents[_0x5d1f8a[_0xf146('0x42')]]);transfers[_0x5d1f8a['transfereeuniqueid']][_0xf146('0x5')]=agents[_0x5d1f8a['secondtransfereruniqueid']][_0xf146('0x5')];transfers[_0x5d1f8a[_0xf146('0x42')]][_0xf146('0x45')]=agents[_0x5d1f8a[_0xf146('0x3c')]]['calleridname'];transfers[_0x5d1f8a[_0xf146('0x42')]][_0xf146('0x15')]=utils['now']();transfers[_0x5d1f8a[_0xf146('0x42')]][_0xf146('0x2b')]=utils[_0xf146('0x16')]();transfers[_0x5d1f8a[_0xf146('0x42')]][_0xf146('0x21')]=0x0;transfers[_0x5d1f8a['transfereeuniqueid']][_0xf146('0x43')]=0x2;}}else if(_0x5d1f8a[_0xf146('0x3c')]==_0x5d1f8a['secondtransfererlinkedid']){if(!_[_0xf146('0x1c')](agents[_0x5d1f8a[_0xf146('0x3b')]])){utils[_0xf146('0x1')](util['format'](_0xf146('0x3d'),_0x5d1f8a[_0xf146('0x3b')],agents[_0x5d1f8a[_0xf146('0x3b')]][_0xf146('0x4')]));agents[_0x5d1f8a[_0xf146('0x3b')]]['transfer']=!![];agents[_0x5d1f8a[_0xf146('0x3b')]][_0xf146('0x3e')]=_0xf146('0x3f');agents[_0x5d1f8a[_0xf146('0x3b')]]['transferexten']=_0x5d1f8a['secondtransfererexten'];agents[_0x5d1f8a['origtransfereruniqueid']][_0xf146('0x3a')]=_0x5d1f8a['secondtransfereruniqueid'];}if(_0x5d1f8a['transfertargetuniqueid']&&agents[_0x5d1f8a[_0xf146('0x46')]]){agents[_0x5d1f8a[_0xf146('0x46')]][_0xf146('0x43')]=0x1;transfers[_0x5d1f8a[_0xf146('0x46')]]=_[_0xf146('0x44')](agents[_0x5d1f8a[_0xf146('0x46')]]);transfers[_0x5d1f8a[_0xf146('0x46')]]['calleridnum']=agents[_0x5d1f8a[_0xf146('0x3b')]][_0xf146('0x5')];transfers[_0x5d1f8a[_0xf146('0x46')]][_0xf146('0x45')]=agents[_0x5d1f8a[_0xf146('0x3b')]][_0xf146('0x45')];transfers[_0x5d1f8a[_0xf146('0x46')]][_0xf146('0x15')]=utils[_0xf146('0x16')]();transfers[_0x5d1f8a[_0xf146('0x46')]][_0xf146('0x2b')]=utils[_0xf146('0x16')]();transfers[_0x5d1f8a[_0xf146('0x46')]][_0xf146('0x21')]=0x0;transfers[_0x5d1f8a[_0xf146('0x46')]]['agententerreason']=0x2;}}}catch(_0x3d8428){utils[_0xf146('0x1a')](util[_0xf146('0x1d')](_0xf146('0x47'),_0x5d1f8a['origtransfereruniqueid']),_0x3d8428);}};exports[_0xf146('0x48')]=function(_0x2fe0f4){try{utils['debug'](util[_0xf146('0x1d')](_0xf146('0x49'),_0x2fe0f4[_0xf146('0x10')]),_0x2fe0f4);if(agents[_0x2fe0f4[_0xf146('0x10')]]&&agents[_0x2fe0f4['uniqueid']][_0xf146('0x29')]===_0xf146('0x20')){if(_0x2fe0f4[_0xf146('0x4a')]==='21'){agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x29')]=_0xf146('0x4b');agents[_0x2fe0f4['uniqueid']][_0xf146('0x1f')]=_0xf146('0x4b');}utils[_0xf146('0x1')](util[_0xf146('0x1d')]('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x2fe0f4[_0xf146('0x10')],agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x4')],agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x29')],agents[_0x2fe0f4['uniqueid']][_0xf146('0x1f')]));writeDB(agents[_0x2fe0f4[_0xf146('0x10')]]);var _0x400a8f=unanswered[_0xf146('0x4c')](_0x2fe0f4['uniqueid']);if(_0x400a8f>-0x1){unanswered[_0xf146('0x4d')](_0x400a8f,0x1);}}if(transfers[_0x2fe0f4[_0xf146('0x10')]]){transfers[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0xc')]=!![];transfers[_0x2fe0f4['uniqueid']][_0xf146('0x30')]=utils['now']();transfers[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x23')]=utils[_0xf146('0x31')](transfers[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x30')],transfers[_0x2fe0f4['uniqueid']]['agentconnectAt']);transfers[_0x2fe0f4[_0xf146('0x10')]]['reason']=_0xf146('0x4e');transfers[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x1f')]=_0xf146('0x32');utils[_0xf146('0x1')](util['format']('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x2fe0f4[_0xf146('0x10')],transfers[_0x2fe0f4['uniqueid']][_0xf146('0x4')],transfers[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x29')],transfers[_0x2fe0f4['uniqueid']][_0xf146('0x1f')]));writeDB(transfers[_0x2fe0f4[_0xf146('0x10')]],!![]);}if(agents[_0x2fe0f4['uniqueid']]&&agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x2b')]){agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0xc')]=!![];agents[_0x2fe0f4[_0xf146('0x10')]]['agentcompleteAt']=utils[_0xf146('0x16')]();agents[_0x2fe0f4[_0xf146('0x10')]]['talktime']=utils[_0xf146('0x31')](agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x30')],agents[_0x2fe0f4['uniqueid']][_0xf146('0x2b')]);agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x29')]=agents[_0x2fe0f4[_0xf146('0x10')]]['transfer']?_0xf146('0x37'):'agent';agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x1f')]=_0xf146('0x32');utils['info'](util['format'](_0xf146('0x4f'),_0x2fe0f4[_0xf146('0x10')],agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x4')],agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x29')],agents[_0x2fe0f4[_0xf146('0x10')]][_0xf146('0x1f')]));writeDB(agents[_0x2fe0f4[_0xf146('0x10')]]);}}catch(_0x2c99ea){utils[_0xf146('0x1a')](util[_0xf146('0x1d')](_0xf146('0x49'),_0x2fe0f4[_0xf146('0x10')]),_0x2c99ea);}};
\ No newline at end of file
+var _0x2bc6=['lastevent','getVoiceQueueByName','then','type','agentcomplete','acw','acwtime','acwTimeout','request','CreateVoiceAgentReport','uniqueid','destuniqueid','debug','[%s][agents][agentcalled]','agentcalledAt','now','called','connectedlinename','info','format','[%s][agents][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','membername','[%s][agents][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:timeout','agentringnoanswer','agentringnoanswerAt','reason','timeout','holdtime','ringtime','push','[%s][agents][agentringnoanswer]','queuecallerabandon','forIn','includes','[%s][agents][queuecallerabandon]','[%s][agents][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned','abandoned','error','[%s][agents][agentconnect]','[%s][agents][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','talktime','answered_elsewhere','answeredelsewheredestinationuniqueid','answeredelsewheremembername','isNil','[%s][agents][agentcomplete]','diffTime','complete','blindtransfer','transfereruniqueid','[%s][agents][blindtransfer]','transfertype','blind','transferexten','extension','transferuniqueid','attendedtransfer','[%s][agents][attendedtransfer]','origtransfereruniqueid','origtransfererlinkedid','secondtransfereruniqueid','[%s][agents][attendedtransfer]\x20agent:%s','transfer','ATTENDED','origtransfererexten','transfereeuniqueid','clone','calleridname','agententerreason','secondtransfererlinkedid','secondtransfererexten','transfertargetuniqueid','hangup','[%s][agents][hangup]','cause','rejected','indexOf','splice','agentcompleteAt','agent','[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s','lodash','util','./utils','[%s][agents][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','channel','queue','interface','calleridnum','connectedlinenum'];(function(_0x1bc33e,_0x1f6479){var _0x2ebee8=function(_0x50c6c2){while(--_0x50c6c2){_0x1bc33e['push'](_0x1bc33e['shift']());}};_0x2ebee8(++_0x1f6479);}(_0x2bc6,0x163));var _0x62bc=function(_0x3bd608,_0x4983d3){_0x3bd608=_0x3bd608-0x0;var _0x538339=_0x2bc6[_0x3bd608];return _0x538339;};'use strict';var _=require(_0x62bc('0x0'));var util=require(_0x62bc('0x1'));var utils=require(_0x62bc('0x2'));var agents={};var transfers={};var unanswered=[];function writeDB(_0x56939b,_0x4b4e73){utils['info'](util['format'](_0x62bc('0x3'),_0x56939b['uniqueid'],_0x56939b[_0x62bc('0x4')],_0x56939b[_0x62bc('0x5')],_0x56939b['membername'],_0x56939b[_0x62bc('0x6')],_0x56939b[_0x62bc('0x7')],_0x56939b[_0x62bc('0x8')],_0x56939b[_0x62bc('0x9')]));if(_0x56939b[_0x62bc('0x5')]){utils[_0x62bc('0xa')](_0x56939b['queue'])[_0x62bc('0xb')](function(_0x762c71){if(_0x762c71){_0x56939b[_0x62bc('0xc')]=_0x762c71[_0x62bc('0xc')];_0x56939b['agentacw']=_0x56939b[_0x62bc('0xd')]?_0x762c71[_0x62bc('0xe')]:![];_0x56939b[_0x62bc('0xf')]=_0x56939b['agentacw']?_0x762c71[_0x62bc('0x10')]:0x0;}utils[_0x62bc('0x11')](_0x62bc('0x12'),_0x56939b);});}else{utils[_0x62bc('0x11')](_0x62bc('0x12'),_0x56939b);}if(_0x4b4e73){delete transfers[_0x56939b[_0x62bc('0x13')]];}else{delete agents[_0x56939b[_0x62bc('0x14')]];}}exports['agentcalled']=function(_0x2a96ae){try{utils[_0x62bc('0x15')](util['format'](_0x62bc('0x16'),_0x2a96ae[_0x62bc('0x13')]),_0x2a96ae);agents[_0x2a96ae[_0x62bc('0x14')]]=_0x2a96ae;agents[_0x2a96ae['destuniqueid']][_0x62bc('0x17')]=utils[_0x62bc('0x18')]();agents[_0x2a96ae['destuniqueid']]['lastevent']=_0x62bc('0x19');agents[_0x2a96ae[_0x62bc('0x14')]]['connectedlinenum']=null;agents[_0x2a96ae[_0x62bc('0x14')]][_0x62bc('0x1a')]=null;utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')](_0x62bc('0x1d'),_0x2a96ae[_0x62bc('0x13')],agents[_0x2a96ae[_0x62bc('0x14')]][_0x62bc('0x1e')],_0x2a96ae[_0x62bc('0x14')]));}catch(_0x5ed51c){utils['error'](util[_0x62bc('0x1c')](_0x62bc('0x16'),_0x2a96ae[_0x62bc('0x13')]),_0x5ed51c);}};exports['agentringnoanswer']=function(_0x380621){try{if(!_['isNil'](agents[_0x380621[_0x62bc('0x14')]])){utils[_0x62bc('0x15')](util[_0x62bc('0x1c')]('[%s][agents][agentringnoanswer]',_0x380621[_0x62bc('0x13')]),_0x380621);utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')](_0x62bc('0x1f'),_0x380621[_0x62bc('0x13')],agents[_0x380621[_0x62bc('0x14')]]['membername'],_0x380621[_0x62bc('0x14')]));agents[_0x380621[_0x62bc('0x14')]][_0x62bc('0x20')]=!![];agents[_0x380621[_0x62bc('0x14')]][_0x62bc('0x21')]=utils['now']();agents[_0x380621['destuniqueid']][_0x62bc('0x9')]='timeout';agents[_0x380621[_0x62bc('0x14')]][_0x62bc('0x22')]=_0x62bc('0x23');agents[_0x380621['destuniqueid']][_0x62bc('0x24')]=_0x380621[_0x62bc('0x25')]?parseInt(_0x380621[_0x62bc('0x25')])/0x3e8:0x0;agents[_0x380621['destuniqueid']]['talktime']=0x0;unanswered[_0x62bc('0x26')](_0x380621[_0x62bc('0x14')]);}}catch(_0x23817c){utils['error'](util[_0x62bc('0x1c')](_0x62bc('0x27'),_0x380621[_0x62bc('0x13')]),_0x23817c);}};exports[_0x62bc('0x28')]=function(_0x5a9302){try{_[_0x62bc('0x29')](agents,function(_0x5e4491,_0x26701b){if(_0x5e4491[_0x62bc('0x13')]==_0x5a9302[_0x62bc('0x13')]&&!_[_0x62bc('0x2a')](unanswered,_0x5e4491[_0x62bc('0x14')])){utils[_0x62bc('0x15')](util[_0x62bc('0x1c')](_0x62bc('0x2b'),_0x5a9302[_0x62bc('0x13')]),_0x5a9302);utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')](_0x62bc('0x2c'),_0x5a9302[_0x62bc('0x13')],_0x5e4491[_0x62bc('0x1e')],_0x5e4491[_0x62bc('0x14')]));_0x5e4491[_0x62bc('0x20')]=!![];_0x5e4491[_0x62bc('0x21')]=utils['now']();_0x5e4491[_0x62bc('0x9')]='abandoned';_0x5e4491['reason']=_0x62bc('0x2d');_0x5e4491['holdtime']=_0x5a9302['holdtime'];_0x5e4491['talktime']=0x0;writeDB(_0x5e4491);}});}catch(_0x3f22c1){utils[_0x62bc('0x2e')](util[_0x62bc('0x1c')]('[%s][agents][queuecallerabandon]',_0x5a9302['uniqueid']),_0x3f22c1);}};exports['agentconnect']=function(_0x3c938d){try{if(agents[_0x3c938d[_0x62bc('0x14')]]){utils['debug'](util['format'](_0x62bc('0x2f'),_0x3c938d[_0x62bc('0x13')]),_0x3c938d);utils[_0x62bc('0x1b')](util['format'](_0x62bc('0x30'),_0x3c938d[_0x62bc('0x13')],agents[_0x3c938d[_0x62bc('0x14')]][_0x62bc('0x1e')],_0x3c938d['destuniqueid']));agents[_0x3c938d[_0x62bc('0x14')]][_0x62bc('0x31')]=utils['now']();agents[_0x3c938d[_0x62bc('0x14')]][_0x62bc('0x8')]=_0x3c938d[_0x62bc('0x8')];agents[_0x3c938d[_0x62bc('0x14')]]['connectedlinename']=_0x3c938d[_0x62bc('0x1a')];agents[_0x3c938d['destuniqueid']][_0x62bc('0x24')]=_0x3c938d[_0x62bc('0x25')];agents[_0x3c938d[_0x62bc('0x14')]][_0x62bc('0x9')]='connect';_[_0x62bc('0x29')](agents,function(_0x5c806b,_0x392550){if(_0x5c806b[_0x62bc('0x14')]!=_0x3c938d[_0x62bc('0x14')]&&_0x5c806b[_0x62bc('0x13')]==_0x3c938d[_0x62bc('0x13')]){_0x5c806b[_0x62bc('0x32')]=0x0;_0x5c806b[_0x62bc('0x24')]=_0x3c938d[_0x62bc('0x25')];_0x5c806b[_0x62bc('0x20')]=!![];_0x5c806b['agentringnoanswerAt']=utils['now']();_0x5c806b[_0x62bc('0x9')]=_0x62bc('0x33');_0x5c806b['reason']=_0x62bc('0x33');_0x5c806b[_0x62bc('0x34')]=_0x3c938d[_0x62bc('0x14')];_0x5c806b[_0x62bc('0x35')]=_0x3c938d[_0x62bc('0x1e')];writeDB(_0x5c806b);}});}}catch(_0x5f3752){utils[_0x62bc('0x2e')](util[_0x62bc('0x1c')]('[%s][agents][agentconnect]',_0x3c938d['uniqueid']),_0x5f3752);}};exports[_0x62bc('0xd')]=function(_0xdbd9ee){try{if(!_[_0x62bc('0x36')](agents[_0xdbd9ee['destuniqueid']])){utils[_0x62bc('0x15')](util[_0x62bc('0x1c')](_0x62bc('0x37'),_0xdbd9ee[_0x62bc('0x13')]),_0xdbd9ee);utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')]('[%s][agents][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0xdbd9ee[_0x62bc('0x13')],agents[_0xdbd9ee['destuniqueid']][_0x62bc('0x1e')],_0xdbd9ee[_0x62bc('0x14')]));agents[_0xdbd9ee[_0x62bc('0x14')]]['agentcomplete']=!![];agents[_0xdbd9ee['destuniqueid']]['agentcompleteAt']=utils[_0x62bc('0x18')]();agents[_0xdbd9ee['destuniqueid']][_0x62bc('0x32')]=utils[_0x62bc('0x38')](agents[_0xdbd9ee['destuniqueid']]['agentcompleteAt'],agents[_0xdbd9ee['destuniqueid']][_0x62bc('0x31')]);agents[_0xdbd9ee[_0x62bc('0x14')]][_0x62bc('0x22')]=_0xdbd9ee[_0x62bc('0x22')];agents[_0xdbd9ee[_0x62bc('0x14')]]['lastevent']=_0x62bc('0x39');writeDB(agents[_0xdbd9ee[_0x62bc('0x14')]]);}}catch(_0x4859fc){utils[_0x62bc('0x2e')](util['format'](_0x62bc('0x37'),_0xdbd9ee[_0x62bc('0x13')]),_0x4859fc);}};exports[_0x62bc('0x3a')]=function(_0xca6190){try{if(!_[_0x62bc('0x36')](agents[_0xca6190[_0x62bc('0x3b')]])){utils[_0x62bc('0x15')](util['format'](_0x62bc('0x3c'),_0xca6190[_0x62bc('0x13')]),_0xca6190);utils['info'](util[_0x62bc('0x1c')]('[%s][agents][blindtransfer]\x20agent:%s\x20transferuniqueid:%s',_0xca6190[_0x62bc('0x13')],agents[_0xca6190[_0x62bc('0x3b')]]['membername'],agents[_0xca6190[_0x62bc('0x3b')]][_0x62bc('0x13')]));agents[_0xca6190[_0x62bc('0x3b')]]['transfer']=!![];agents[_0xca6190[_0x62bc('0x3b')]][_0x62bc('0x3d')]=_0x62bc('0x3e');agents[_0xca6190[_0x62bc('0x3b')]][_0x62bc('0x3f')]=_0xca6190[_0x62bc('0x40')];agents[_0xca6190[_0x62bc('0x3b')]][_0x62bc('0x41')]=agents[_0xca6190[_0x62bc('0x3b')]][_0x62bc('0x13')];}}catch(_0x44d2a2){utils[_0x62bc('0x2e')](util[_0x62bc('0x1c')](_0x62bc('0x3c'),_0xca6190[_0x62bc('0x13')]),_0x44d2a2);}};exports[_0x62bc('0x42')]=function(_0x5b0e9b){try{utils[_0x62bc('0x15')](util[_0x62bc('0x1c')](_0x62bc('0x43'),_0x5b0e9b[_0x62bc('0x44')]),_0x5b0e9b);if(_0x5b0e9b[_0x62bc('0x44')]==_0x5b0e9b[_0x62bc('0x45')]){if(!_[_0x62bc('0x36')](agents[_0x5b0e9b[_0x62bc('0x46')]])){utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')](_0x62bc('0x47'),_0x5b0e9b[_0x62bc('0x44')],agents[_0x5b0e9b['secondtransfereruniqueid']][_0x62bc('0x1e')]));agents[_0x5b0e9b['secondtransfereruniqueid']][_0x62bc('0x48')]=!![];agents[_0x5b0e9b[_0x62bc('0x46')]][_0x62bc('0x3d')]=_0x62bc('0x49');agents[_0x5b0e9b[_0x62bc('0x46')]][_0x62bc('0x3f')]=_0x5b0e9b[_0x62bc('0x4a')];agents[_0x5b0e9b[_0x62bc('0x46')]]['transferuniqueid']=_0x5b0e9b['origtransfereruniqueid'];}if(_0x5b0e9b[_0x62bc('0x4b')]&&agents[_0x5b0e9b[_0x62bc('0x4b')]]){agents[_0x5b0e9b[_0x62bc('0x4b')]]['agententerreason']=0x1;transfers[_0x5b0e9b[_0x62bc('0x4b')]]=_[_0x62bc('0x4c')](agents[_0x5b0e9b[_0x62bc('0x4b')]]);transfers[_0x5b0e9b[_0x62bc('0x4b')]]['calleridnum']=agents[_0x5b0e9b[_0x62bc('0x46')]][_0x62bc('0x7')];transfers[_0x5b0e9b[_0x62bc('0x4b')]][_0x62bc('0x4d')]=agents[_0x5b0e9b[_0x62bc('0x46')]][_0x62bc('0x4d')];transfers[_0x5b0e9b[_0x62bc('0x4b')]]['agentcalledAt']=utils[_0x62bc('0x18')]();transfers[_0x5b0e9b[_0x62bc('0x4b')]][_0x62bc('0x31')]=utils['now']();transfers[_0x5b0e9b['transfereeuniqueid']][_0x62bc('0x24')]=0x0;transfers[_0x5b0e9b[_0x62bc('0x4b')]][_0x62bc('0x4e')]=0x2;}}else if(_0x5b0e9b['secondtransfereruniqueid']==_0x5b0e9b[_0x62bc('0x4f')]){if(!_['isNil'](agents[_0x5b0e9b[_0x62bc('0x44')]])){utils[_0x62bc('0x1b')](util['format'](_0x62bc('0x47'),_0x5b0e9b['origtransfereruniqueid'],agents[_0x5b0e9b[_0x62bc('0x44')]]['membername']));agents[_0x5b0e9b[_0x62bc('0x44')]][_0x62bc('0x48')]=!![];agents[_0x5b0e9b[_0x62bc('0x44')]][_0x62bc('0x3d')]=_0x62bc('0x49');agents[_0x5b0e9b[_0x62bc('0x44')]]['transferexten']=_0x5b0e9b[_0x62bc('0x50')];agents[_0x5b0e9b[_0x62bc('0x44')]][_0x62bc('0x41')]=_0x5b0e9b['secondtransfereruniqueid'];}if(_0x5b0e9b[_0x62bc('0x51')]&&agents[_0x5b0e9b[_0x62bc('0x51')]]){agents[_0x5b0e9b[_0x62bc('0x51')]][_0x62bc('0x4e')]=0x1;transfers[_0x5b0e9b['transfertargetuniqueid']]=_[_0x62bc('0x4c')](agents[_0x5b0e9b[_0x62bc('0x51')]]);transfers[_0x5b0e9b[_0x62bc('0x51')]][_0x62bc('0x7')]=agents[_0x5b0e9b[_0x62bc('0x44')]]['calleridnum'];transfers[_0x5b0e9b['transfertargetuniqueid']][_0x62bc('0x4d')]=agents[_0x5b0e9b['origtransfereruniqueid']][_0x62bc('0x4d')];transfers[_0x5b0e9b[_0x62bc('0x51')]]['agentcalledAt']=utils[_0x62bc('0x18')]();transfers[_0x5b0e9b['transfertargetuniqueid']][_0x62bc('0x31')]=utils['now']();transfers[_0x5b0e9b[_0x62bc('0x51')]]['holdtime']=0x0;transfers[_0x5b0e9b[_0x62bc('0x51')]][_0x62bc('0x4e')]=0x2;}}}catch(_0x6bb64b){utils['error'](util[_0x62bc('0x1c')](_0x62bc('0x43'),_0x5b0e9b[_0x62bc('0x44')]),_0x6bb64b);}};exports[_0x62bc('0x52')]=function(_0x177fba){try{utils['debug'](util[_0x62bc('0x1c')](_0x62bc('0x53'),_0x177fba[_0x62bc('0x13')]),_0x177fba);if(agents[_0x177fba[_0x62bc('0x13')]]&&agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x22')]===_0x62bc('0x23')){if(_0x177fba[_0x62bc('0x54')]==='21'){agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x22')]=_0x62bc('0x55');agents[_0x177fba['uniqueid']][_0x62bc('0x9')]=_0x62bc('0x55');}utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')]('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x177fba[_0x62bc('0x13')],agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x1e')],agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x22')],agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x9')]));writeDB(agents[_0x177fba[_0x62bc('0x13')]]);var _0x5698a4=unanswered[_0x62bc('0x56')](_0x177fba[_0x62bc('0x13')]);if(_0x5698a4>-0x1){unanswered[_0x62bc('0x57')](_0x5698a4,0x1);}}if(transfers[_0x177fba[_0x62bc('0x13')]]){transfers[_0x177fba[_0x62bc('0x13')]][_0x62bc('0xd')]=!![];transfers[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x58')]=utils[_0x62bc('0x18')]();transfers[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x32')]=utils[_0x62bc('0x38')](transfers[_0x177fba['uniqueid']][_0x62bc('0x58')],transfers[_0x177fba[_0x62bc('0x13')]]['agentconnectAt']);transfers[_0x177fba[_0x62bc('0x13')]]['reason']=_0x62bc('0x59');transfers[_0x177fba[_0x62bc('0x13')]]['lastevent']=_0x62bc('0x39');utils['info'](util[_0x62bc('0x1c')]('[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s',_0x177fba[_0x62bc('0x13')],transfers[_0x177fba['uniqueid']][_0x62bc('0x1e')],transfers[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x22')],transfers[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x9')]));writeDB(transfers[_0x177fba[_0x62bc('0x13')]],!![]);}if(agents[_0x177fba['uniqueid']]&&agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x31')]){agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0xd')]=!![];agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x58')]=utils[_0x62bc('0x18')]();agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x32')]=utils[_0x62bc('0x38')](agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x58')],agents[_0x177fba[_0x62bc('0x13')]]['agentconnectAt']);agents[_0x177fba['uniqueid']]['reason']=agents[_0x177fba[_0x62bc('0x13')]]['transfer']?_0x62bc('0x48'):_0x62bc('0x59');agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x9')]=_0x62bc('0x39');utils[_0x62bc('0x1b')](util[_0x62bc('0x1c')](_0x62bc('0x5a'),_0x177fba['uniqueid'],agents[_0x177fba[_0x62bc('0x13')]][_0x62bc('0x1e')],agents[_0x177fba[_0x62bc('0x13')]]['reason'],agents[_0x177fba[_0x62bc('0x13')]]['lastevent']));writeDB(agents[_0x177fba[_0x62bc('0x13')]]);}}catch(_0x3aa295){utils['error'](util[_0x62bc('0x1c')](_0x62bc('0x53'),_0x177fba['uniqueid']),_0x3aa295);}};
\ No newline at end of file