Built motion from commit 953226e6.|2.6.32
[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 _0x2c8f=['YYYY-MM-DD\x20HH:mm:ss','connectedlinenum','destchannelstate','destchannelstatedesc','holdtime','lastevent','merge','pick','destconnectedlinenum','name','accountcode','user:agentconnect','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere','answeredelsewheredestinationuniqueid','answeredelsewheremembername','reason','answered_elsewhere','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','error','[%s][voiceAgentReport][agentringnoanswer]\x20event:','rejected','user:agentringnoanswer','custom:agentringnoanswer','[%s][voiceAgentReport][agentringnoanswer]','syncQueueCallerAbandon','agentringnoanswerAt','abandoned','[%s][voiceAgentReport][queuecallerabandon]\x20sending\x20agentqueuecallerabandon\x20event:','custom:agentqueuecallerabandon','[%s][voiceAgentReport][queuecallerabandon]','[%s][voiceAgentReport][agentcomplete]\x20event:','agentcompleteAt','complete','transfer','acwtime','acwTimeout','[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:','[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:','destaccountcode','user:agentcomplete','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','addVariable','keys','variable','value','[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberpenalty','memberrealtime','includes','[%s][voiceAgentReport][hangup]\x20event:','[%s][voiceAgentReport][hangup]\x20destuniqueid:%s','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','values','deleteChannelAfterTimeout','transfereeuniqueid','[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','talktime','diff','seconds','secondtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]','syncBlindTransfer','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','[%s][voiceAgentReport][blindtransfer]','[%s][voiceAgentReport][musiconholdstart]\x20event:','channel','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s','onhold','[%s][voiceAgentReport][musiconholdstart]','syncMusicOnHoldStop','[%s][voiceAgentReport][musiconholdstop]\x20event:','substring','lastIndexOf','[%s][voiceAgentReport][musiconholdstop]','exports','moment','../../../config/logger','ami','../ami','redis','localhost','socket.io-emitter','voiceChannels','channels','voiceQueues','agents','agentcalled','syncAgentCalled','bind','agentconnect','syncAgentConnect','agentringnoanswer','syncAgentRingNoAnswer','queuecallerabandon','agentcomplete','syncAgentComplete','varset','syncVarSet','hangup','syncHangup','musiconholdstart','syncMusicOnHoldStart','musiconholdstop','attendedtransfer','syncAttendedTransfer','blindtransfer','prototype','emit','isNotNull','isUndefined','info','[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','membername','destuniqueid','debug','[%s][voiceAgentReport][agentcalled]\x20event:','inspect','uniqueid','interface','queue','variables','format','called','type','inbound','voice','assign','omit','event','privilege','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:','user:%s','user:called','[%s][voiceAgentReport][agentcalled]','hasOwnProperty','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt'];(function(_0x53c32b,_0x11b312){var _0xd0de4f=function(_0x27422f){while(--_0x27422f){_0x53c32b['push'](_0x53c32b['shift']());}};_0xd0de4f(++_0x11b312);}(_0x2c8f,0x192));var _0xf2c8=function(_0x101cbe,_0x24c660){_0x101cbe=_0x101cbe-0x0;var _0x1f70f7=_0x2c8f[_0x101cbe];return _0x1f70f7;};'use strict';var _=require('lodash');var moment=require(_0xf2c8('0x0'));var util=require('util');var Redis=require('ioredis');var config=require('../../../config/environment');var logger=require(_0xf2c8('0x1'))(_0xf2c8('0x2'));var ami=require(_0xf2c8('0x3'));config['redis']=_['defaults'](config[_0xf2c8('0x4')],{'host':_0xf2c8('0x5'),'port':0x18eb});var io=require(_0xf2c8('0x6'))(new Redis(config[_0xf2c8('0x4')]));function VoiceAgentReport(_0x2785ee){this['channels']={};this[_0xf2c8('0x7')]=_0x2785ee[_0xf2c8('0x8')];this[_0xf2c8('0x9')]=_0x2785ee[_0xf2c8('0x9')];this[_0xf2c8('0xa')]=_0x2785ee[_0xf2c8('0xa')];this['variables']={};ami['on'](_0xf2c8('0xb'),this[_0xf2c8('0xc')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0xe'),this[_0xf2c8('0xf')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x10'),this[_0xf2c8('0x11')]['bind'](this));ami['on'](_0xf2c8('0x12'),this['syncQueueCallerAbandon'][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x13'),this[_0xf2c8('0x14')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x15'),this[_0xf2c8('0x16')]['bind'](this));ami['on'](_0xf2c8('0x17'),this[_0xf2c8('0x18')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x19'),this[_0xf2c8('0x1a')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x1b'),this['syncMusicOnHoldStop'][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x1c'),this[_0xf2c8('0x1d')][_0xf2c8('0xd')](this));ami['on'](_0xf2c8('0x1e'),this['syncBlindTransfer']['bind'](this));}VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x20')]=function(_0x2c6d7a,_0x283ecf,_0x516d99){io['to'](_0x2c6d7a)[_0xf2c8('0x20')](_0x283ecf,_0x516d99);};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x21')]=function(_0x47b5e4){return _0x47b5e4!==null&&!_[_0xf2c8('0x22')](_0x47b5e4);};VoiceAgentReport[_0xf2c8('0x1f')]['syncAgentCalled']=function(_0x5b1e44){try{if(this[_0xf2c8('0x21')](_0x5b1e44)){logger[_0xf2c8('0x23')](_0xf2c8('0x24'),_0x5b1e44['uniqueid'],_0x5b1e44[_0xf2c8('0x25')],_0x5b1e44[_0xf2c8('0x26')]);logger[_0xf2c8('0x27')](_0xf2c8('0x28'),_0x5b1e44['uniqueid'],util[_0xf2c8('0x29')](_0x5b1e44,{'showHidden':![],'depth':null}));if(_[_0xf2c8('0x22')](this[_0xf2c8('0x8')][_0x5b1e44[_0xf2c8('0x2a')]])){this[_0xf2c8('0x8')][_0x5b1e44['uniqueid']]={};}var _0x93707c=this['agents'][_0x5b1e44[_0xf2c8('0x2b')]];var _0x2e2305=this[_0xf2c8('0x8')][_0x5b1e44[_0xf2c8('0x2a')]][_0x5b1e44[_0xf2c8('0x26')]];var _0x3160a5=this[_0xf2c8('0x9')][_0x5b1e44[_0xf2c8('0x2c')]];var _0x33f1b0=this[_0xf2c8('0x2d')][_0x5b1e44[_0xf2c8('0x2a')]];if(_[_0xf2c8('0x22')](_0x2e2305)){_0x2e2305={'agentcalledAt':moment()[_0xf2c8('0x2e')]('YYYY-MM-DD\x20HH:mm:ss'),'lastevent':_0xf2c8('0x2f'),'mandatoryDisposition':_0x3160a5&&_0x3160a5['mandatoryDisposition']?_0x3160a5['mandatoryDisposition']:![],'type':_0x3160a5&&_0x3160a5[_0xf2c8('0x30')]?_0x3160a5['type']:_0xf2c8('0x31'),'variables':_0x33f1b0,'motionChannel':_0xf2c8('0x32')};}Object[_0xf2c8('0x33')](_0x2e2305,_[_0xf2c8('0x34')](_0x5b1e44,[_0xf2c8('0x35'),_0xf2c8('0x36')]));this[_0xf2c8('0x8')][_0x5b1e44['uniqueid']][_0x5b1e44[_0xf2c8('0x26')]]=_0x2e2305;logger[_0xf2c8('0x27')](_0xf2c8('0x37'),_0x5b1e44[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x2e2305,{'showHidden':![],'depth':null}));ami[_0xf2c8('0x20')]('custom:agentcalled',_0x2e2305);var _0x104b3e={'id':_0x93707c['id'],'calleridnum':_0x2e2305['calleridnum'],'queue':_0x2e2305[_0xf2c8('0x2c')],'variables':_0x2e2305['variables'],'uniqueid':_0x5b1e44[_0xf2c8('0x2a')]};logger[_0xf2c8('0x27')](_0xf2c8('0x38'),_0x5b1e44[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x104b3e,{'showHidden':![],'depth':null}));this['emit'](util[_0xf2c8('0x2e')](_0xf2c8('0x39'),_0x5b1e44['membername']),_0xf2c8('0x3a'),_0x104b3e);}}catch(_0x23f6be){logger['error'](_0xf2c8('0x3b'),_0x5b1e44[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x23f6be,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0xf')]=function(_0x54e851){try{if(this['isNotNull'](_0x54e851)){if(this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]]){for(var _0xb48f51 in this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]]){if(this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xf2c8('0x3c')](_0xb48f51)){if(_0x54e851['destuniqueid']===_0xb48f51){logger[_0xf2c8('0x23')](_0xf2c8('0x3d'),_0x54e851[_0xf2c8('0x2a')],_0x54e851['membername'],_0x54e851['destuniqueid']);this['channels'][_0x54e851['uniqueid']][_0xb48f51][_0xf2c8('0x3e')]=moment()['format'](_0xf2c8('0x3f'));this['channels'][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51]['connectedlinename']=_0x54e851['connectedlinename'];this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51]['connectedlinenum']=_0x54e851[_0xf2c8('0x40')];this[_0xf2c8('0x8')][_0x54e851['uniqueid']][_0xb48f51][_0xf2c8('0x41')]=_0x54e851[_0xf2c8('0x41')];this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x42')]=_0x54e851[_0xf2c8('0x42')];this['channels'][_0x54e851['uniqueid']][_0xb48f51][_0xf2c8('0x43')]=_0x54e851['holdtime'];this[_0xf2c8('0x8')][_0x54e851['uniqueid']][_0xb48f51][_0xf2c8('0x44')]='connect';_[_0xf2c8('0x45')](this[_0xf2c8('0xa')][_0x54e851[_0xf2c8('0x2b')]],_[_0xf2c8('0x46')](_0x54e851,['queue',_0xf2c8('0x47')]));var _0x40fb25=this['agents'][_0x54e851[_0xf2c8('0x2b')]];var _0xa68854={'id':_0x40fb25['id'],'name':_0x40fb25[_0xf2c8('0x48')],'agentconnected':!![],'destaccountcode':_0x40fb25[_0xf2c8('0x49')],'destconnectedlinenum':this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0x54e851[_0xf2c8('0x26')]]['exten'],'queue':this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0x54e851[_0xf2c8('0x26')]][_0xf2c8('0x2c')],'uniqueid':this['channels'][_0x54e851['uniqueid']][_0x54e851[_0xf2c8('0x26')]][_0xf2c8('0x2a')]};ami[_0xf2c8('0x20')]('custom:agentconnect',this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0x54e851['destuniqueid']]);this['emit'](util[_0xf2c8('0x2e')](_0xf2c8('0x39'),_0x54e851[_0xf2c8('0x25')]),_0xf2c8('0x4a'),_0xa68854);}else if(!this['channels'][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x10')]&&!this[_0xf2c8('0x8')][_0x54e851['uniqueid']][_0xb48f51][_0xf2c8('0x13')]){logger[_0xf2c8('0x23')](_0xf2c8('0x4b'),_0x54e851['uniqueid'],this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x25')],_0xb48f51);this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51]['agentringnoanswer']=!![];this[_0xf2c8('0x8')][_0x54e851['uniqueid']][_0xb48f51]['agentringnoanswerAt']=moment()[_0xf2c8('0x2e')](_0xf2c8('0x3f'));this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x4c')]=_0x54e851['destuniqueid'];this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x4d')]=_0x54e851[_0xf2c8('0x25')];this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51]['lastevent']='answered_elsewhere';this[_0xf2c8('0x8')][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51][_0xf2c8('0x4e')]=_0xf2c8('0x4f');logger[_0xf2c8('0x27')](_0xf2c8('0x50'),_0x54e851[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](this['channels'][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51],{'showHidden':![],'depth':null}));ami[_0xf2c8('0x20')]('custom:agentansweredelsewhere',this['channels'][_0x54e851[_0xf2c8('0x2a')]][_0xb48f51]);}else{logger[_0xf2c8('0x27')]('[%s][voiceAgentReport][agentconnect]\x20Else\x20path\x20should\x20never\x20be\x20taken',_0x54e851[_0xf2c8('0x2a')]);}}}}}}catch(_0x232884){logger[_0xf2c8('0x51')]('[%s][voiceAgentReport][agentconnect]',_0x54e851[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x232884,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x11')]=function(_0x3b33fb){try{if(this[_0xf2c8('0x21')](_0x3b33fb)){logger[_0xf2c8('0x27')](_0xf2c8('0x52'),_0x3b33fb['uniqueid'],util[_0xf2c8('0x29')](_0x3b33fb,{'showHidden':![],'depth':null}));if(this[_0xf2c8('0x8')][_0x3b33fb[_0xf2c8('0x2a')]]&&this['channels'][_0x3b33fb['uniqueid']][_0x3b33fb[_0xf2c8('0x26')]]){logger[_0xf2c8('0x23')]('[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected',_0x3b33fb[_0xf2c8('0x2a')],_0x3b33fb['membername'],_0x3b33fb['destuniqueid']);var _0x33cf49=this[_0xf2c8('0xa')][_0x3b33fb['interface']];var _0x201699=this[_0xf2c8('0x8')][_0x3b33fb[_0xf2c8('0x2a')]][_0x3b33fb[_0xf2c8('0x26')]];_0x201699[_0xf2c8('0x10')]=!![];_0x201699['agentringnoanswerAt']=moment()[_0xf2c8('0x2e')](_0xf2c8('0x3f'));_0x201699['lastevent']=_0xf2c8('0x53');_0x201699['reason']=_0xf2c8('0x53');var _0x184c25={'id':_0x33cf49['id'],'name':_0x33cf49[_0xf2c8('0x48')],'queue':_0x201699[_0xf2c8('0x2c')],'uniqueid':_0x201699[_0xf2c8('0x2a')]};logger[_0xf2c8('0x27')]('[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:',_0x3b33fb[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x184c25,{'showHidden':![],'depth':null}));this[_0xf2c8('0x20')](util[_0xf2c8('0x2e')](_0xf2c8('0x39'),_0x33cf49['name']),_0xf2c8('0x54'),_0x184c25);ami[_0xf2c8('0x20')](_0xf2c8('0x55'),_0x201699);this[_0xf2c8('0x8')][_0x3b33fb['uniqueid']][_0x3b33fb[_0xf2c8('0x26')]]=Object[_0xf2c8('0x33')]({},_0x201699);}}}catch(_0x41f92e){logger[_0xf2c8('0x51')](_0xf2c8('0x56'),_0x3b33fb[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x41f92e,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x57')]=function(_0x4f13fe){try{if(this[_0xf2c8('0x21')](_0x4f13fe)){logger[_0xf2c8('0x27')]('[%s][voiceAgentReport][queuecallerabandon]\x20event:',_0x4f13fe[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x4f13fe,{'showHidden':![],'depth':null}));if(this['channels'][_0x4f13fe[_0xf2c8('0x2a')]]){for(var _0x308591 in this[_0xf2c8('0x8')][_0x4f13fe[_0xf2c8('0x2a')]]){if(this['channels'][_0x4f13fe['uniqueid']][_0xf2c8('0x3c')](_0x308591)&&!this['channels'][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591][_0xf2c8('0x10')]&&!this[_0xf2c8('0x8')][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591][_0xf2c8('0x13')]){logger[_0xf2c8('0x23')]('[%s][voiceAgentReport][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned',_0x4f13fe[_0xf2c8('0x2a')],this[_0xf2c8('0x8')][_0x4f13fe['uniqueid']][_0x308591][_0xf2c8('0x25')],_0x308591);this[_0xf2c8('0x8')][_0x4f13fe['uniqueid']][_0x308591][_0xf2c8('0x10')]=!![];this['channels'][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591][_0xf2c8('0x58')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');this['channels'][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591][_0xf2c8('0x44')]=_0xf2c8('0x59');this[_0xf2c8('0x8')][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591][_0xf2c8('0x4e')]='abandoned';logger[_0xf2c8('0x27')](_0xf2c8('0x5a'),_0x4f13fe[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](this['channels'][_0x4f13fe['uniqueid']][_0x308591],{'showHidden':![],'depth':null}));ami[_0xf2c8('0x20')](_0xf2c8('0x5b'),this[_0xf2c8('0x8')][_0x4f13fe[_0xf2c8('0x2a')]][_0x308591]);}}}}}catch(_0x50796b){logger['error'](_0xf2c8('0x5c'),_0x4f13fe[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x50796b,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')]['syncAgentComplete']=function(_0x57c348){try{if(this[_0xf2c8('0x21')](_0x57c348)){logger[_0xf2c8('0x27')](_0xf2c8('0x5d'),_0x57c348[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x57c348,{'showHidden':![],'depth':null}));if(this[_0xf2c8('0x8')][_0x57c348['uniqueid']]){for(var _0x35c799 in this[_0xf2c8('0x8')][_0x57c348['uniqueid']]){if(this[_0xf2c8('0x8')][_0x57c348['uniqueid']][_0xf2c8('0x3c')](_0x35c799)){if(this['channels'][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x3e')]&&!this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x13')]){logger['info']('[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x57c348['uniqueid'],this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x25')],_0x35c799);this['channels'][_0x57c348[_0xf2c8('0x2a')]][_0x35c799]['agentcomplete']=!![];this[_0xf2c8('0x8')][_0x57c348['uniqueid']][_0x35c799][_0xf2c8('0x5e')]=moment()['format'](_0xf2c8('0x3f'));this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x44')]=_0xf2c8('0x5f');this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x4e')]=_0x57c348['reason']==_0xf2c8('0x60')?'agent':_0x57c348[_0xf2c8('0x4e')];this['channels'][_0x57c348['uniqueid']][_0x35c799]['talktime']=_0x57c348['talktime'];if(this[_0xf2c8('0x9')][_0x57c348[_0xf2c8('0x2c')]]&&this[_0xf2c8('0x9')][_0x57c348[_0xf2c8('0x2c')]]['acw']){this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799][_0xf2c8('0x61')]=this[_0xf2c8('0x9')][_0x57c348['queue']][_0xf2c8('0x62')];this[_0xf2c8('0x8')][_0x57c348['uniqueid']][_0x35c799]['agentacw']=!![];}this[_0xf2c8('0xa')][_0x57c348[_0xf2c8('0x2b')]]=_[_0xf2c8('0x34')](this[_0xf2c8('0xa')][_0x57c348[_0xf2c8('0x2b')]],[_0xf2c8('0x2c'),_0xf2c8('0x47')]);logger['debug'](_0xf2c8('0x63'),_0x57c348[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799],{'showHidden':![],'depth':null}));ami[_0xf2c8('0x20')]('custom:agentcomplete',this[_0xf2c8('0x8')][_0x57c348[_0xf2c8('0x2a')]][_0x35c799]);logger[_0xf2c8('0x27')](_0xf2c8('0x64'),_0x57c348[_0xf2c8('0x2a')],util[_0xf2c8('0x29')]({'id':this['agents'][_0x57c348[_0xf2c8('0x2b')]]['id'],'destaccountcode':_0x57c348[_0xf2c8('0x65')]},{'showHidden':![],'depth':null}));this[_0xf2c8('0x20')](util[_0xf2c8('0x2e')](_0xf2c8('0x39'),_0x57c348['membername']),_0xf2c8('0x66'),{'id':this[_0xf2c8('0xa')][_0x57c348[_0xf2c8('0x2b')]]['id'],'destaccountcode':Number(_0x57c348['destaccountcode'])});}}}}}}catch(_0x45428c){logger[_0xf2c8('0x51')](_0xf2c8('0x67'),_0x57c348[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x45428c,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype']['syncVarSet']=function(_0x2b1939){try{if(this['isNotNull'](_0x2b1939)){logger[_0xf2c8('0x27')](_0xf2c8('0x68'),_0x2b1939[_0xf2c8('0x2a')],util['inspect'](_0x2b1939,{'showHidden':![],'depth':null}));this[_0xf2c8('0x69')](_0x2b1939[_0xf2c8('0x2a')],_[_0xf2c8('0x6a')](_0x2b1939[_0xf2c8('0x6b')])[0x0],_0x2b1939[_0xf2c8('0x6c')]);if(this[_0xf2c8('0x8')][_0x2b1939[_0xf2c8('0x2a')]]){for(var _0x33d312 in this[_0xf2c8('0x8')][_0x2b1939[_0xf2c8('0x2a')]]){if(this[_0xf2c8('0x8')][_0x2b1939['uniqueid']]['hasOwnProperty'](_0x33d312)){logger[_0xf2c8('0x23')](_0xf2c8('0x6d'),_0x2b1939[_0xf2c8('0x2a')],_0x33d312,_[_0xf2c8('0x6a')](_0x2b1939[_0xf2c8('0x6b')])[0x0],_0x2b1939[_0xf2c8('0x6c')]);if(_[_0xf2c8('0x22')](this[_0xf2c8('0x8')][_0x2b1939[_0xf2c8('0x2a')]][_0x33d312][_0xf2c8('0x2d')])){this[_0xf2c8('0x8')][_0x2b1939[_0xf2c8('0x2a')]][_0x33d312][_0xf2c8('0x2d')]={};}this[_0xf2c8('0x8')][_0x2b1939[_0xf2c8('0x2a')]][_0x33d312]['variables']=this[_0xf2c8('0x2d')][_0x2b1939[_0xf2c8('0x2a')]];}}}}}catch(_0xa70095){logger[_0xf2c8('0x51')](_0xf2c8('0x6e'),_0x2b1939[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0xa70095,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x69')]=function(_0x40cfac,_0x57d0fa,_0x3443b2){var _0x604bbf=[_0xf2c8('0x6f'),'rtpaudioqosbridged',_0xf2c8('0x70'),_0xf2c8('0x71'),_0xf2c8('0x72'),_0xf2c8('0x73'),_0xf2c8('0x74'),_0xf2c8('0x75'),_0xf2c8('0x76'),_0xf2c8('0x77'),_0xf2c8('0x78'),_0xf2c8('0x79'),_0xf2c8('0x7a'),_0xf2c8('0x7b'),'memberinterface','memberlastcall',_0xf2c8('0x25'),_0xf2c8('0x7c'),_0xf2c8('0x7d')];if(!_['isNil'](_0x57d0fa)&&!_[_0xf2c8('0x7e')](_0x604bbf,_0x57d0fa)){if(_[_0xf2c8('0x22')](this['variables'][_0x40cfac])){this[_0xf2c8('0x2d')][_0x40cfac]={};}this['variables'][_0x40cfac][_0x57d0fa]=_0x3443b2;}};VoiceAgentReport['prototype'][_0xf2c8('0x18')]=function(_0x166b45){try{if(this[_0xf2c8('0x21')](_0x166b45)){logger[_0xf2c8('0x27')](_0xf2c8('0x7f'),_0x166b45[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x166b45,{'showHidden':![],'depth':null}));if(this['channels'][_0x166b45[_0xf2c8('0x2a')]]){for(var _0x346a11 in this[_0xf2c8('0x8')][_0x166b45[_0xf2c8('0x2a')]]){if(this[_0xf2c8('0x8')][_0x166b45['uniqueid']][_0xf2c8('0x3c')](_0x346a11)){if(this[_0xf2c8('0x8')][_0x166b45[_0xf2c8('0x2a')]][_0x346a11]['reason']=='transfer'&&this[_0xf2c8('0x8')][_0x166b45[_0xf2c8('0x2a')]][_0x346a11][_0xf2c8('0x13')]){logger[_0xf2c8('0x23')](_0xf2c8('0x80'),_0x166b45['uniqueid'],_0x346a11);this['channels'][_0x166b45[_0xf2c8('0x2a')]][_0x346a11]['agentcompleteAt']=moment()[_0xf2c8('0x2e')](_0xf2c8('0x3f'));}}}logger[_0xf2c8('0x27')](_0xf2c8('0x81'),_0x166b45[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_['values'](this[_0xf2c8('0x8')][_0x166b45[_0xf2c8('0x2a')]]),{'showHidden':![],'depth':null}));ami[_0xf2c8('0x20')]('custom:voiceAgentReport',_[_0xf2c8('0x82')](this[_0xf2c8('0x8')][_0x166b45[_0xf2c8('0x2a')]]));this[_0xf2c8('0x83')](_0x166b45['uniqueid']);}if(this['variables'][_0x166b45[_0xf2c8('0x2a')]]){delete this[_0xf2c8('0x2d')][_0x166b45[_0xf2c8('0x2a')]];}}}catch(_0xf16ea2){logger[_0xf2c8('0x51')]('[%s][voiceAgentReport][hangup]',_0x166b45[_0xf2c8('0x2a')],util['inspect'](_0xf16ea2,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x1d')]=function(_0x4935db){try{if(this[_0xf2c8('0x21')](_0x4935db)){logger[_0xf2c8('0x27')]('[%s][voiceAgentReport][attendedtransfer]\x20event:',_0x4935db[_0xf2c8('0x2a')],util['inspect'](_0x4935db,{'showHidden':![],'depth':null}));if(this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]]){for(var _0x3bbeb8 in this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]]){if(this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]][_0xf2c8('0x3c')](_0x3bbeb8)){if(_0x4935db['origtransfereruniqueid']===_0x3bbeb8){logger['info'](_0xf2c8('0x85'),_0x4935db[_0xf2c8('0x2a')],this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8]['membername'],_0x3bbeb8);var _0xcac6a7=moment();this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8]['agentcomplete']=!![];this['channels'][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8]['agentcompleteAt']=moment()[_0xf2c8('0x2e')](_0xf2c8('0x3f'));this[_0xf2c8('0x8')][_0x4935db['transfereeuniqueid']][_0x3bbeb8][_0xf2c8('0x44')]=_0xf2c8('0x5f');this['channels'][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8]['reason']=_0xf2c8('0x60');this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8][_0xf2c8('0x86')]=_0xcac6a7[_0xf2c8('0x87')](this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]][_0x3bbeb8]['agentconnectAt'],_0xf2c8('0x88'));}}}}if(this[_0xf2c8('0x8')][_0x4935db['secondtransfereruniqueid']]){var _0x10bd33=this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x89')]];this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x89')]]=this['channels'][_0x4935db[_0xf2c8('0x84')]];this[_0xf2c8('0x8')][_0x4935db[_0xf2c8('0x84')]]=_0x10bd33;}}}catch(_0x187f89){logger[_0xf2c8('0x51')](_0xf2c8('0x8a'),_0x4935db['uniqueid'],util[_0xf2c8('0x29')](_0x187f89,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x8b')]=function(_0x4e5dd3){try{if(this[_0xf2c8('0x21')](_0x4e5dd3)){logger['debug'](_0xf2c8('0x8c'),_0x4e5dd3[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x4e5dd3,{'showHidden':![],'depth':null}));if(this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]]){for(var _0x4f5dc9 in this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]]){if(this['channels'][_0x4e5dd3[_0xf2c8('0x84')]][_0xf2c8('0x3c')](_0x4f5dc9)){if(_0x4e5dd3[_0xf2c8('0x8d')]===_0x4f5dc9){logger['info'](_0xf2c8('0x8e'),_0x4e5dd3[_0xf2c8('0x2a')],this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]][_0x4f5dc9][_0xf2c8('0x25')],_0x4f5dc9);var _0x51420c=moment();this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]][_0x4f5dc9][_0xf2c8('0x13')]=!![];this[_0xf2c8('0x8')][_0x4e5dd3['transfereeuniqueid']][_0x4f5dc9]['agentcompleteAt']=_0x51420c;this['channels'][_0x4e5dd3['transfereeuniqueid']][_0x4f5dc9]['lastevent']='complete';this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]][_0x4f5dc9][_0xf2c8('0x4e')]='transfer';this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]][_0x4f5dc9][_0xf2c8('0x86')]=_0x51420c[_0xf2c8('0x87')](this[_0xf2c8('0x8')][_0x4e5dd3[_0xf2c8('0x84')]][_0x4f5dc9][_0xf2c8('0x3e')],_0xf2c8('0x88'));}}}}}}catch(_0x37471e){logger[_0xf2c8('0x51')](_0xf2c8('0x8f'),_0x4e5dd3['uniqueid'],util[_0xf2c8('0x29')](_0x37471e,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xf2c8('0x1a')]=function(_0x248448){var _0x4c2c7a='';try{if(this[_0xf2c8('0x21')](_0x248448)){logger[_0xf2c8('0x27')](_0xf2c8('0x90'),_0x248448['uniqueid'],util['inspect'](_0x248448,{'showHidden':![],'depth':null}));if(_0x248448[_0xf2c8('0x91')]){_0x4c2c7a=_0x248448['channel']['substring'](0x0,_0x248448['channel']['lastIndexOf']('-'));if(this['agents'][_0x4c2c7a]){logger[_0xf2c8('0x23')](_0xf2c8('0x92'),_0x248448['uniqueid'],_0x4c2c7a);this['agents'][_0x4c2c7a][_0xf2c8('0x93')]=!![];}}}}catch(_0x201d6c){logger['error'](_0xf2c8('0x94'),_0x248448[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x201d6c,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x95')]=function(_0x43be33){var _0x2d16e3='';try{if(this['isNotNull'](_0x43be33)){logger[_0xf2c8('0x27')](_0xf2c8('0x96'),_0x43be33[_0xf2c8('0x2a')],util['inspect'](_0x43be33,{'showHidden':![],'depth':null}));if(_0x43be33[_0xf2c8('0x91')]){_0x2d16e3=_0x43be33[_0xf2c8('0x91')][_0xf2c8('0x97')](0x0,_0x43be33[_0xf2c8('0x91')][_0xf2c8('0x98')]('-'));if(this[_0xf2c8('0xa')][_0x2d16e3]){logger[_0xf2c8('0x23')]('[%s][voiceAgentReport][musiconholdstop]\x20interface:%s',_0x43be33[_0xf2c8('0x2a')],_0x2d16e3);this[_0xf2c8('0xa')][_0x2d16e3][_0xf2c8('0x93')]=![];}}}}catch(_0x3e42e4){logger['error'](_0xf2c8('0x99'),_0x43be33[_0xf2c8('0x2a')],util[_0xf2c8('0x29')](_0x3e42e4,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xf2c8('0x1f')][_0xf2c8('0x83')]=function(_0x2669b4,_0x305ef9=0x2710){if(this[_0xf2c8('0x8')][_0x2669b4]){setTimeout(()=>{delete this[_0xf2c8('0x8')][_0x2669b4];},_0x305ef9);}};module[_0xf2c8('0x9a')]=VoiceAgentReport;