Built motion from commit 52c8a02d.|2.6.29
[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 _0xcebb=['agents','variables','agentcalled','syncAgentCalled','bind','agentconnect','syncAgentConnect','agentringnoanswer','syncQueueCallerAbandon','agentcomplete','syncAgentComplete','varset','syncVarSet','musiconholdstart','musiconholdstop','syncMusicOnHoldStop','syncAttendedTransfer','syncBlindTransfer','prototype','emit','isNotNull','isUndefined','info','uniqueid','membername','destuniqueid','debug','[%s][voiceAgentReport][agentcalled]\x20event:','inspect','interface','queue','format','YYYY-MM-DD\x20HH:mm:ss','mandatoryDisposition','type','inbound','voice','event','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','custom:agentcalled','calleridnum','user:%s','user:called','error','hasOwnProperty','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','connectedlinename','connectedlinenum','destchannelstate','destchannelstatedesc','holdtime','lastevent','connect','merge','pick','destconnectedlinenum','name','accountcode','user:agentconnect','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere','agentringnoanswerAt','answeredelsewheredestinationuniqueid','answered_elsewhere','reason','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','custom:agentansweredelsewhere','[%s][voiceAgentReport][agentconnect]','syncAgentRingNoAnswer','rejected','custom:agentringnoanswer','assign','[%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]','[%s][voiceAgentReport][agentcomplete]\x20event:','complete','transfer','agent','talktime','acw','acwtime','acwTimeout','agentacw','omit','[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:','custom:agentcomplete','destaccountcode','user:agentcomplete','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','addVariable','keys','variable','value','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqosrtt','sipcallid','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberlastcall','memberpenalty','memberrealtime','isNil','syncHangup','[%s][voiceAgentReport][hangup]\x20destuniqueid:%s','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','values','deleteChannelAfterTimeout','[%s][voiceAgentReport][hangup]','[%s][voiceAgentReport][attendedtransfer]\x20event:','transfereeuniqueid','origtransfereruniqueid','agentcompleteAt','diff','seconds','secondtransfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','syncMusicOnHoldStart','[%s][voiceAgentReport][musiconholdstart]\x20event:','channel','substring','lastIndexOf','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s','onhold','[%s][voiceAgentReport][musiconholdstart]','[%s][voiceAgentReport][musiconholdstop]\x20event:','lodash','moment','../../../config/environment','../../../config/logger','../ami','redis','defaults','localhost','socket.io-emitter','channels','voiceQueues'];(function(_0x26da89,_0x264785){var _0xc95b7b=function(_0x230e5b){while(--_0x230e5b){_0x26da89['push'](_0x26da89['shift']());}};_0xc95b7b(++_0x264785);}(_0xcebb,0x8c));var _0xbceb=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xcebb[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0xbceb('0x0'));var moment=require(_0xbceb('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xbceb('0x2'));var logger=require(_0xbceb('0x3'))('ami');var ami=require(_0xbceb('0x4'));config[_0xbceb('0x5')]=_[_0xbceb('0x6')](config[_0xbceb('0x5')],{'host':_0xbceb('0x7'),'port':0x18eb});var io=require(_0xbceb('0x8'))(new Redis(config[_0xbceb('0x5')]));function VoiceAgentReport(_0xcdc7ac){this[_0xbceb('0x9')]={};this['voiceChannels']=_0xcdc7ac['channels'];this[_0xbceb('0xa')]=_0xcdc7ac[_0xbceb('0xa')];this[_0xbceb('0xb')]=_0xcdc7ac[_0xbceb('0xb')];this[_0xbceb('0xc')]={};ami['on'](_0xbceb('0xd'),this[_0xbceb('0xe')][_0xbceb('0xf')](this));ami['on'](_0xbceb('0x10'),this[_0xbceb('0x11')][_0xbceb('0xf')](this));ami['on'](_0xbceb('0x12'),this['syncAgentRingNoAnswer'][_0xbceb('0xf')](this));ami['on']('queuecallerabandon',this[_0xbceb('0x13')][_0xbceb('0xf')](this));ami['on'](_0xbceb('0x14'),this[_0xbceb('0x15')][_0xbceb('0xf')](this));ami['on'](_0xbceb('0x16'),this[_0xbceb('0x17')][_0xbceb('0xf')](this));ami['on']('hangup',this['syncHangup'][_0xbceb('0xf')](this));ami['on'](_0xbceb('0x18'),this['syncMusicOnHoldStart']['bind'](this));ami['on'](_0xbceb('0x19'),this[_0xbceb('0x1a')][_0xbceb('0xf')](this));ami['on']('attendedtransfer',this[_0xbceb('0x1b')][_0xbceb('0xf')](this));ami['on']('blindtransfer',this[_0xbceb('0x1c')][_0xbceb('0xf')](this));}VoiceAgentReport[_0xbceb('0x1d')]['emit']=function(_0x21bd85,_0x42f972,_0x53edd4){io['to'](_0x21bd85)[_0xbceb('0x1e')](_0x42f972,_0x53edd4);};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x1f')]=function(_0x279622){return _0x279622!==null&&!_[_0xbceb('0x20')](_0x279622);};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0xe')]=function(_0xcefd61){try{if(this[_0xbceb('0x1f')](_0xcefd61)){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called',_0xcefd61[_0xbceb('0x22')],_0xcefd61[_0xbceb('0x23')],_0xcefd61[_0xbceb('0x24')]);logger[_0xbceb('0x25')](_0xbceb('0x26'),_0xcefd61[_0xbceb('0x22')],util[_0xbceb('0x27')](_0xcefd61,{'showHidden':![],'depth':null}));if(_['isUndefined'](this['channels'][_0xcefd61['uniqueid']])){this[_0xbceb('0x9')][_0xcefd61[_0xbceb('0x22')]]={};}var _0x2edf50=this['agents'][_0xcefd61[_0xbceb('0x28')]];var _0xc87e6b=this[_0xbceb('0x9')][_0xcefd61[_0xbceb('0x22')]][_0xcefd61[_0xbceb('0x24')]];var _0x4a8562=this[_0xbceb('0xa')][_0xcefd61[_0xbceb('0x29')]];var _0x297638=this[_0xbceb('0xc')][_0xcefd61[_0xbceb('0x22')]];if(_[_0xbceb('0x20')](_0xc87e6b)){_0xc87e6b={'agentcalledAt':moment()[_0xbceb('0x2a')](_0xbceb('0x2b')),'lastevent':'called','mandatoryDisposition':_0x4a8562&&_0x4a8562[_0xbceb('0x2c')]?_0x4a8562[_0xbceb('0x2c')]:![],'type':_0x4a8562&&_0x4a8562[_0xbceb('0x2d')]?_0x4a8562[_0xbceb('0x2d')]:_0xbceb('0x2e'),'variables':_0x297638,'motionChannel':_0xbceb('0x2f')};}Object['assign'](_0xc87e6b,_['omit'](_0xcefd61,[_0xbceb('0x30'),'privilege']));this[_0xbceb('0x9')][_0xcefd61['uniqueid']][_0xcefd61[_0xbceb('0x24')]]=_0xc87e6b;logger[_0xbceb('0x25')](_0xbceb('0x31'),_0xcefd61[_0xbceb('0x22')],util[_0xbceb('0x27')](_0xc87e6b,{'showHidden':![],'depth':null}));ami[_0xbceb('0x1e')](_0xbceb('0x32'),_0xc87e6b);var _0xef6b60={'id':_0x2edf50['id'],'calleridnum':_0xc87e6b[_0xbceb('0x33')],'queue':_0xc87e6b[_0xbceb('0x29')],'variables':_0xc87e6b[_0xbceb('0xc')],'uniqueid':_0xcefd61['uniqueid']};logger[_0xbceb('0x25')]('[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:',_0xcefd61[_0xbceb('0x22')],util[_0xbceb('0x27')](_0xef6b60,{'showHidden':![],'depth':null}));this[_0xbceb('0x1e')](util[_0xbceb('0x2a')](_0xbceb('0x34'),_0xcefd61[_0xbceb('0x23')]),_0xbceb('0x35'),_0xef6b60);}}catch(_0x17126c){logger[_0xbceb('0x36')]('[%s][voiceAgentReport][agentcalled]',_0xcefd61[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x17126c,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')]['syncAgentConnect']=function(_0x142904){try{if(this[_0xbceb('0x1f')](_0x142904)){if(this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]]){for(var _0x165413 in this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]]){if(this['channels'][_0x142904[_0xbceb('0x22')]][_0xbceb('0x37')](_0x165413)){if(_0x142904[_0xbceb('0x24')]===_0x165413){logger[_0xbceb('0x21')](_0xbceb('0x38'),_0x142904[_0xbceb('0x22')],_0x142904[_0xbceb('0x23')],_0x142904[_0xbceb('0x24')]);this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x39')]=moment()[_0xbceb('0x2a')](_0xbceb('0x2b'));this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x3a')]=_0x142904[_0xbceb('0x3a')];this['channels'][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x3b')]=_0x142904[_0xbceb('0x3b')];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]['destchannelstate']=_0x142904[_0xbceb('0x3c')];this[_0xbceb('0x9')][_0x142904['uniqueid']][_0x165413][_0xbceb('0x3d')]=_0x142904[_0xbceb('0x3d')];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x3e')]=_0x142904['holdtime'];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x3f')]=_0xbceb('0x40');_[_0xbceb('0x41')](this[_0xbceb('0xb')][_0x142904[_0xbceb('0x28')]],_[_0xbceb('0x42')](_0x142904,[_0xbceb('0x29'),_0xbceb('0x43')]));var _0x5bb62c=this[_0xbceb('0xb')][_0x142904[_0xbceb('0x28')]];var _0x4c10a3={'id':_0x5bb62c['id'],'name':_0x5bb62c[_0xbceb('0x44')],'agentconnected':!![],'destaccountcode':_0x5bb62c[_0xbceb('0x45')],'destconnectedlinenum':this['channels'][_0x142904['uniqueid']][_0x142904['destuniqueid']]['exten'],'queue':this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x142904['destuniqueid']][_0xbceb('0x29')],'uniqueid':this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x142904[_0xbceb('0x24')]][_0xbceb('0x22')]};ami[_0xbceb('0x1e')]('custom:agentconnect',this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x142904[_0xbceb('0x24')]]);this[_0xbceb('0x1e')](util[_0xbceb('0x2a')](_0xbceb('0x34'),_0x142904[_0xbceb('0x23')]),_0xbceb('0x46'),_0x4c10a3);}else if(!this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x12')]&&!this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]['agentcomplete']){logger[_0xbceb('0x21')](_0xbceb('0x47'),_0x142904[_0xbceb('0x22')],this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]['membername'],_0x165413);this[_0xbceb('0x9')][_0x142904['uniqueid']][_0x165413][_0xbceb('0x12')]=!![];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x48')]=moment()[_0xbceb('0x2a')]('YYYY-MM-DD\x20HH:mm:ss');this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x49')]=_0x142904[_0xbceb('0x24')];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]['answeredelsewheremembername']=_0x142904[_0xbceb('0x23')];this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]['lastevent']=_0xbceb('0x4a');this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413][_0xbceb('0x4b')]=_0xbceb('0x4a');logger[_0xbceb('0x25')](_0xbceb('0x4c'),_0x142904[_0xbceb('0x22')],util[_0xbceb('0x27')](this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413],{'showHidden':![],'depth':null}));ami[_0xbceb('0x1e')](_0xbceb('0x4d'),this[_0xbceb('0x9')][_0x142904[_0xbceb('0x22')]][_0x165413]);}else{logger[_0xbceb('0x25')]('[%s][voiceAgentReport][agentconnect]\x20Else\x20path\x20should\x20never\x20be\x20taken',_0x142904[_0xbceb('0x22')]);}}}}}}catch(_0xe4f2a2){logger['error'](_0xbceb('0x4e'),_0x142904['uniqueid'],util['inspect'](_0xe4f2a2,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xbceb('0x4f')]=function(_0x78f1d8){try{if(this['isNotNull'](_0x78f1d8)){logger[_0xbceb('0x25')]('[%s][voiceAgentReport][agentringnoanswer]\x20event:',_0x78f1d8[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x78f1d8,{'showHidden':![],'depth':null}));if(this[_0xbceb('0x9')][_0x78f1d8[_0xbceb('0x22')]]&&this[_0xbceb('0x9')][_0x78f1d8[_0xbceb('0x22')]][_0x78f1d8['destuniqueid']]){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected',_0x78f1d8[_0xbceb('0x22')],_0x78f1d8[_0xbceb('0x23')],_0x78f1d8['destuniqueid']);var _0x2ef1a1=this[_0xbceb('0xb')][_0x78f1d8[_0xbceb('0x28')]];var _0x1f18e4=this['channels'][_0x78f1d8[_0xbceb('0x22')]][_0x78f1d8[_0xbceb('0x24')]];_0x1f18e4[_0xbceb('0x12')]=!![];_0x1f18e4[_0xbceb('0x48')]=moment()[_0xbceb('0x2a')](_0xbceb('0x2b'));_0x1f18e4[_0xbceb('0x3f')]='rejected';_0x1f18e4[_0xbceb('0x4b')]=_0xbceb('0x50');var _0x4eb4c8={'id':_0x2ef1a1['id'],'name':_0x2ef1a1[_0xbceb('0x44')],'queue':_0x1f18e4['queue'],'uniqueid':_0x1f18e4['uniqueid']};logger['debug']('[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:',_0x78f1d8[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x4eb4c8,{'showHidden':![],'depth':null}));this[_0xbceb('0x1e')](util[_0xbceb('0x2a')](_0xbceb('0x34'),_0x2ef1a1[_0xbceb('0x44')]),'user:agentringnoanswer',_0x4eb4c8);ami['emit'](_0xbceb('0x51'),_0x1f18e4);this[_0xbceb('0x9')][_0x78f1d8[_0xbceb('0x22')]][_0x78f1d8[_0xbceb('0x24')]]=Object[_0xbceb('0x52')]({},_0x1f18e4);}}}catch(_0x46dccc){logger[_0xbceb('0x36')](_0xbceb('0x53'),_0x78f1d8[_0xbceb('0x22')],util['inspect'](_0x46dccc,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x13')]=function(_0x53ed4c){try{if(this[_0xbceb('0x1f')](_0x53ed4c)){logger[_0xbceb('0x25')](_0xbceb('0x54'),_0x53ed4c[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x53ed4c,{'showHidden':![],'depth':null}));if(this['channels'][_0x53ed4c['uniqueid']]){for(var _0x1c675a in this['channels'][_0x53ed4c[_0xbceb('0x22')]]){if(this['channels'][_0x53ed4c['uniqueid']]['hasOwnProperty'](_0x1c675a)&&!this[_0xbceb('0x9')][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a][_0xbceb('0x12')]&&!this[_0xbceb('0x9')][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a][_0xbceb('0x14')]){logger['info'](_0xbceb('0x55'),_0x53ed4c[_0xbceb('0x22')],this[_0xbceb('0x9')][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a][_0xbceb('0x23')],_0x1c675a);this[_0xbceb('0x9')][_0x53ed4c['uniqueid']][_0x1c675a][_0xbceb('0x12')]=!![];this[_0xbceb('0x9')][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a]['agentringnoanswerAt']=moment()[_0xbceb('0x2a')](_0xbceb('0x2b'));this['channels'][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a][_0xbceb('0x3f')]='abandoned';this['channels'][_0x53ed4c['uniqueid']][_0x1c675a][_0xbceb('0x4b')]=_0xbceb('0x56');logger[_0xbceb('0x25')](_0xbceb('0x57'),_0x53ed4c['uniqueid'],util[_0xbceb('0x27')](this['channels'][_0x53ed4c['uniqueid']][_0x1c675a],{'showHidden':![],'depth':null}));ami['emit'](_0xbceb('0x58'),this[_0xbceb('0x9')][_0x53ed4c[_0xbceb('0x22')]][_0x1c675a]);}}}}}catch(_0x166a06){logger[_0xbceb('0x36')](_0xbceb('0x59'),_0x53ed4c[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x166a06,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xbceb('0x15')]=function(_0x307e74){try{if(this[_0xbceb('0x1f')](_0x307e74)){logger['debug'](_0xbceb('0x5a'),_0x307e74[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x307e74,{'showHidden':![],'depth':null}));if(this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]]){for(var _0x8e27eb in this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]]){if(this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]]['hasOwnProperty'](_0x8e27eb)){if(this[_0xbceb('0x9')][_0x307e74['uniqueid']][_0x8e27eb][_0xbceb('0x39')]&&!this[_0xbceb('0x9')][_0x307e74['uniqueid']][_0x8e27eb][_0xbceb('0x14')]){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x307e74[_0xbceb('0x22')],this[_0xbceb('0x9')][_0x307e74['uniqueid']][_0x8e27eb][_0xbceb('0x23')],_0x8e27eb);this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]][_0x8e27eb][_0xbceb('0x14')]=!![];this[_0xbceb('0x9')][_0x307e74['uniqueid']][_0x8e27eb]['agentcompleteAt']=moment()[_0xbceb('0x2a')](_0xbceb('0x2b'));this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]][_0x8e27eb]['lastevent']=_0xbceb('0x5b');this[_0xbceb('0x9')][_0x307e74['uniqueid']][_0x8e27eb]['reason']=_0x307e74[_0xbceb('0x4b')]==_0xbceb('0x5c')?_0xbceb('0x5d'):_0x307e74[_0xbceb('0x4b')];this['channels'][_0x307e74[_0xbceb('0x22')]][_0x8e27eb][_0xbceb('0x5e')]=_0x307e74[_0xbceb('0x5e')];if(this[_0xbceb('0xa')][_0x307e74['queue']]&&this[_0xbceb('0xa')][_0x307e74[_0xbceb('0x29')]][_0xbceb('0x5f')]){this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]][_0x8e27eb][_0xbceb('0x60')]=this[_0xbceb('0xa')][_0x307e74[_0xbceb('0x29')]][_0xbceb('0x61')];this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]][_0x8e27eb][_0xbceb('0x62')]=!![];}this['agents'][_0x307e74[_0xbceb('0x28')]]=_[_0xbceb('0x63')](this[_0xbceb('0xb')][_0x307e74[_0xbceb('0x28')]],[_0xbceb('0x29'),_0xbceb('0x43')]);logger['debug'](_0xbceb('0x64'),_0x307e74[_0xbceb('0x22')],util['inspect'](this[_0xbceb('0x9')][_0x307e74[_0xbceb('0x22')]][_0x8e27eb],{'showHidden':![],'depth':null}));ami['emit'](_0xbceb('0x65'),this['channels'][_0x307e74[_0xbceb('0x22')]][_0x8e27eb]);logger[_0xbceb('0x25')]('[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:',_0x307e74[_0xbceb('0x22')],util[_0xbceb('0x27')]({'id':this[_0xbceb('0xb')][_0x307e74[_0xbceb('0x28')]]['id'],'destaccountcode':_0x307e74[_0xbceb('0x66')]},{'showHidden':![],'depth':null}));this[_0xbceb('0x1e')](util[_0xbceb('0x2a')]('user:%s',_0x307e74[_0xbceb('0x23')]),_0xbceb('0x67'),{'id':this[_0xbceb('0xb')][_0x307e74['interface']]['id'],'destaccountcode':Number(_0x307e74['destaccountcode'])});}}}}}}catch(_0x442eff){logger[_0xbceb('0x36')](_0xbceb('0x68'),_0x307e74[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x442eff,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xbceb('0x17')]=function(_0xe16abb){try{if(this[_0xbceb('0x1f')](_0xe16abb)){logger['debug'](_0xbceb('0x69'),_0xe16abb[_0xbceb('0x22')],util[_0xbceb('0x27')](_0xe16abb,{'showHidden':![],'depth':null}));this[_0xbceb('0x6a')](_0xe16abb[_0xbceb('0x22')],_[_0xbceb('0x6b')](_0xe16abb[_0xbceb('0x6c')])[0x0],_0xe16abb[_0xbceb('0x6d')]);if(this['channels'][_0xe16abb[_0xbceb('0x22')]]){for(var _0x76a3d4 in this[_0xbceb('0x9')][_0xe16abb[_0xbceb('0x22')]]){if(this[_0xbceb('0x9')][_0xe16abb['uniqueid']]['hasOwnProperty'](_0x76a3d4)){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s',_0xe16abb[_0xbceb('0x22')],_0x76a3d4,_['keys'](_0xe16abb['variable'])[0x0],_0xe16abb[_0xbceb('0x6d')]);if(_[_0xbceb('0x20')](this['channels'][_0xe16abb[_0xbceb('0x22')]][_0x76a3d4]['variables'])){this[_0xbceb('0x9')][_0xe16abb['uniqueid']][_0x76a3d4]['variables']={};}this['channels'][_0xe16abb[_0xbceb('0x22')]][_0x76a3d4]['variables']=this[_0xbceb('0xc')][_0xe16abb[_0xbceb('0x22')]];}}}}}catch(_0xbc698e){logger['error'](_0xbceb('0x6e'),_0xe16abb[_0xbceb('0x22')],util['inspect'](_0xbc698e,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x6a')]=function(_0x108442,_0xdc0d8e,_0x5eaae6){var _0x4987d0=[_0xbceb('0x6f'),'rtpaudioqosbridged',_0xbceb('0x70'),_0xbceb('0x71'),_0xbceb('0x72'),'rtpaudioqoslossbridged',_0xbceb('0x73'),'rtpaudioqosrttbridged',_0xbceb('0x74'),'sipuri',_0xbceb('0x75'),_0xbceb('0x76'),_0xbceb('0x77'),_0xbceb('0x78'),_0xbceb('0x79'),_0xbceb('0x7a'),_0xbceb('0x23'),_0xbceb('0x7b'),_0xbceb('0x7c')];if(!_[_0xbceb('0x7d')](_0xdc0d8e)&&!_['includes'](_0x4987d0,_0xdc0d8e)){if(_[_0xbceb('0x20')](this[_0xbceb('0xc')][_0x108442])){this[_0xbceb('0xc')][_0x108442]={};}this[_0xbceb('0xc')][_0x108442][_0xdc0d8e]=_0x5eaae6;}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x7e')]=function(_0x70b3b7){try{if(this[_0xbceb('0x1f')](_0x70b3b7)){logger['debug']('[%s][voiceAgentReport][hangup]\x20event:',_0x70b3b7[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x70b3b7,{'showHidden':![],'depth':null}));if(this['channels'][_0x70b3b7['uniqueid']]){for(var _0xa0ddf9 in this[_0xbceb('0x9')][_0x70b3b7[_0xbceb('0x22')]]){if(this['channels'][_0x70b3b7[_0xbceb('0x22')]][_0xbceb('0x37')](_0xa0ddf9)){if(this[_0xbceb('0x9')][_0x70b3b7[_0xbceb('0x22')]][_0xa0ddf9][_0xbceb('0x4b')]==_0xbceb('0x5c')&&this[_0xbceb('0x9')][_0x70b3b7[_0xbceb('0x22')]][_0xa0ddf9][_0xbceb('0x14')]){logger[_0xbceb('0x21')](_0xbceb('0x7f'),_0x70b3b7[_0xbceb('0x22')],_0xa0ddf9);this['channels'][_0x70b3b7[_0xbceb('0x22')]][_0xa0ddf9]['agentcompleteAt']=moment()[_0xbceb('0x2a')](_0xbceb('0x2b'));}}}logger[_0xbceb('0x25')](_0xbceb('0x80'),_0x70b3b7['uniqueid'],util[_0xbceb('0x27')](_['values'](this[_0xbceb('0x9')][_0x70b3b7[_0xbceb('0x22')]]),{'showHidden':![],'depth':null}));ami[_0xbceb('0x1e')]('custom:voiceAgentReport',_[_0xbceb('0x81')](this[_0xbceb('0x9')][_0x70b3b7[_0xbceb('0x22')]]));this[_0xbceb('0x82')](_0x70b3b7[_0xbceb('0x22')]);}if(this[_0xbceb('0xc')][_0x70b3b7[_0xbceb('0x22')]]){delete this[_0xbceb('0xc')][_0x70b3b7[_0xbceb('0x22')]];}}}catch(_0x49cc56){logger['error'](_0xbceb('0x83'),_0x70b3b7['uniqueid'],util[_0xbceb('0x27')](_0x49cc56,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')]['syncAttendedTransfer']=function(_0x40362d){try{if(this['isNotNull'](_0x40362d)){logger[_0xbceb('0x25')](_0xbceb('0x84'),_0x40362d[_0xbceb('0x22')],util['inspect'](_0x40362d,{'showHidden':![],'depth':null}));if(this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]]){for(var _0x4b93f8 in this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]]){if(this[_0xbceb('0x9')][_0x40362d['transfereeuniqueid']][_0xbceb('0x37')](_0x4b93f8)){if(_0x40362d[_0xbceb('0x86')]===_0x4b93f8){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x40362d[_0xbceb('0x22')],this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]][_0x4b93f8][_0xbceb('0x23')],_0x4b93f8);var _0x1d46db=moment();this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]][_0x4b93f8][_0xbceb('0x14')]=!![];this['channels'][_0x40362d[_0xbceb('0x85')]][_0x4b93f8][_0xbceb('0x87')]=moment()[_0xbceb('0x2a')]('YYYY-MM-DD\x20HH:mm:ss');this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]][_0x4b93f8][_0xbceb('0x3f')]=_0xbceb('0x5b');this['channels'][_0x40362d[_0xbceb('0x85')]][_0x4b93f8][_0xbceb('0x4b')]='transfer';this['channels'][_0x40362d['transfereeuniqueid']][_0x4b93f8]['talktime']=_0x1d46db[_0xbceb('0x88')](this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x85')]][_0x4b93f8]['agentconnectAt'],_0xbceb('0x89'));}}}}if(this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x8a')]]){var _0x18abc8=this['channels'][_0x40362d[_0xbceb('0x8a')]];this[_0xbceb('0x9')][_0x40362d[_0xbceb('0x8a')]]=this[_0xbceb('0x9')][_0x40362d['transfereeuniqueid']];this['channels'][_0x40362d['transfereeuniqueid']]=_0x18abc8;}}}catch(_0x3dc72e){logger[_0xbceb('0x36')]('[%s][voiceAgentReport][attendedtransfer]',_0x40362d[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x3dc72e,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x1c')]=function(_0x3606f1){try{if(this['isNotNull'](_0x3606f1)){logger[_0xbceb('0x25')](_0xbceb('0x8b'),_0x3606f1[_0xbceb('0x22')],util['inspect'](_0x3606f1,{'showHidden':![],'depth':null}));if(this[_0xbceb('0x9')][_0x3606f1['transfereeuniqueid']]){for(var _0x40945f in this[_0xbceb('0x9')][_0x3606f1['transfereeuniqueid']]){if(this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]]['hasOwnProperty'](_0x40945f)){if(_0x3606f1[_0xbceb('0x8c')]===_0x40945f){logger[_0xbceb('0x21')](_0xbceb('0x8d'),_0x3606f1[_0xbceb('0x22')],this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f][_0xbceb('0x23')],_0x40945f);var _0x453a09=moment();this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f][_0xbceb('0x14')]=!![];this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f][_0xbceb('0x87')]=_0x453a09;this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f]['lastevent']=_0xbceb('0x5b');this['channels'][_0x3606f1['transfereeuniqueid']][_0x40945f]['reason']=_0xbceb('0x5c');this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f][_0xbceb('0x5e')]=_0x453a09[_0xbceb('0x88')](this[_0xbceb('0x9')][_0x3606f1[_0xbceb('0x85')]][_0x40945f][_0xbceb('0x39')],'seconds');}}}}}}catch(_0x3b3062){logger[_0xbceb('0x36')]('[%s][voiceAgentReport][blindtransfer]',_0x3606f1[_0xbceb('0x22')],util['inspect'](_0x3b3062,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xbceb('0x8e')]=function(_0x481633){var _0x3bc8bb='';try{if(this[_0xbceb('0x1f')](_0x481633)){logger[_0xbceb('0x25')](_0xbceb('0x8f'),_0x481633[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x481633,{'showHidden':![],'depth':null}));if(_0x481633['channel']){_0x3bc8bb=_0x481633[_0xbceb('0x90')][_0xbceb('0x91')](0x0,_0x481633[_0xbceb('0x90')][_0xbceb('0x92')]('-'));if(this[_0xbceb('0xb')][_0x3bc8bb]){logger[_0xbceb('0x21')](_0xbceb('0x93'),_0x481633['uniqueid'],_0x3bc8bb);this[_0xbceb('0xb')][_0x3bc8bb][_0xbceb('0x94')]=!![];}}}}catch(_0x1d16cc){logger[_0xbceb('0x36')](_0xbceb('0x95'),_0x481633[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x1d16cc,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x1a')]=function(_0x1f2061){var _0x47b77c='';try{if(this[_0xbceb('0x1f')](_0x1f2061)){logger[_0xbceb('0x25')](_0xbceb('0x96'),_0x1f2061['uniqueid'],util['inspect'](_0x1f2061,{'showHidden':![],'depth':null}));if(_0x1f2061[_0xbceb('0x90')]){_0x47b77c=_0x1f2061[_0xbceb('0x90')][_0xbceb('0x91')](0x0,_0x1f2061[_0xbceb('0x90')][_0xbceb('0x92')]('-'));if(this['agents'][_0x47b77c]){logger[_0xbceb('0x21')]('[%s][voiceAgentReport][musiconholdstop]\x20interface:%s',_0x1f2061[_0xbceb('0x22')],_0x47b77c);this['agents'][_0x47b77c]['onhold']=![];}}}}catch(_0x3136b6){logger['error']('[%s][voiceAgentReport][musiconholdstop]',_0x1f2061[_0xbceb('0x22')],util[_0xbceb('0x27')](_0x3136b6,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xbceb('0x1d')][_0xbceb('0x82')]=function(_0x1505dc,_0x4b6805=0x2710){if(this[_0xbceb('0x9')][_0x1505dc]){setTimeout(()=>{delete this[_0xbceb('0x9')][_0x1505dc];},_0x4b6805);}};module['exports']=VoiceAgentReport;