d2602c8f16fe11164a88ded809766e29edc320ad
[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 _0xb5f1=['[%s][voiceAgentReport][hangup]\x20event:','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','values','custom:voiceAgentReport','deleteChannelAfterTimeout','[%s][voiceAgentReport][attendedtransfer]\x20event:','transfereeuniqueid','origtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','talktime','diff','seconds','secondtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]','syncBlindTransfer','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','complete','[%s][voiceAgentReport][blindtransfer]','[%s][voiceAgentReport][musiconholdstart]\x20event:','channel','substring','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s','onhold','[%s][voiceAgentReport][musiconholdstart]','[%s][voiceAgentReport][musiconholdstop]\x20event:','[%s][voiceAgentReport][musiconholdstop]','exports','lodash','moment','ioredis','../../../config/environment','../../../config/logger','ami','../ami','defaults','redis','localhost','voiceChannels','channels','voiceQueues','agents','syncAgentCalled','bind','syncAgentConnect','agentringnoanswer','syncAgentRingNoAnswer','queuecallerabandon','syncQueueCallerAbandon','agentcomplete','varset','syncVarSet','hangup','syncHangup','syncMusicOnHoldStart','musiconholdstop','syncMusicOnHoldStop','attendedtransfer','syncAttendedTransfer','prototype','emit','isNotNull','isUndefined','info','[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','uniqueid','destuniqueid','debug','inspect','variables','format','YYYY-MM-DD\x20HH:mm:ss','called','mandatoryDisposition','type','inbound','voice','assign','omit','privilege','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','custom:agentcalled','queue','[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:','user:%s','membername','error','hasOwnProperty','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','connectedlinename','connectedlinenum','destchannelstate','holdtime','lastevent','connect','destconnectedlinenum','interface','name','accountcode','custom:agentconnect','user:agentconnect','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere','answeredelsewheredestinationuniqueid','answeredelsewheremembername','answered_elsewhere','reason','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','custom:agentansweredelsewhere','[%s][voiceAgentReport][agentconnect]\x20Else\x20path\x20should\x20never\x20be\x20taken','[%s][voiceAgentReport][agentconnect]','[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected','agentringnoanswerAt','rejected','[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:','user:agentringnoanswer','[%s][voiceAgentReport][agentringnoanswer]','[%s][voiceAgentReport][queuecallerabandon]\x20event:','[%s][voiceAgentReport][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned','abandoned','[%s][voiceAgentReport][queuecallerabandon]\x20sending\x20agentqueuecallerabandon\x20event:','custom:agentqueuecallerabandon','[%s][voiceAgentReport][queuecallerabandon]','syncAgentComplete','[%s][voiceAgentReport][agentcomplete]\x20event:','agentcompleteAt','transfer','agent','acwtime','acwTimeout','agentacw','[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:','destaccountcode','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','keys','value','[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s','variable','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosjitter','rtpaudioqosloss','rtpaudioqoslossbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberlastcall','memberrealtime','isNil'];(function(_0x141aab,_0x3babe0){var _0x30d04e=function(_0x456b30){while(--_0x456b30){_0x141aab['push'](_0x141aab['shift']());}};_0x30d04e(++_0x3babe0);}(_0xb5f1,0x150));var _0x1b5f=function(_0x4e13cd,_0x1c53e9){_0x4e13cd=_0x4e13cd-0x0;var _0x39d7b4=_0xb5f1[_0x4e13cd];return _0x39d7b4;};'use strict';var _=require(_0x1b5f('0x0'));var moment=require(_0x1b5f('0x1'));var util=require('util');var Redis=require(_0x1b5f('0x2'));var config=require(_0x1b5f('0x3'));var logger=require(_0x1b5f('0x4'))(_0x1b5f('0x5'));var ami=require(_0x1b5f('0x6'));config['redis']=_[_0x1b5f('0x7')](config[_0x1b5f('0x8')],{'host':_0x1b5f('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x1b5f('0x8')]));function VoiceAgentReport(_0x26a200){this['channels']={};this[_0x1b5f('0xa')]=_0x26a200[_0x1b5f('0xb')];this[_0x1b5f('0xc')]=_0x26a200['voiceQueues'];this[_0x1b5f('0xd')]=_0x26a200['agents'];this['variables']={};ami['on']('agentcalled',this[_0x1b5f('0xe')][_0x1b5f('0xf')](this));ami['on']('agentconnect',this[_0x1b5f('0x10')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x11'),this[_0x1b5f('0x12')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x13'),this[_0x1b5f('0x14')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x15'),this['syncAgentComplete']['bind'](this));ami['on'](_0x1b5f('0x16'),this[_0x1b5f('0x17')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x18'),this[_0x1b5f('0x19')][_0x1b5f('0xf')](this));ami['on']('musiconholdstart',this[_0x1b5f('0x1a')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x1b'),this[_0x1b5f('0x1c')][_0x1b5f('0xf')](this));ami['on'](_0x1b5f('0x1d'),this[_0x1b5f('0x1e')][_0x1b5f('0xf')](this));ami['on']('blindtransfer',this['syncBlindTransfer'][_0x1b5f('0xf')](this));}VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x20')]=function(_0x2ad505,_0x2f4eec,_0x22fb53){io['to'](_0x2ad505)[_0x1b5f('0x20')](_0x2f4eec,_0x22fb53);};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x21')]=function(_0x3ae891){return _0x3ae891!==null&&!_[_0x1b5f('0x22')](_0x3ae891);};VoiceAgentReport[_0x1b5f('0x1f')]['syncAgentCalled']=function(_0x4ab3f6){try{if(this[_0x1b5f('0x21')](_0x4ab3f6)){logger[_0x1b5f('0x23')](_0x1b5f('0x24'),_0x4ab3f6[_0x1b5f('0x25')],_0x4ab3f6['membername'],_0x4ab3f6[_0x1b5f('0x26')]);logger[_0x1b5f('0x27')]('[%s][voiceAgentReport][agentcalled]\x20event:',_0x4ab3f6['uniqueid'],util[_0x1b5f('0x28')](_0x4ab3f6,{'showHidden':![],'depth':null}));if(_[_0x1b5f('0x22')](this[_0x1b5f('0xb')][_0x4ab3f6[_0x1b5f('0x25')]])){this[_0x1b5f('0xb')][_0x4ab3f6['uniqueid']]={};}var _0x450a5c=this[_0x1b5f('0xd')][_0x4ab3f6['interface']];var _0x15a576=this['channels'][_0x4ab3f6[_0x1b5f('0x25')]][_0x4ab3f6[_0x1b5f('0x26')]];var _0x589755=this['voiceQueues'][_0x4ab3f6['queue']];var _0x5833db=this[_0x1b5f('0x29')][_0x4ab3f6[_0x1b5f('0x25')]];if(_[_0x1b5f('0x22')](_0x15a576)){_0x15a576={'agentcalledAt':moment()[_0x1b5f('0x2a')](_0x1b5f('0x2b')),'lastevent':_0x1b5f('0x2c'),'mandatoryDisposition':_0x589755&&_0x589755[_0x1b5f('0x2d')]?_0x589755['mandatoryDisposition']:![],'type':_0x589755&&_0x589755[_0x1b5f('0x2e')]?_0x589755['type']:_0x1b5f('0x2f'),'variables':_0x5833db,'motionChannel':_0x1b5f('0x30')};}Object[_0x1b5f('0x31')](_0x15a576,_[_0x1b5f('0x32')](_0x4ab3f6,['event',_0x1b5f('0x33')]));this[_0x1b5f('0xb')][_0x4ab3f6[_0x1b5f('0x25')]][_0x4ab3f6[_0x1b5f('0x26')]]=_0x15a576;logger[_0x1b5f('0x27')](_0x1b5f('0x34'),_0x4ab3f6[_0x1b5f('0x25')],util['inspect'](_0x15a576,{'showHidden':![],'depth':null}));ami[_0x1b5f('0x20')](_0x1b5f('0x35'),_0x15a576);var _0x295820={'id':_0x450a5c['id'],'calleridnum':_0x15a576['calleridnum'],'queue':_0x15a576[_0x1b5f('0x36')],'variables':_0x15a576['variables'],'uniqueid':_0x4ab3f6['uniqueid']};logger[_0x1b5f('0x27')](_0x1b5f('0x37'),_0x4ab3f6['uniqueid'],util[_0x1b5f('0x28')](_0x295820,{'showHidden':![],'depth':null}));this[_0x1b5f('0x20')](util[_0x1b5f('0x2a')](_0x1b5f('0x38'),_0x4ab3f6[_0x1b5f('0x39')]),'user:called',_0x295820);}}catch(_0x1b5124){logger[_0x1b5f('0x3a')]('[%s][voiceAgentReport][agentcalled]',_0x4ab3f6[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x1b5124,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x10')]=function(_0x238bd7){try{if(this[_0x1b5f('0x21')](_0x238bd7)){if(this['channels'][_0x238bd7[_0x1b5f('0x25')]]){for(var _0x1041dd in this[_0x1b5f('0xb')][_0x238bd7['uniqueid']]){if(this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1b5f('0x3b')](_0x1041dd)){if(_0x238bd7[_0x1b5f('0x26')]===_0x1041dd){logger[_0x1b5f('0x23')](_0x1b5f('0x3c'),_0x238bd7[_0x1b5f('0x25')],_0x238bd7['membername'],_0x238bd7[_0x1b5f('0x26')]);this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x3d')]=moment()[_0x1b5f('0x2a')]('YYYY-MM-DD\x20HH:mm:ss');this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x3e')]=_0x238bd7[_0x1b5f('0x3e')];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x3f')]=_0x238bd7[_0x1b5f('0x3f')];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x40')]=_0x238bd7['destchannelstate'];this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd]['destchannelstatedesc']=_0x238bd7['destchannelstatedesc'];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x41')]=_0x238bd7[_0x1b5f('0x41')];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x42')]=_0x1b5f('0x43');_['merge'](this[_0x1b5f('0xd')][_0x238bd7['interface']],_['pick'](_0x238bd7,[_0x1b5f('0x36'),_0x1b5f('0x44')]));var _0x83b559=this['agents'][_0x238bd7[_0x1b5f('0x45')]];var _0xc866f1={'id':_0x83b559['id'],'name':_0x83b559[_0x1b5f('0x46')],'agentconnected':!![],'destaccountcode':_0x83b559[_0x1b5f('0x47')],'destconnectedlinenum':this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x238bd7[_0x1b5f('0x26')]]['exten'],'queue':this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x238bd7[_0x1b5f('0x26')]][_0x1b5f('0x36')],'uniqueid':this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x238bd7[_0x1b5f('0x26')]]['uniqueid']};ami[_0x1b5f('0x20')](_0x1b5f('0x48'),this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x238bd7[_0x1b5f('0x26')]]);this[_0x1b5f('0x20')](util[_0x1b5f('0x2a')](_0x1b5f('0x38'),_0x238bd7['membername']),_0x1b5f('0x49'),_0xc866f1);}else if(!this[_0x1b5f('0xb')][_0x238bd7['uniqueid']][_0x1041dd]['agentringnoanswer']&&!this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd]['agentcomplete']){logger['info'](_0x1b5f('0x4a'),_0x238bd7['uniqueid'],this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x39')],_0x1041dd);this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd]['agentringnoanswer']=!![];this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd]['agentringnoanswerAt']=moment()[_0x1b5f('0x2a')](_0x1b5f('0x2b'));this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x4b')]=_0x238bd7['destuniqueid'];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x4c')]=_0x238bd7['membername'];this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x42')]=_0x1b5f('0x4d');this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd][_0x1b5f('0x4e')]=_0x1b5f('0x4d');logger[_0x1b5f('0x27')](_0x1b5f('0x4f'),_0x238bd7[_0x1b5f('0x25')],util['inspect'](this[_0x1b5f('0xb')][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd],{'showHidden':![],'depth':null}));ami[_0x1b5f('0x20')](_0x1b5f('0x50'),this['channels'][_0x238bd7[_0x1b5f('0x25')]][_0x1041dd]);}else{logger[_0x1b5f('0x27')](_0x1b5f('0x51'),_0x238bd7[_0x1b5f('0x25')]);}}}}}}catch(_0x323a48){logger[_0x1b5f('0x3a')](_0x1b5f('0x52'),_0x238bd7[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x323a48,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x12')]=function(_0x786b10){try{if(this[_0x1b5f('0x21')](_0x786b10)){logger[_0x1b5f('0x27')]('[%s][voiceAgentReport][agentringnoanswer]\x20event:',_0x786b10[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x786b10,{'showHidden':![],'depth':null}));if(this['channels'][_0x786b10[_0x1b5f('0x25')]]&&this[_0x1b5f('0xb')][_0x786b10[_0x1b5f('0x25')]][_0x786b10[_0x1b5f('0x26')]]){logger[_0x1b5f('0x23')](_0x1b5f('0x53'),_0x786b10['uniqueid'],_0x786b10[_0x1b5f('0x39')],_0x786b10['destuniqueid']);var _0x16032f=this[_0x1b5f('0xd')][_0x786b10['interface']];var _0x6cdd6=this[_0x1b5f('0xb')][_0x786b10[_0x1b5f('0x25')]][_0x786b10['destuniqueid']];_0x6cdd6[_0x1b5f('0x11')]=!![];_0x6cdd6[_0x1b5f('0x54')]=moment()[_0x1b5f('0x2a')](_0x1b5f('0x2b'));_0x6cdd6[_0x1b5f('0x42')]='rejected';_0x6cdd6['reason']=_0x1b5f('0x55');var _0x3b6cb5={'id':_0x16032f['id'],'name':_0x16032f[_0x1b5f('0x46')],'queue':_0x6cdd6[_0x1b5f('0x36')],'uniqueid':_0x6cdd6[_0x1b5f('0x25')]};logger[_0x1b5f('0x27')](_0x1b5f('0x56'),_0x786b10['uniqueid'],util[_0x1b5f('0x28')](_0x3b6cb5,{'showHidden':![],'depth':null}));this['emit'](util['format'](_0x1b5f('0x38'),_0x16032f[_0x1b5f('0x46')]),_0x1b5f('0x57'),_0x3b6cb5);ami[_0x1b5f('0x20')]('custom:agentringnoanswer',_0x6cdd6);this['channels'][_0x786b10[_0x1b5f('0x25')]][_0x786b10[_0x1b5f('0x26')]]=Object['assign']({},_0x6cdd6);}}}catch(_0x38fa19){logger[_0x1b5f('0x3a')](_0x1b5f('0x58'),_0x786b10[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x38fa19,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x14')]=function(_0x261b61){try{if(this[_0x1b5f('0x21')](_0x261b61)){logger[_0x1b5f('0x27')](_0x1b5f('0x59'),_0x261b61[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x261b61,{'showHidden':![],'depth':null}));if(this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]]){for(var _0x4c093e in this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]]){if(this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]]['hasOwnProperty'](_0x4c093e)&&!this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]][_0x4c093e][_0x1b5f('0x11')]&&!this['channels'][_0x261b61[_0x1b5f('0x25')]][_0x4c093e]['agentcomplete']){logger[_0x1b5f('0x23')](_0x1b5f('0x5a'),_0x261b61[_0x1b5f('0x25')],this['channels'][_0x261b61['uniqueid']][_0x4c093e][_0x1b5f('0x39')],_0x4c093e);this[_0x1b5f('0xb')][_0x261b61['uniqueid']][_0x4c093e]['agentringnoanswer']=!![];this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]][_0x4c093e][_0x1b5f('0x54')]=moment()[_0x1b5f('0x2a')]('YYYY-MM-DD\x20HH:mm:ss');this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]][_0x4c093e]['lastevent']='abandoned';this[_0x1b5f('0xb')][_0x261b61[_0x1b5f('0x25')]][_0x4c093e][_0x1b5f('0x4e')]=_0x1b5f('0x5b');logger[_0x1b5f('0x27')](_0x1b5f('0x5c'),_0x261b61[_0x1b5f('0x25')],util['inspect'](this['channels'][_0x261b61[_0x1b5f('0x25')]][_0x4c093e],{'showHidden':![],'depth':null}));ami['emit'](_0x1b5f('0x5d'),this['channels'][_0x261b61[_0x1b5f('0x25')]][_0x4c093e]);}}}}}catch(_0x2d1580){logger[_0x1b5f('0x3a')](_0x1b5f('0x5e'),_0x261b61[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x2d1580,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x1b5f('0x5f')]=function(_0x30a68f){try{if(this['isNotNull'](_0x30a68f)){logger[_0x1b5f('0x27')](_0x1b5f('0x60'),_0x30a68f[_0x1b5f('0x25')],util['inspect'](_0x30a68f,{'showHidden':![],'depth':null}));if(this[_0x1b5f('0xb')][_0x30a68f['uniqueid']]){for(var _0x16498a in this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]]){if(this['channels'][_0x30a68f['uniqueid']]['hasOwnProperty'](_0x16498a)){if(this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x3d')]&&!this['channels'][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x15')]){logger[_0x1b5f('0x23')]('[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x30a68f[_0x1b5f('0x25')],this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x39')],_0x16498a);this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x15')]=!![];this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x61')]=moment()[_0x1b5f('0x2a')](_0x1b5f('0x2b'));this[_0x1b5f('0xb')][_0x30a68f['uniqueid']][_0x16498a][_0x1b5f('0x42')]='complete';this[_0x1b5f('0xb')][_0x30a68f['uniqueid']][_0x16498a][_0x1b5f('0x4e')]=_0x30a68f[_0x1b5f('0x4e')]==_0x1b5f('0x62')?_0x1b5f('0x63'):_0x30a68f[_0x1b5f('0x4e')];this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a]['talktime']=_0x30a68f['talktime'];if(this[_0x1b5f('0xc')][_0x30a68f['queue']]&&this['voiceQueues'][_0x30a68f[_0x1b5f('0x36')]]['acw']){this[_0x1b5f('0xb')][_0x30a68f['uniqueid']][_0x16498a][_0x1b5f('0x64')]=this[_0x1b5f('0xc')][_0x30a68f[_0x1b5f('0x36')]][_0x1b5f('0x65')];this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a][_0x1b5f('0x66')]=!![];}this['agents'][_0x30a68f[_0x1b5f('0x45')]]=_['omit'](this['agents'][_0x30a68f[_0x1b5f('0x45')]],['queue',_0x1b5f('0x44')]);logger[_0x1b5f('0x27')]('[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:',_0x30a68f[_0x1b5f('0x25')],util[_0x1b5f('0x28')](this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a],{'showHidden':![],'depth':null}));ami[_0x1b5f('0x20')]('custom:agentcomplete',this[_0x1b5f('0xb')][_0x30a68f[_0x1b5f('0x25')]][_0x16498a]);logger[_0x1b5f('0x27')](_0x1b5f('0x67'),_0x30a68f['uniqueid'],util['inspect']({'id':this[_0x1b5f('0xd')][_0x30a68f[_0x1b5f('0x45')]]['id'],'destaccountcode':_0x30a68f[_0x1b5f('0x68')]},{'showHidden':![],'depth':null}));this[_0x1b5f('0x20')](util[_0x1b5f('0x2a')](_0x1b5f('0x38'),_0x30a68f['membername']),'user:agentcomplete',{'id':this['agents'][_0x30a68f[_0x1b5f('0x45')]]['id'],'destaccountcode':Number(_0x30a68f['destaccountcode'])});}}}}}}catch(_0x3a7aeb){logger[_0x1b5f('0x3a')](_0x1b5f('0x69'),_0x30a68f['uniqueid'],util[_0x1b5f('0x28')](_0x3a7aeb,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x1b5f('0x17')]=function(_0x440121){try{if(this[_0x1b5f('0x21')](_0x440121)){logger[_0x1b5f('0x27')](_0x1b5f('0x6a'),_0x440121['uniqueid'],util[_0x1b5f('0x28')](_0x440121,{'showHidden':![],'depth':null}));this['addVariable'](_0x440121['uniqueid'],_[_0x1b5f('0x6b')](_0x440121['variable'])[0x0],_0x440121[_0x1b5f('0x6c')]);if(this[_0x1b5f('0xb')][_0x440121[_0x1b5f('0x25')]]){for(var _0x3ab4cc in this[_0x1b5f('0xb')][_0x440121[_0x1b5f('0x25')]]){if(this['channels'][_0x440121['uniqueid']][_0x1b5f('0x3b')](_0x3ab4cc)){logger[_0x1b5f('0x23')](_0x1b5f('0x6d'),_0x440121[_0x1b5f('0x25')],_0x3ab4cc,_[_0x1b5f('0x6b')](_0x440121[_0x1b5f('0x6e')])[0x0],_0x440121[_0x1b5f('0x6c')]);if(_[_0x1b5f('0x22')](this[_0x1b5f('0xb')][_0x440121['uniqueid']][_0x3ab4cc][_0x1b5f('0x29')])){this[_0x1b5f('0xb')][_0x440121[_0x1b5f('0x25')]][_0x3ab4cc][_0x1b5f('0x29')]={};}this[_0x1b5f('0xb')][_0x440121['uniqueid']][_0x3ab4cc][_0x1b5f('0x29')]=this[_0x1b5f('0x29')][_0x440121[_0x1b5f('0x25')]];}}}}}catch(_0x439a72){logger['error'](_0x1b5f('0x6f'),_0x440121[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x439a72,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')]['addVariable']=function(_0x540630,_0x5805d3,_0x408d65){var _0x4781ff=[_0x1b5f('0x70'),'rtpaudioqosbridged',_0x1b5f('0x71'),'rtpaudioqosjitterbridged',_0x1b5f('0x72'),_0x1b5f('0x73'),'rtpaudioqosrtt','rtpaudioqosrttbridged',_0x1b5f('0x74'),_0x1b5f('0x75'),_0x1b5f('0x76'),_0x1b5f('0x77'),_0x1b5f('0x78'),_0x1b5f('0x79'),_0x1b5f('0x7a'),_0x1b5f('0x7b'),_0x1b5f('0x39'),'memberpenalty',_0x1b5f('0x7c')];if(!_[_0x1b5f('0x7d')](_0x5805d3)&&!_['includes'](_0x4781ff,_0x5805d3)){if(_['isUndefined'](this[_0x1b5f('0x29')][_0x540630])){this['variables'][_0x540630]={};}this[_0x1b5f('0x29')][_0x540630][_0x5805d3]=_0x408d65;}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x19')]=function(_0x5ec56c){try{if(this['isNotNull'](_0x5ec56c)){logger['debug'](_0x1b5f('0x7e'),_0x5ec56c[_0x1b5f('0x25')],util['inspect'](_0x5ec56c,{'showHidden':![],'depth':null}));if(this[_0x1b5f('0xb')][_0x5ec56c[_0x1b5f('0x25')]]){for(var _0x56346f in this[_0x1b5f('0xb')][_0x5ec56c[_0x1b5f('0x25')]]){if(this[_0x1b5f('0xb')][_0x5ec56c['uniqueid']][_0x1b5f('0x3b')](_0x56346f)){if(this[_0x1b5f('0xb')][_0x5ec56c[_0x1b5f('0x25')]][_0x56346f][_0x1b5f('0x4e')]==_0x1b5f('0x62')&&this[_0x1b5f('0xb')][_0x5ec56c['uniqueid']][_0x56346f]['agentcomplete']){logger['info']('[%s][voiceAgentReport][hangup]\x20destuniqueid:%s',_0x5ec56c['uniqueid'],_0x56346f);this[_0x1b5f('0xb')][_0x5ec56c['uniqueid']][_0x56346f][_0x1b5f('0x61')]=moment()[_0x1b5f('0x2a')]('YYYY-MM-DD\x20HH:mm:ss');}}}logger['debug'](_0x1b5f('0x7f'),_0x5ec56c[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_[_0x1b5f('0x80')](this[_0x1b5f('0xb')][_0x5ec56c[_0x1b5f('0x25')]]),{'showHidden':![],'depth':null}));ami[_0x1b5f('0x20')](_0x1b5f('0x81'),_[_0x1b5f('0x80')](this['channels'][_0x5ec56c[_0x1b5f('0x25')]]));this[_0x1b5f('0x82')](_0x5ec56c[_0x1b5f('0x25')]);}if(this[_0x1b5f('0x29')][_0x5ec56c['uniqueid']]){delete this[_0x1b5f('0x29')][_0x5ec56c[_0x1b5f('0x25')]];}}}catch(_0x454596){logger[_0x1b5f('0x3a')]('[%s][voiceAgentReport][hangup]',_0x5ec56c['uniqueid'],util[_0x1b5f('0x28')](_0x454596,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x1e')]=function(_0x14bc07){try{if(this[_0x1b5f('0x21')](_0x14bc07)){logger['debug'](_0x1b5f('0x83'),_0x14bc07[_0x1b5f('0x25')],util['inspect'](_0x14bc07,{'showHidden':![],'depth':null}));if(this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]]){for(var _0x5275a5 in this['channels'][_0x14bc07[_0x1b5f('0x84')]]){if(this['channels'][_0x14bc07[_0x1b5f('0x84')]][_0x1b5f('0x3b')](_0x5275a5)){if(_0x14bc07[_0x1b5f('0x85')]===_0x5275a5){logger[_0x1b5f('0x23')](_0x1b5f('0x86'),_0x14bc07[_0x1b5f('0x25')],this['channels'][_0x14bc07['transfereeuniqueid']][_0x5275a5][_0x1b5f('0x39')],_0x5275a5);var _0x5c7f33=moment();this[_0x1b5f('0xb')][_0x14bc07['transfereeuniqueid']][_0x5275a5][_0x1b5f('0x15')]=!![];this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]][_0x5275a5][_0x1b5f('0x61')]=moment()[_0x1b5f('0x2a')](_0x1b5f('0x2b'));this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]][_0x5275a5][_0x1b5f('0x42')]='complete';this[_0x1b5f('0xb')][_0x14bc07['transfereeuniqueid']][_0x5275a5]['reason']='transfer';this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]][_0x5275a5][_0x1b5f('0x87')]=_0x5c7f33[_0x1b5f('0x88')](this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]][_0x5275a5]['agentconnectAt'],_0x1b5f('0x89'));}}}}if(this['channels'][_0x14bc07[_0x1b5f('0x8a')]]){var _0x5d1034=this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x8a')]];this['channels'][_0x14bc07[_0x1b5f('0x8a')]]=this[_0x1b5f('0xb')][_0x14bc07[_0x1b5f('0x84')]];this['channels'][_0x14bc07[_0x1b5f('0x84')]]=_0x5d1034;}}}catch(_0x4221cf){logger[_0x1b5f('0x3a')](_0x1b5f('0x8b'),_0x14bc07[_0x1b5f('0x25')],util['inspect'](_0x4221cf,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x8c')]=function(_0x370170){try{if(this[_0x1b5f('0x21')](_0x370170)){logger[_0x1b5f('0x27')](_0x1b5f('0x8d'),_0x370170[_0x1b5f('0x25')],util['inspect'](_0x370170,{'showHidden':![],'depth':null}));if(this[_0x1b5f('0xb')][_0x370170['transfereeuniqueid']]){for(var _0x49c11f in this['channels'][_0x370170[_0x1b5f('0x84')]]){if(this[_0x1b5f('0xb')][_0x370170[_0x1b5f('0x84')]][_0x1b5f('0x3b')](_0x49c11f)){if(_0x370170[_0x1b5f('0x8e')]===_0x49c11f){logger[_0x1b5f('0x23')]('[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x370170[_0x1b5f('0x25')],this[_0x1b5f('0xb')][_0x370170['transfereeuniqueid']][_0x49c11f][_0x1b5f('0x39')],_0x49c11f);var _0x1942d6=moment();this['channels'][_0x370170['transfereeuniqueid']][_0x49c11f][_0x1b5f('0x15')]=!![];this['channels'][_0x370170[_0x1b5f('0x84')]][_0x49c11f][_0x1b5f('0x61')]=_0x1942d6;this[_0x1b5f('0xb')][_0x370170[_0x1b5f('0x84')]][_0x49c11f][_0x1b5f('0x42')]=_0x1b5f('0x8f');this[_0x1b5f('0xb')][_0x370170[_0x1b5f('0x84')]][_0x49c11f][_0x1b5f('0x4e')]='transfer';this[_0x1b5f('0xb')][_0x370170[_0x1b5f('0x84')]][_0x49c11f][_0x1b5f('0x87')]=_0x1942d6[_0x1b5f('0x88')](this[_0x1b5f('0xb')][_0x370170['transfereeuniqueid']][_0x49c11f]['agentconnectAt'],_0x1b5f('0x89'));}}}}}}catch(_0x249a50){logger['error'](_0x1b5f('0x90'),_0x370170[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0x249a50,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')]['syncMusicOnHoldStart']=function(_0x2b0651){var _0x52ceab='';try{if(this[_0x1b5f('0x21')](_0x2b0651)){logger['debug'](_0x1b5f('0x91'),_0x2b0651['uniqueid'],util[_0x1b5f('0x28')](_0x2b0651,{'showHidden':![],'depth':null}));if(_0x2b0651[_0x1b5f('0x92')]){_0x52ceab=_0x2b0651[_0x1b5f('0x92')][_0x1b5f('0x93')](0x0,_0x2b0651[_0x1b5f('0x92')]['lastIndexOf']('-'));if(this[_0x1b5f('0xd')][_0x52ceab]){logger['info'](_0x1b5f('0x94'),_0x2b0651[_0x1b5f('0x25')],_0x52ceab);this[_0x1b5f('0xd')][_0x52ceab][_0x1b5f('0x95')]=!![];}}}}catch(_0xb313d0){logger[_0x1b5f('0x3a')](_0x1b5f('0x96'),_0x2b0651[_0x1b5f('0x25')],util[_0x1b5f('0x28')](_0xb313d0,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x1c')]=function(_0x5077a9){var _0x36f47f='';try{if(this[_0x1b5f('0x21')](_0x5077a9)){logger[_0x1b5f('0x27')](_0x1b5f('0x97'),_0x5077a9[_0x1b5f('0x25')],util['inspect'](_0x5077a9,{'showHidden':![],'depth':null}));if(_0x5077a9[_0x1b5f('0x92')]){_0x36f47f=_0x5077a9[_0x1b5f('0x92')][_0x1b5f('0x93')](0x0,_0x5077a9['channel']['lastIndexOf']('-'));if(this[_0x1b5f('0xd')][_0x36f47f]){logger[_0x1b5f('0x23')]('[%s][voiceAgentReport][musiconholdstop]\x20interface:%s',_0x5077a9[_0x1b5f('0x25')],_0x36f47f);this['agents'][_0x36f47f]['onhold']=![];}}}}catch(_0x15872d){logger[_0x1b5f('0x3a')](_0x1b5f('0x98'),_0x5077a9['uniqueid'],util[_0x1b5f('0x28')](_0x15872d,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x1b5f('0x1f')][_0x1b5f('0x82')]=function(_0x14bf82,_0x140e10=0x2710){if(this[_0x1b5f('0xb')][_0x14bf82]){setTimeout(()=>{delete this['channels'][_0x14bf82];},_0x140e10);}};module[_0x1b5f('0x99')]=VoiceAgentReport;