Built motion from commit eddce310.|2.6.12
[motion2.git] / server / services / ami / report / voiceAgentReport.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 _0xb095=['onhold','[%s][voiceAgentReport][musiconholdstart]','[%s][voiceAgentReport][musiconholdstop]\x20interface:%s','[%s][voiceAgentReport][musiconholdstop]','exports','util','ioredis','../../../config/environment','../../../config/logger','ami','defaults','redis','localhost','socket.io-emitter','channels','voiceChannels','voiceQueues','agents','variables','agentcalled','bind','agentconnect','syncAgentConnect','agentringnoanswer','syncAgentRingNoAnswer','queuecallerabandon','syncQueueCallerAbandon','agentcomplete','syncAgentComplete','varset','syncVarSet','hangup','syncHangup','musiconholdstart','syncMusicOnHoldStart','syncMusicOnHoldStop','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','prototype','emit','isNotNull','syncAgentCalled','info','uniqueid','membername','[%s][voiceAgentReport][agentcalled]\x20event:','isUndefined','interface','destuniqueid','queue','YYYY-MM-DD\x20HH:mm:ss','called','mandatoryDisposition','type','inbound','voice','event','privilege','debug','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','inspect','calleridnum','[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:','format','user:%s','user:called','[%s][voiceAgentReport][agentcalled]','hasOwnProperty','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','connectedlinename','connectedlinenum','destchannelstate','destchannelstatedesc','holdtime','lastevent','connect','routealias','merge','name','exten','custom:agentconnect','agentringnoanswerAt','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','[%s][voiceAgentReport][agentconnect]\x20Else\x20path\x20should\x20never\x20be\x20taken','error','[%s][voiceAgentReport][agentconnect]','[%s][voiceAgentReport][agentringnoanswer]\x20event:','[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected','reason','user:agentringnoanswer','custom:agentringnoanswer','[%s][voiceAgentReport][agentringnoanswer]','abandoned','custom:agentqueuecallerabandon','[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','transfer','agent','acw','acwtime','acwTimeout','agentacw','omit','[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:','destaccountcode','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','addVariable','keys','variable','value','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosloss','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberrealtime','isNil','includes','[%s][voiceAgentReport][hangup]\x20event:','agentcompleteAt','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','custom:voiceAgentReport','[%s][voiceAgentReport][hangup]','[%s][voiceAgentReport][attendedtransfer]\x20event:','transfereeuniqueid','[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','complete','diff','seconds','secondtransfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','talktime','[%s][voiceAgentReport][musiconholdstart]\x20event:','channel','lastIndexOf','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s'];(function(_0x553905,_0x444caa){var _0x35c1d6=function(_0x4f9e93){while(--_0x4f9e93){_0x553905['push'](_0x553905['shift']());}};_0x35c1d6(++_0x444caa);}(_0xb095,0x9a));var _0x5b09=function(_0x26427d,_0x1e5a43){_0x26427d=_0x26427d-0x0;var _0x3a5a75=_0xb095[_0x26427d];return _0x3a5a75;};'use strict';var _=require('lodash');var moment=require('moment');var util=require(_0x5b09('0x0'));var Redis=require(_0x5b09('0x1'));var config=require(_0x5b09('0x2'));var logger=require(_0x5b09('0x3'))(_0x5b09('0x4'));var ami=require('../ami');config['redis']=_[_0x5b09('0x5')](config[_0x5b09('0x6')],{'host':_0x5b09('0x7'),'port':0x18eb});var io=require(_0x5b09('0x8'))(new Redis(config[_0x5b09('0x6')]));function VoiceAgentReport(_0x23ebc9){this[_0x5b09('0x9')]={};this[_0x5b09('0xa')]=_0x23ebc9['channels'];this[_0x5b09('0xb')]=_0x23ebc9[_0x5b09('0xb')];this['agents']=_0x23ebc9[_0x5b09('0xc')];this[_0x5b09('0xd')]={};ami['on'](_0x5b09('0xe'),this['syncAgentCalled'][_0x5b09('0xf')](this));ami['on'](_0x5b09('0x10'),this[_0x5b09('0x11')]['bind'](this));ami['on'](_0x5b09('0x12'),this[_0x5b09('0x13')]['bind'](this));ami['on'](_0x5b09('0x14'),this[_0x5b09('0x15')]['bind'](this));ami['on'](_0x5b09('0x16'),this[_0x5b09('0x17')][_0x5b09('0xf')](this));ami['on'](_0x5b09('0x18'),this[_0x5b09('0x19')]['bind'](this));ami['on'](_0x5b09('0x1a'),this[_0x5b09('0x1b')][_0x5b09('0xf')](this));ami['on'](_0x5b09('0x1c'),this[_0x5b09('0x1d')]['bind'](this));ami['on']('musiconholdstop',this[_0x5b09('0x1e')][_0x5b09('0xf')](this));ami['on'](_0x5b09('0x1f'),this[_0x5b09('0x20')]['bind'](this));ami['on'](_0x5b09('0x21'),this[_0x5b09('0x22')][_0x5b09('0xf')](this));}VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x24')]=function(_0x10f46b,_0x59dfec,_0x33c06c){io['to'](_0x10f46b)[_0x5b09('0x24')](_0x59dfec,_0x33c06c);};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x25')]=function(_0x5e7b3c){return _0x5e7b3c!==null&&!_['isUndefined'](_0x5e7b3c);};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x26')]=function(_0x42f26a){try{if(this[_0x5b09('0x25')](_0x42f26a)){logger[_0x5b09('0x27')]('[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called',_0x42f26a[_0x5b09('0x28')],_0x42f26a[_0x5b09('0x29')],_0x42f26a['destuniqueid']);logger['debug'](_0x5b09('0x2a'),_0x42f26a[_0x5b09('0x28')],util['inspect'](_0x42f26a,{'showHidden':![],'depth':null}));if(_[_0x5b09('0x2b')](this[_0x5b09('0x9')][_0x42f26a[_0x5b09('0x28')]])){this[_0x5b09('0x9')][_0x42f26a[_0x5b09('0x28')]]={};}var _0x359173=this[_0x5b09('0xc')][_0x42f26a[_0x5b09('0x2c')]];var _0x418bd7=this[_0x5b09('0x9')][_0x42f26a[_0x5b09('0x28')]][_0x42f26a[_0x5b09('0x2d')]];var _0x5afd4a=this[_0x5b09('0xb')][_0x42f26a[_0x5b09('0x2e')]];var _0x4a292f=this[_0x5b09('0xd')][_0x42f26a[_0x5b09('0x28')]];if(_[_0x5b09('0x2b')](_0x418bd7)){_0x418bd7={'agentcalledAt':moment()['format'](_0x5b09('0x2f')),'lastevent':_0x5b09('0x30'),'mandatoryDisposition':_0x5afd4a&&_0x5afd4a[_0x5b09('0x31')]?_0x5afd4a[_0x5b09('0x31')]:![],'type':_0x5afd4a&&_0x5afd4a[_0x5b09('0x32')]?_0x5afd4a[_0x5b09('0x32')]:_0x5b09('0x33'),'variables':_0x4a292f,'motionChannel':_0x5b09('0x34')};}_['merge'](_0x418bd7,_['omit'](_0x42f26a,[_0x5b09('0x35'),_0x5b09('0x36')]));this[_0x5b09('0x9')][_0x42f26a['uniqueid']][_0x42f26a[_0x5b09('0x2d')]]=_0x418bd7;logger[_0x5b09('0x37')](_0x5b09('0x38'),_0x42f26a[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x418bd7,{'showHidden':![],'depth':null}));ami['emit']('custom:agentcalled',_0x418bd7);var _0x4bcef7={'id':_0x359173['id'],'calleridnum':_0x418bd7[_0x5b09('0x3a')],'queue':_0x418bd7[_0x5b09('0x2e')],'variables':_0x418bd7[_0x5b09('0xd')],'uniqueid':_0x42f26a['uniqueid']};logger['debug'](_0x5b09('0x3b'),_0x42f26a[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x4bcef7,{'showHidden':![],'depth':null}));this[_0x5b09('0x24')](util[_0x5b09('0x3c')](_0x5b09('0x3d'),_0x42f26a[_0x5b09('0x29')]),_0x5b09('0x3e'),_0x4bcef7);}}catch(_0x148e45){logger['error'](_0x5b09('0x3f'),_0x42f26a[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x148e45,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x5b09('0x11')]=function(_0x43bbe2){try{if(this[_0x5b09('0x25')](_0x43bbe2)){if(this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]]){for(var _0xcd2545 in this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]]){if(this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0x5b09('0x40')](_0xcd2545)){if(_0x43bbe2[_0x5b09('0x2d')]===_0xcd2545){logger[_0x5b09('0x27')](_0x5b09('0x41'),_0x43bbe2[_0x5b09('0x28')],_0x43bbe2['membername'],_0x43bbe2['destuniqueid']);this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x42')]=moment()[_0x5b09('0x3c')](_0x5b09('0x2f'));this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x43')]=_0x43bbe2[_0x5b09('0x43')];this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x44')]=_0x43bbe2[_0x5b09('0x44')];this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x45')]=_0x43bbe2[_0x5b09('0x45')];this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x46')]=_0x43bbe2[_0x5b09('0x46')];this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x47')]=_0x43bbe2[_0x5b09('0x47')];this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x48')]=_0x5b09('0x49');if(this['voiceChannels'][this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x28')]]){var _0x159191=this[_0x5b09('0xa')][this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x28')]]['routealias'];this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x4a')]=_0x159191;_0x43bbe2['routealias']=_0x159191;}_[_0x5b09('0x4b')](this['agents'][_0x43bbe2[_0x5b09('0x2c')]],_['pick'](_0x43bbe2,[_0x5b09('0x2e'),'destconnectedlinenum',_0x5b09('0x4a')]));var _0x57882b=this[_0x5b09('0xc')][_0x43bbe2[_0x5b09('0x2c')]];var _0x1786eb={'id':_0x57882b['id'],'name':_0x57882b[_0x5b09('0x4c')],'agentconnected':!![],'destaccountcode':_0x57882b['accountcode'],'destconnectedlinenum':this['channels'][_0x43bbe2['uniqueid']][_0x43bbe2['destuniqueid']][_0x5b09('0x4d')],'queue':this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0x43bbe2['destuniqueid']]['queue'],'routealias':this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0x43bbe2['destuniqueid']][_0x5b09('0x4a')],'uniqueid':this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0x43bbe2[_0x5b09('0x2d')]][_0x5b09('0x28')]};ami[_0x5b09('0x24')](_0x5b09('0x4e'),this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0x43bbe2[_0x5b09('0x2d')]]);this['emit'](util[_0x5b09('0x3c')]('user:%s',_0x43bbe2['membername']),'user:agentconnect',_0x1786eb);}else if(!this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545]['agentringnoanswer']&&!this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545]['agentcomplete']){logger[_0x5b09('0x27')]('[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere',_0x43bbe2[_0x5b09('0x28')],this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x29')],_0xcd2545);this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x12')]=!![];this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545][_0x5b09('0x4f')]=moment()['format'](_0x5b09('0x2f'));this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545]['answeredelsewheredestinationuniqueid']=_0x43bbe2[_0x5b09('0x2d')];this['channels'][_0x43bbe2['uniqueid']][_0xcd2545]['answeredelsewheremembername']=_0x43bbe2[_0x5b09('0x29')];this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545][_0x5b09('0x48')]='answered_elsewhere';this['channels'][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545]['reason']='answered_elsewhere';logger[_0x5b09('0x37')](_0x5b09('0x50'),_0x43bbe2['uniqueid'],util[_0x5b09('0x39')](this[_0x5b09('0x9')][_0x43bbe2[_0x5b09('0x28')]][_0xcd2545],{'showHidden':![],'depth':null}));ami['emit']('custom:agentansweredelsewhere',this[_0x5b09('0x9')][_0x43bbe2['uniqueid']][_0xcd2545]);}else{logger[_0x5b09('0x37')](_0x5b09('0x51'),_0x43bbe2['uniqueid']);}}}}}}catch(_0x47add6){logger[_0x5b09('0x52')](_0x5b09('0x53'),_0x43bbe2['uniqueid'],util[_0x5b09('0x39')](_0x47add6,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x5b09('0x13')]=function(_0x3e145b){try{if(this[_0x5b09('0x25')](_0x3e145b)){logger[_0x5b09('0x37')](_0x5b09('0x54'),_0x3e145b[_0x5b09('0x28')],util['inspect'](_0x3e145b,{'showHidden':![],'depth':null}));if(this[_0x5b09('0x9')][_0x3e145b[_0x5b09('0x28')]]&&this['channels'][_0x3e145b[_0x5b09('0x28')]][_0x3e145b['destuniqueid']]){logger[_0x5b09('0x27')](_0x5b09('0x55'),_0x3e145b[_0x5b09('0x28')],_0x3e145b['membername'],_0x3e145b[_0x5b09('0x2d')]);var _0x21e155=this[_0x5b09('0xc')][_0x3e145b[_0x5b09('0x2c')]];var _0x55e258=this[_0x5b09('0x9')][_0x3e145b[_0x5b09('0x28')]][_0x3e145b['destuniqueid']];_0x55e258['agentringnoanswer']=!![];_0x55e258[_0x5b09('0x4f')]=moment()[_0x5b09('0x3c')](_0x5b09('0x2f'));_0x55e258[_0x5b09('0x48')]='rejected';_0x55e258[_0x5b09('0x56')]='rejected';var _0x28709d={'id':_0x21e155['id'],'name':_0x21e155['name'],'queue':_0x55e258[_0x5b09('0x2e')],'uniqueid':_0x55e258[_0x5b09('0x28')]};logger[_0x5b09('0x37')]('[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:',_0x3e145b['uniqueid'],util[_0x5b09('0x39')](_0x28709d,{'showHidden':![],'depth':null}));this[_0x5b09('0x24')](util[_0x5b09('0x3c')](_0x5b09('0x3d'),_0x21e155[_0x5b09('0x4c')]),_0x5b09('0x57'),_0x28709d);ami['emit'](_0x5b09('0x58'),_0x55e258);}}}catch(_0x5b76c6){logger['error'](_0x5b09('0x59'),_0x3e145b['uniqueid'],util['inspect'](_0x5b76c6,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')]['syncQueueCallerAbandon']=function(_0x5880f6){try{if(this[_0x5b09('0x25')](_0x5880f6)){logger['debug']('[%s][voiceAgentReport][queuecallerabandon]\x20event:',_0x5880f6['uniqueid'],util[_0x5b09('0x39')](_0x5880f6,{'showHidden':![],'depth':null}));if(this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]]){for(var _0x44b695 in this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]]){if(this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]][_0x5b09('0x40')](_0x44b695)&&!this[_0x5b09('0x9')][_0x5880f6['uniqueid']][_0x44b695][_0x5b09('0x12')]&&!this[_0x5b09('0x9')][_0x5880f6['uniqueid']][_0x44b695]['agentcomplete']){logger[_0x5b09('0x27')]('[%s][voiceAgentReport][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned',_0x5880f6[_0x5b09('0x28')],this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]][_0x44b695]['membername'],_0x44b695);this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]][_0x44b695]['agentringnoanswer']=!![];this['channels'][_0x5880f6['uniqueid']][_0x44b695][_0x5b09('0x4f')]=moment()['format'](_0x5b09('0x2f'));this[_0x5b09('0x9')][_0x5880f6['uniqueid']][_0x44b695][_0x5b09('0x48')]=_0x5b09('0x5a');this['channels'][_0x5880f6[_0x5b09('0x28')]][_0x44b695][_0x5b09('0x56')]=_0x5b09('0x5a');logger[_0x5b09('0x37')]('[%s][voiceAgentReport][queuecallerabandon]\x20sending\x20agentqueuecallerabandon\x20event:',_0x5880f6['uniqueid'],util[_0x5b09('0x39')](this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]][_0x44b695],{'showHidden':![],'depth':null}));ami[_0x5b09('0x24')](_0x5b09('0x5b'),this[_0x5b09('0x9')][_0x5880f6[_0x5b09('0x28')]][_0x44b695]);}}}}}catch(_0x164ca4){logger[_0x5b09('0x52')]('[%s][voiceAgentReport][queuecallerabandon]',_0x5880f6['uniqueid'],util[_0x5b09('0x39')](_0x164ca4,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x5b09('0x17')]=function(_0x178575){try{if(this[_0x5b09('0x25')](_0x178575)){logger[_0x5b09('0x37')]('[%s][voiceAgentReport][agentcomplete]\x20event:',_0x178575[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x178575,{'showHidden':![],'depth':null}));if(this['channels'][_0x178575[_0x5b09('0x28')]]){for(var _0x45e4fe in this['channels'][_0x178575[_0x5b09('0x28')]]){if(this[_0x5b09('0x9')][_0x178575['uniqueid']][_0x5b09('0x40')](_0x45e4fe)){if(this['channels'][_0x178575['uniqueid']][_0x45e4fe][_0x5b09('0x42')]&&!this['channels'][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['agentcomplete']){logger[_0x5b09('0x27')](_0x5b09('0x5c'),_0x178575[_0x5b09('0x28')],this[_0x5b09('0x9')][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['membername'],_0x45e4fe);this['channels'][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['agentcomplete']=!![];this['channels'][_0x178575['uniqueid']][_0x45e4fe]['agentcompleteAt']=moment()[_0x5b09('0x3c')](_0x5b09('0x2f'));this[_0x5b09('0x9')][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['lastevent']='complete';this['channels'][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['reason']=_0x178575['reason']==_0x5b09('0x5d')?_0x5b09('0x5e'):_0x178575[_0x5b09('0x56')];this[_0x5b09('0x9')][_0x178575[_0x5b09('0x28')]][_0x45e4fe]['talktime']=_0x178575['talktime'];if(this[_0x5b09('0xb')][_0x178575[_0x5b09('0x2e')]]&&this['voiceQueues'][_0x178575[_0x5b09('0x2e')]][_0x5b09('0x5f')]){this[_0x5b09('0x9')][_0x178575[_0x5b09('0x28')]][_0x45e4fe][_0x5b09('0x60')]=this['voiceQueues'][_0x178575['queue']][_0x5b09('0x61')];this['channels'][_0x178575[_0x5b09('0x28')]][_0x45e4fe][_0x5b09('0x62')]=!![];}this['agents'][_0x178575[_0x5b09('0x2c')]]=_[_0x5b09('0x63')](this['agents'][_0x178575['interface']],[_0x5b09('0x2e'),'destconnectedlinenum']);logger[_0x5b09('0x37')](_0x5b09('0x64'),_0x178575[_0x5b09('0x28')],util[_0x5b09('0x39')](this['channels'][_0x178575[_0x5b09('0x28')]][_0x45e4fe],{'showHidden':![],'depth':null}));ami[_0x5b09('0x24')]('custom:agentcomplete',this[_0x5b09('0x9')][_0x178575[_0x5b09('0x28')]][_0x45e4fe]);logger[_0x5b09('0x37')]('[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:',_0x178575['uniqueid'],util[_0x5b09('0x39')]({'id':this[_0x5b09('0xc')][_0x178575[_0x5b09('0x2c')]]['id'],'destaccountcode':_0x178575['destaccountcode']},{'showHidden':![],'depth':null}));this[_0x5b09('0x24')](util[_0x5b09('0x3c')](_0x5b09('0x3d'),_0x178575[_0x5b09('0x29')]),'user:agentcomplete',{'id':this[_0x5b09('0xc')][_0x178575[_0x5b09('0x2c')]]['id'],'destaccountcode':Number(_0x178575[_0x5b09('0x65')])});}}}}}}catch(_0x428f4b){logger['error'](_0x5b09('0x66'),_0x178575[_0x5b09('0x28')],util['inspect'](_0x428f4b,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x19')]=function(_0xf1ad45){try{if(this[_0x5b09('0x25')](_0xf1ad45)){logger['debug'](_0x5b09('0x67'),_0xf1ad45[_0x5b09('0x28')],util['inspect'](_0xf1ad45,{'showHidden':![],'depth':null}));this[_0x5b09('0x68')](_0xf1ad45[_0x5b09('0x28')],_[_0x5b09('0x69')](_0xf1ad45[_0x5b09('0x6a')])[0x0],_0xf1ad45[_0x5b09('0x6b')]);if(this[_0x5b09('0x9')][_0xf1ad45[_0x5b09('0x28')]]){for(var _0x2bffbf in this['channels'][_0xf1ad45[_0x5b09('0x28')]]){if(this[_0x5b09('0x9')][_0xf1ad45[_0x5b09('0x28')]][_0x5b09('0x40')](_0x2bffbf)){logger['info']('[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s',_0xf1ad45[_0x5b09('0x28')],_0x2bffbf,_['keys'](_0xf1ad45[_0x5b09('0x6a')])[0x0],_0xf1ad45[_0x5b09('0x6b')]);if(_[_0x5b09('0x2b')](this[_0x5b09('0x9')][_0xf1ad45[_0x5b09('0x28')]][_0x2bffbf]['variables'])){this[_0x5b09('0x9')][_0xf1ad45[_0x5b09('0x28')]][_0x2bffbf][_0x5b09('0xd')]={};}this[_0x5b09('0x9')][_0xf1ad45[_0x5b09('0x28')]][_0x2bffbf][_0x5b09('0xd')]=this[_0x5b09('0xd')][_0xf1ad45[_0x5b09('0x28')]];}}}}}catch(_0x1ce8c5){logger[_0x5b09('0x52')](_0x5b09('0x6c'),_0xf1ad45[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x1ce8c5,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x68')]=function(_0x4b1173,_0x43bb70,_0x3a9095){var _0x4d6f37=[_0x5b09('0x6d'),_0x5b09('0x6e'),'rtpaudioqosjitter','rtpaudioqosjitterbridged',_0x5b09('0x6f'),'rtpaudioqoslossbridged',_0x5b09('0x70'),_0x5b09('0x71'),_0x5b09('0x72'),_0x5b09('0x73'),_0x5b09('0x74'),_0x5b09('0x75'),_0x5b09('0x76'),_0x5b09('0x77'),_0x5b09('0x78'),'memberlastcall',_0x5b09('0x29'),'memberpenalty',_0x5b09('0x79')];if(!_[_0x5b09('0x7a')](_0x43bb70)&&!_[_0x5b09('0x7b')](_0x4d6f37,_0x43bb70)){if(_[_0x5b09('0x2b')](this[_0x5b09('0xd')][_0x4b1173])){this['variables'][_0x4b1173]={};}this[_0x5b09('0xd')][_0x4b1173][_0x43bb70]=_0x3a9095;}};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x1b')]=function(_0x1c3e80){try{if(this[_0x5b09('0x25')](_0x1c3e80)){logger[_0x5b09('0x37')](_0x5b09('0x7c'),_0x1c3e80[_0x5b09('0x28')],util['inspect'](_0x1c3e80,{'showHidden':![],'depth':null}));if(this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]]){for(var _0x343ba7 in this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]]){if(this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]]['hasOwnProperty'](_0x343ba7)){if(this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]][_0x343ba7][_0x5b09('0x56')]=='transfer'&&this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]][_0x343ba7][_0x5b09('0x16')]){logger[_0x5b09('0x27')]('[%s][voiceAgentReport][hangup]\x20destuniqueid:%s',_0x1c3e80[_0x5b09('0x28')],_0x343ba7);this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]][_0x343ba7][_0x5b09('0x7d')]=moment()[_0x5b09('0x3c')](_0x5b09('0x2f'));}}}logger['debug'](_0x5b09('0x7e'),_0x1c3e80[_0x5b09('0x28')],util['inspect'](_['values'](this[_0x5b09('0x9')][_0x1c3e80['uniqueid']]),{'showHidden':![],'depth':null}));ami['emit'](_0x5b09('0x7f'),_['values'](this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]]));delete this[_0x5b09('0x9')][_0x1c3e80[_0x5b09('0x28')]];}if(this[_0x5b09('0xd')][_0x1c3e80[_0x5b09('0x28')]]){delete this[_0x5b09('0xd')][_0x1c3e80['uniqueid']];}}}catch(_0x298309){logger[_0x5b09('0x52')](_0x5b09('0x80'),_0x1c3e80['uniqueid'],util[_0x5b09('0x39')](_0x298309,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')]['syncAttendedTransfer']=function(_0x4180a6){try{if(this[_0x5b09('0x25')](_0x4180a6)){logger[_0x5b09('0x37')](_0x5b09('0x81'),_0x4180a6[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x4180a6,{'showHidden':![],'depth':null}));if(this['channels'][_0x4180a6['transfereeuniqueid']]){for(var _0x3fa742 in this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]]){if(this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x5b09('0x40')](_0x3fa742)){if(_0x4180a6['origtransfereruniqueid']===_0x3fa742){logger[_0x5b09('0x27')](_0x5b09('0x83'),_0x4180a6[_0x5b09('0x28')],this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x3fa742][_0x5b09('0x29')],_0x3fa742);var _0x175f8f=moment();this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x3fa742][_0x5b09('0x16')]=!![];this['channels'][_0x4180a6[_0x5b09('0x82')]][_0x3fa742][_0x5b09('0x7d')]=moment()[_0x5b09('0x3c')]('YYYY-MM-DD\x20HH:mm:ss');this['channels'][_0x4180a6[_0x5b09('0x82')]][_0x3fa742]['lastevent']=_0x5b09('0x84');this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x3fa742]['reason']='transfer';this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x3fa742]['talktime']=_0x175f8f[_0x5b09('0x85')](this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]][_0x3fa742][_0x5b09('0x42')],_0x5b09('0x86'));}}}}if(this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x87')]]){var _0x20ecb7=this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x87')]];this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x87')]]=this['channels'][_0x4180a6[_0x5b09('0x82')]];this[_0x5b09('0x9')][_0x4180a6[_0x5b09('0x82')]]=_0x20ecb7;}}}catch(_0x55fde3){logger[_0x5b09('0x52')]('[%s][voiceAgentReport][attendedtransfer]',_0x4180a6[_0x5b09('0x28')],util['inspect'](_0x55fde3,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x22')]=function(_0xead0aa){try{if(this[_0x5b09('0x25')](_0xead0aa)){logger[_0x5b09('0x37')](_0x5b09('0x88'),_0xead0aa[_0x5b09('0x28')],util['inspect'](_0xead0aa,{'showHidden':![],'depth':null}));if(this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]]){for(var _0x48569d in this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]]){if(this[_0x5b09('0x9')][_0xead0aa['transfereeuniqueid']][_0x5b09('0x40')](_0x48569d)){if(_0xead0aa[_0x5b09('0x89')]===_0x48569d){logger['info'](_0x5b09('0x8a'),_0xead0aa[_0x5b09('0x28')],this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]][_0x48569d][_0x5b09('0x29')],_0x48569d);var _0x518c19=moment();this['channels'][_0xead0aa[_0x5b09('0x82')]][_0x48569d][_0x5b09('0x16')]=!![];this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]][_0x48569d][_0x5b09('0x7d')]=_0x518c19;this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]][_0x48569d][_0x5b09('0x48')]=_0x5b09('0x84');this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]][_0x48569d][_0x5b09('0x56')]=_0x5b09('0x5d');this[_0x5b09('0x9')][_0xead0aa['transfereeuniqueid']][_0x48569d][_0x5b09('0x8b')]=_0x518c19[_0x5b09('0x85')](this[_0x5b09('0x9')][_0xead0aa[_0x5b09('0x82')]][_0x48569d]['agentconnectAt'],_0x5b09('0x86'));}}}}}}catch(_0x2d7bd9){logger[_0x5b09('0x52')]('[%s][voiceAgentReport][blindtransfer]',_0xead0aa['uniqueid'],util[_0x5b09('0x39')](_0x2d7bd9,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')]['syncMusicOnHoldStart']=function(_0x376451){var _0x2d63a6='';try{if(this[_0x5b09('0x25')](_0x376451)){logger['debug'](_0x5b09('0x8c'),_0x376451[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x376451,{'showHidden':![],'depth':null}));if(_0x376451[_0x5b09('0x8d')]){_0x2d63a6=_0x376451['channel']['substring'](0x0,_0x376451[_0x5b09('0x8d')][_0x5b09('0x8e')]('-'));if(this['agents'][_0x2d63a6]){logger[_0x5b09('0x27')](_0x5b09('0x8f'),_0x376451[_0x5b09('0x28')],_0x2d63a6);this[_0x5b09('0xc')][_0x2d63a6][_0x5b09('0x90')]=!![];}}}}catch(_0x5cbeec){logger[_0x5b09('0x52')](_0x5b09('0x91'),_0x376451[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x5cbeec,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x5b09('0x23')][_0x5b09('0x1e')]=function(_0x21d17c){var _0x1ec544='';try{if(this['isNotNull'](_0x21d17c)){logger[_0x5b09('0x37')]('[%s][voiceAgentReport][musiconholdstop]\x20event:',_0x21d17c[_0x5b09('0x28')],util[_0x5b09('0x39')](_0x21d17c,{'showHidden':![],'depth':null}));if(_0x21d17c[_0x5b09('0x8d')]){_0x1ec544=_0x21d17c['channel']['substring'](0x0,_0x21d17c[_0x5b09('0x8d')][_0x5b09('0x8e')]('-'));if(this['agents'][_0x1ec544]){logger[_0x5b09('0x27')](_0x5b09('0x92'),_0x21d17c[_0x5b09('0x28')],_0x1ec544);this['agents'][_0x1ec544][_0x5b09('0x90')]=![];}}}}catch(_0xad8b3a){logger[_0x5b09('0x52')](_0x5b09('0x93'),_0x21d17c[_0x5b09('0x28')],util[_0x5b09('0x39')](_0xad8b3a,{'showHidden':![],'depth':null}));}};module[_0x5b09('0x94')]=VoiceAgentReport;