Built motion from commit 87cd5f02.|2.5.48
[motion2.git] / server / services / xdr / agents.controller.js
index d065976..0fccfe0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbfc0=['complete','blindtransfer','transfereruniqueid','[%s][agents][blindtransfer]','transfer','transfertype','transferexten','attendedtransfer','[%s][agents][attendedtransfer]','origtransfereruniqueid','origtransfererlinkedid','secondtransfereruniqueid','[%s][agents][attendedtransfer]\x20agent:%s','origtransfererexten','transferuniqueid','transfereeuniqueid','clone','calleridname','agententerreason','secondtransfererlinkedid','transfertargetuniqueid','hangup','cause','rejected','[%s][agents][hangup]\x20agent:%s\x20reason:%s\x20lastevent:%s','indexOf','splice','diffTime','agent','lodash','./utils','info','format','[%s][agents][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','uniqueid','channel','queue','membername','interface','calleridnum','lastevent','type','agentacw','acwTimeout','request','CreateVoiceAgentReport','agentcalled','debug','[%s][agents][agentcalled]','destuniqueid','agentcalledAt','now','called','connectedlinenum','connectedlinename','[%s][agents][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','error','isNil','[%s][agents][agentringnoanswer]','[%s][agents][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:timeout','agentringnoanswer','reason','timeout','holdtime','ringtime','push','queuecallerabandon','forIn','includes','[%s][agents][queuecallerabandon]','[%s][agents][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned','agentringnoanswerAt','abandoned','talktime','[%s][agents][agentconnect]','agentconnectAt','connect','answered_elsewhere','answeredelsewheredestinationuniqueid','answeredelsewheremembername','agentcomplete','[%s][agents][agentcomplete]','[%s][agents][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','agentcompleteAt'];(function(_0x1f0fd8,_0x18b7c6){var _0x34ffa0=function(_0x45a44e){while(--_0x45a44e){_0x1f0fd8['push'](_0x1f0fd8['shift']());}};_0x34ffa0(++_0x18b7c6);}(_0xbfc0,0x119));var _0x0bfc=function(_0x559a80,_0x3d193d){_0x559a80=_0x559a80-0x0;var _0x42f555=_0xbfc0[_0x559a80];return _0x42f555;};'use strict';var _=require(_0x0bfc('0x0'));var util=require('util');var utils=require(_0x0bfc('0x1'));var agents={};var transfers={};var unanswered=[];function writeDB(_0x51c7fd,_0x4ea4cb){utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x4'),_0x51c7fd[_0x0bfc('0x5')],_0x51c7fd[_0x0bfc('0x6')],_0x51c7fd[_0x0bfc('0x7')],_0x51c7fd[_0x0bfc('0x8')],_0x51c7fd[_0x0bfc('0x9')],_0x51c7fd[_0x0bfc('0xa')],_0x51c7fd['connectedlinenum'],_0x51c7fd[_0x0bfc('0xb')]));if(_0x51c7fd[_0x0bfc('0x7')]){utils['getVoiceQueueByName'](_0x51c7fd['queue'])['then'](function(_0x1cd1a1){if(_0x1cd1a1){_0x51c7fd['type']=_0x1cd1a1[_0x0bfc('0xc')];_0x51c7fd['agentacw']=_0x51c7fd['agentcomplete']?_0x1cd1a1['acw']:![];_0x51c7fd['acwtime']=_0x51c7fd[_0x0bfc('0xd')]?_0x1cd1a1[_0x0bfc('0xe')]:0x0;}utils[_0x0bfc('0xf')](_0x0bfc('0x10'),_0x51c7fd);});}else{utils[_0x0bfc('0xf')](_0x0bfc('0x10'),_0x51c7fd);}if(_0x4ea4cb){delete transfers[_0x51c7fd[_0x0bfc('0x5')]];}else{delete agents[_0x51c7fd['destuniqueid']];}}exports[_0x0bfc('0x11')]=function(_0x56d1e9){try{utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x13'),_0x56d1e9[_0x0bfc('0x5')]),_0x56d1e9);agents[_0x56d1e9[_0x0bfc('0x14')]]=_0x56d1e9;agents[_0x56d1e9[_0x0bfc('0x14')]][_0x0bfc('0x15')]=utils[_0x0bfc('0x16')]();agents[_0x56d1e9[_0x0bfc('0x14')]][_0x0bfc('0xb')]=_0x0bfc('0x17');agents[_0x56d1e9['destuniqueid']][_0x0bfc('0x18')]=null;agents[_0x56d1e9[_0x0bfc('0x14')]][_0x0bfc('0x19')]=null;utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x1a'),_0x56d1e9['uniqueid'],agents[_0x56d1e9[_0x0bfc('0x14')]]['membername'],_0x56d1e9[_0x0bfc('0x14')]));}catch(_0x172996){utils[_0x0bfc('0x1b')](util[_0x0bfc('0x3')]('[%s][agents][agentcalled]',_0x56d1e9[_0x0bfc('0x5')]),_0x172996);}};exports['agentringnoanswer']=function(_0x46e0fa){try{if(!_[_0x0bfc('0x1c')](agents[_0x46e0fa['destuniqueid']])){utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x1d'),_0x46e0fa['uniqueid']),_0x46e0fa);utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x1e'),_0x46e0fa[_0x0bfc('0x5')],agents[_0x46e0fa[_0x0bfc('0x14')]][_0x0bfc('0x8')],_0x46e0fa[_0x0bfc('0x14')]));agents[_0x46e0fa[_0x0bfc('0x14')]][_0x0bfc('0x1f')]=!![];agents[_0x46e0fa[_0x0bfc('0x14')]]['agentringnoanswerAt']=utils[_0x0bfc('0x16')]();agents[_0x46e0fa[_0x0bfc('0x14')]][_0x0bfc('0xb')]='timeout';agents[_0x46e0fa[_0x0bfc('0x14')]][_0x0bfc('0x20')]=_0x0bfc('0x21');agents[_0x46e0fa[_0x0bfc('0x14')]][_0x0bfc('0x22')]=_0x46e0fa['ringtime']?parseInt(_0x46e0fa[_0x0bfc('0x23')])/0x3e8:0x0;agents[_0x46e0fa[_0x0bfc('0x14')]]['talktime']=0x0;unanswered[_0x0bfc('0x24')](_0x46e0fa['destuniqueid']);}}catch(_0x30d8c6){utils[_0x0bfc('0x1b')](util[_0x0bfc('0x3')](_0x0bfc('0x1d'),_0x46e0fa[_0x0bfc('0x5')]),_0x30d8c6);}};exports[_0x0bfc('0x25')]=function(_0x568530){try{_[_0x0bfc('0x26')](agents,function(_0x3580de,_0xe7d050){if(_0x3580de[_0x0bfc('0x5')]==_0x568530[_0x0bfc('0x5')]&&!_[_0x0bfc('0x27')](unanswered,_0x3580de[_0x0bfc('0x14')])){utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x28'),_0x568530['uniqueid']),_0x568530);utils['info'](util[_0x0bfc('0x3')](_0x0bfc('0x29'),_0x568530['uniqueid'],_0x3580de[_0x0bfc('0x8')],_0x3580de[_0x0bfc('0x14')]));_0x3580de['agentringnoanswer']=!![];_0x3580de[_0x0bfc('0x2a')]=utils[_0x0bfc('0x16')]();_0x3580de['lastevent']=_0x0bfc('0x2b');_0x3580de[_0x0bfc('0x20')]=_0x0bfc('0x2b');_0x3580de[_0x0bfc('0x22')]=_0x568530[_0x0bfc('0x22')];_0x3580de[_0x0bfc('0x2c')]=0x0;writeDB(_0x3580de);}});}catch(_0x4f69eb){utils['error'](util['format'](_0x0bfc('0x28'),_0x568530['uniqueid']),_0x4f69eb);}};exports['agentconnect']=function(_0x500d9f){try{if(agents[_0x500d9f[_0x0bfc('0x14')]]){utils['debug'](util[_0x0bfc('0x3')](_0x0bfc('0x2d'),_0x500d9f[_0x0bfc('0x5')]),_0x500d9f);utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')]('[%s][agents][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect',_0x500d9f[_0x0bfc('0x5')],agents[_0x500d9f['destuniqueid']][_0x0bfc('0x8')],_0x500d9f[_0x0bfc('0x14')]));agents[_0x500d9f[_0x0bfc('0x14')]][_0x0bfc('0x2e')]=utils['now']();agents[_0x500d9f[_0x0bfc('0x14')]][_0x0bfc('0x18')]=_0x500d9f[_0x0bfc('0x18')];agents[_0x500d9f[_0x0bfc('0x14')]][_0x0bfc('0x19')]=_0x500d9f['connectedlinename'];agents[_0x500d9f[_0x0bfc('0x14')]][_0x0bfc('0x22')]=_0x500d9f['ringtime'];agents[_0x500d9f[_0x0bfc('0x14')]][_0x0bfc('0xb')]=_0x0bfc('0x2f');_[_0x0bfc('0x26')](agents,function(_0xb98bd,_0x323a41){if(_0xb98bd['destuniqueid']!=_0x500d9f['destuniqueid']&&_0xb98bd[_0x0bfc('0x5')]==_0x500d9f['uniqueid']){_0xb98bd['talktime']=0x0;_0xb98bd[_0x0bfc('0x22')]=_0x500d9f[_0x0bfc('0x23')];_0xb98bd['agentringnoanswer']=!![];_0xb98bd[_0x0bfc('0x2a')]=utils[_0x0bfc('0x16')]();_0xb98bd[_0x0bfc('0xb')]=_0x0bfc('0x30');_0xb98bd['reason']=_0x0bfc('0x30');_0xb98bd[_0x0bfc('0x31')]=_0x500d9f['destuniqueid'];_0xb98bd[_0x0bfc('0x32')]=_0x500d9f['membername'];writeDB(_0xb98bd);}});}}catch(_0x144293){utils['error'](util[_0x0bfc('0x3')](_0x0bfc('0x2d'),_0x500d9f[_0x0bfc('0x5')]),_0x144293);}};exports[_0x0bfc('0x33')]=function(_0x1b356a){try{if(!_[_0x0bfc('0x1c')](agents[_0x1b356a[_0x0bfc('0x14')]])){utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x34'),_0x1b356a[_0x0bfc('0x5')]),_0x1b356a);utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x35'),_0x1b356a[_0x0bfc('0x5')],agents[_0x1b356a['destuniqueid']][_0x0bfc('0x8')],_0x1b356a['destuniqueid']));agents[_0x1b356a[_0x0bfc('0x14')]]['agentcomplete']=!![];agents[_0x1b356a[_0x0bfc('0x14')]][_0x0bfc('0x36')]=utils[_0x0bfc('0x16')]();agents[_0x1b356a[_0x0bfc('0x14')]][_0x0bfc('0x2c')]=utils['diffTime'](agents[_0x1b356a[_0x0bfc('0x14')]][_0x0bfc('0x36')],agents[_0x1b356a[_0x0bfc('0x14')]][_0x0bfc('0x2e')]);agents[_0x1b356a['destuniqueid']][_0x0bfc('0x20')]=_0x1b356a[_0x0bfc('0x20')];agents[_0x1b356a[_0x0bfc('0x14')]][_0x0bfc('0xb')]=_0x0bfc('0x37');writeDB(agents[_0x1b356a[_0x0bfc('0x14')]]);}}catch(_0x395e7b){utils[_0x0bfc('0x1b')](util[_0x0bfc('0x3')](_0x0bfc('0x34'),_0x1b356a[_0x0bfc('0x5')]),_0x395e7b);}};exports[_0x0bfc('0x38')]=function(_0x1541e3){try{if(!_[_0x0bfc('0x1c')](agents[_0x1541e3[_0x0bfc('0x39')]])){utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x3a'),_0x1541e3[_0x0bfc('0x5')]),_0x1541e3);utils['info'](util['format']('[%s][agents][blindtransfer]\x20agent:%s\x20transferuniqueid:%s',_0x1541e3[_0x0bfc('0x5')],agents[_0x1541e3[_0x0bfc('0x39')]]['membername'],agents[_0x1541e3['transfereruniqueid']]['uniqueid']));agents[_0x1541e3[_0x0bfc('0x39')]][_0x0bfc('0x3b')]=!![];agents[_0x1541e3[_0x0bfc('0x39')]][_0x0bfc('0x3c')]='blind';agents[_0x1541e3['transfereruniqueid']][_0x0bfc('0x3d')]=_0x1541e3['extension'];agents[_0x1541e3[_0x0bfc('0x39')]]['transferuniqueid']=agents[_0x1541e3[_0x0bfc('0x39')]][_0x0bfc('0x5')];}}catch(_0x5ce136){utils[_0x0bfc('0x1b')](util[_0x0bfc('0x3')]('[%s][agents][blindtransfer]',_0x1541e3[_0x0bfc('0x5')]),_0x5ce136);}};exports[_0x0bfc('0x3e')]=function(_0x21d1c6){try{utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')](_0x0bfc('0x3f'),_0x21d1c6[_0x0bfc('0x40')]),_0x21d1c6);if(_0x21d1c6[_0x0bfc('0x40')]==_0x21d1c6[_0x0bfc('0x41')]){if(!_[_0x0bfc('0x1c')](agents[_0x21d1c6[_0x0bfc('0x42')]])){utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x43'),_0x21d1c6['origtransfereruniqueid'],agents[_0x21d1c6['secondtransfereruniqueid']][_0x0bfc('0x8')]));agents[_0x21d1c6[_0x0bfc('0x42')]]['transfer']=!![];agents[_0x21d1c6['secondtransfereruniqueid']]['transfertype']='ATTENDED';agents[_0x21d1c6[_0x0bfc('0x42')]]['transferexten']=_0x21d1c6[_0x0bfc('0x44')];agents[_0x21d1c6[_0x0bfc('0x42')]][_0x0bfc('0x45')]=_0x21d1c6['origtransfereruniqueid'];}if(_0x21d1c6[_0x0bfc('0x46')]&&agents[_0x21d1c6[_0x0bfc('0x46')]]){agents[_0x21d1c6['transfereeuniqueid']]['agententerreason']=0x1;transfers[_0x21d1c6[_0x0bfc('0x46')]]=_[_0x0bfc('0x47')](agents[_0x21d1c6[_0x0bfc('0x46')]]);transfers[_0x21d1c6['transfereeuniqueid']][_0x0bfc('0xa')]=agents[_0x21d1c6[_0x0bfc('0x42')]][_0x0bfc('0xa')];transfers[_0x21d1c6[_0x0bfc('0x46')]][_0x0bfc('0x48')]=agents[_0x21d1c6[_0x0bfc('0x42')]]['calleridname'];transfers[_0x21d1c6[_0x0bfc('0x46')]]['agentcalledAt']=utils['now']();transfers[_0x21d1c6[_0x0bfc('0x46')]][_0x0bfc('0x2e')]=utils[_0x0bfc('0x16')]();transfers[_0x21d1c6[_0x0bfc('0x46')]][_0x0bfc('0x22')]=0x0;transfers[_0x21d1c6[_0x0bfc('0x46')]][_0x0bfc('0x49')]=0x2;}}else if(_0x21d1c6[_0x0bfc('0x42')]==_0x21d1c6[_0x0bfc('0x4a')]){if(!_[_0x0bfc('0x1c')](agents[_0x21d1c6[_0x0bfc('0x40')]])){utils[_0x0bfc('0x2')](util['format'](_0x0bfc('0x43'),_0x21d1c6[_0x0bfc('0x40')],agents[_0x21d1c6['origtransfereruniqueid']][_0x0bfc('0x8')]));agents[_0x21d1c6['origtransfereruniqueid']][_0x0bfc('0x3b')]=!![];agents[_0x21d1c6['origtransfereruniqueid']]['transfertype']='ATTENDED';agents[_0x21d1c6[_0x0bfc('0x40')]][_0x0bfc('0x3d')]=_0x21d1c6['secondtransfererexten'];agents[_0x21d1c6['origtransfereruniqueid']][_0x0bfc('0x45')]=_0x21d1c6[_0x0bfc('0x42')];}if(_0x21d1c6[_0x0bfc('0x4b')]&&agents[_0x21d1c6[_0x0bfc('0x4b')]]){agents[_0x21d1c6['transfertargetuniqueid']][_0x0bfc('0x49')]=0x1;transfers[_0x21d1c6[_0x0bfc('0x4b')]]=_[_0x0bfc('0x47')](agents[_0x21d1c6[_0x0bfc('0x4b')]]);transfers[_0x21d1c6[_0x0bfc('0x4b')]][_0x0bfc('0xa')]=agents[_0x21d1c6[_0x0bfc('0x40')]][_0x0bfc('0xa')];transfers[_0x21d1c6[_0x0bfc('0x4b')]][_0x0bfc('0x48')]=agents[_0x21d1c6[_0x0bfc('0x40')]]['calleridname'];transfers[_0x21d1c6['transfertargetuniqueid']][_0x0bfc('0x15')]=utils['now']();transfers[_0x21d1c6[_0x0bfc('0x4b')]][_0x0bfc('0x2e')]=utils[_0x0bfc('0x16')]();transfers[_0x21d1c6[_0x0bfc('0x4b')]][_0x0bfc('0x22')]=0x0;transfers[_0x21d1c6['transfertargetuniqueid']]['agententerreason']=0x2;}}}catch(_0x2ca6a5){utils[_0x0bfc('0x1b')](util['format'](_0x0bfc('0x3f'),_0x21d1c6[_0x0bfc('0x40')]),_0x2ca6a5);}};exports[_0x0bfc('0x4c')]=function(_0x1ac82d){try{utils[_0x0bfc('0x12')](util[_0x0bfc('0x3')]('[%s][agents][hangup]',_0x1ac82d['uniqueid']),_0x1ac82d);if(agents[_0x1ac82d[_0x0bfc('0x5')]]&&agents[_0x1ac82d['uniqueid']][_0x0bfc('0x20')]===_0x0bfc('0x21')){if(_0x1ac82d[_0x0bfc('0x4d')]==='21'){agents[_0x1ac82d['uniqueid']]['reason']=_0x0bfc('0x4e');agents[_0x1ac82d['uniqueid']][_0x0bfc('0xb')]='rejected';}utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x4f'),_0x1ac82d[_0x0bfc('0x5')],agents[_0x1ac82d[_0x0bfc('0x5')]]['membername'],agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x20')],agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0xb')]));writeDB(agents[_0x1ac82d[_0x0bfc('0x5')]]);var _0x223c00=unanswered[_0x0bfc('0x50')](_0x1ac82d[_0x0bfc('0x5')]);if(_0x223c00>-0x1){unanswered[_0x0bfc('0x51')](_0x223c00,0x1);}}if(transfers[_0x1ac82d[_0x0bfc('0x5')]]){transfers[_0x1ac82d[_0x0bfc('0x5')]]['agentcomplete']=!![];transfers[_0x1ac82d[_0x0bfc('0x5')]]['agentcompleteAt']=utils[_0x0bfc('0x16')]();transfers[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x2c')]=utils[_0x0bfc('0x52')](transfers[_0x1ac82d['uniqueid']]['agentcompleteAt'],transfers[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x2e')]);transfers[_0x1ac82d['uniqueid']]['reason']=_0x0bfc('0x53');transfers[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0xb')]=_0x0bfc('0x37');utils[_0x0bfc('0x2')](util[_0x0bfc('0x3')](_0x0bfc('0x4f'),_0x1ac82d[_0x0bfc('0x5')],transfers[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x8')],transfers[_0x1ac82d['uniqueid']]['reason'],transfers[_0x1ac82d['uniqueid']][_0x0bfc('0xb')]));writeDB(transfers[_0x1ac82d[_0x0bfc('0x5')]],!![]);}if(agents[_0x1ac82d['uniqueid']]&&agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x2e')]){agents[_0x1ac82d['uniqueid']][_0x0bfc('0x33')]=!![];agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x36')]=utils[_0x0bfc('0x16')]();agents[_0x1ac82d[_0x0bfc('0x5')]]['talktime']=utils[_0x0bfc('0x52')](agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x36')],agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x2e')]);agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x20')]=agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x3b')]?'transfer':_0x0bfc('0x53');agents[_0x1ac82d['uniqueid']][_0x0bfc('0xb')]='complete';utils[_0x0bfc('0x2')](util['format'](_0x0bfc('0x4f'),_0x1ac82d[_0x0bfc('0x5')],agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0x8')],agents[_0x1ac82d['uniqueid']]['reason'],agents[_0x1ac82d[_0x0bfc('0x5')]][_0x0bfc('0xb')]));writeDB(agents[_0x1ac82d[_0x0bfc('0x5')]]);}}catch(_0x529489){utils[_0x0bfc('0x1b')](util[_0x0bfc('0x3')]('[%s][agents][hangup]',_0x1ac82d[_0x0bfc('0x5')]),_0x529489);}};
\ 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