Built motion from commit (unavailable).|2.5.22
[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 _0xfd49=['rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','memberdynamic','memberinterface','memberrealtime','isNil','includes','[%s][voiceAgentReport][hangup]\x20event:','[%s][voiceAgentReport][hangup]\x20destuniqueid:%s','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','values','custom:voiceAgentReport','[%s][voiceAgentReport][hangup]','syncAttendedTransfer','[%s][voiceAgentReport][attendedtransfer]\x20event:','transfereeuniqueid','origtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','secondtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','diff','[%s][voiceAgentReport][blindtransfer]','channel','substring','lastIndexOf','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s','onhold','[%s][voiceAgentReport][musiconholdstart]','[%s][voiceAgentReport][musiconholdstop]\x20event:','[%s][voiceAgentReport][musiconholdstop]\x20interface:%s','[%s][voiceAgentReport][musiconholdstop]','lodash','moment','util','ioredis','ami','../ami','defaults','redis','socket.io-emitter','voiceQueues','agents','variables','agentcalled','bind','agentconnect','syncAgentConnect','syncAgentRingNoAnswer','syncQueueCallerAbandon','agentcomplete','syncAgentComplete','varset','syncVarSet','hangup','syncHangup','musiconholdstart','syncMusicOnHoldStart','syncMusicOnHoldStop','blindtransfer','syncBlindTransfer','emit','prototype','isNotNull','isUndefined','syncAgentCalled','info','[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','uniqueid','membername','inspect','channels','destuniqueid','format','YYYY-MM-DD\x20HH:mm:ss','called','queue','inbound','merge','omit','event','privilege','debug','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','custom:agentcalled','[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:','user:%s','user:called','error','[%s][voiceAgentReport][agentcalled]','[%s][voiceAgentReport][agentconnect]\x20event:','agentconnectAt','connectedlinename','destchannelstate','destchannelstatedesc','holdtime','connect','interface','pick','destconnectedlinenum','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentconnect\x20event:','custom:agentconnect','agentringnoanswer','agentringnoanswerAt','answeredelsewheredestinationuniqueid','answeredelsewheremembername','lastevent','answered_elsewhere','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','custom:agentansweredelsewhere','[%s][voiceAgentReport][agentconnect]','[%s][voiceAgentReport][agentringnoanswer]\x20event:','[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected','rejected','reason','[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:','[%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][agentcomplete]\x20event:','[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','agentcompleteAt','complete','transfer','talktime','acw','acwtime','acwTimeout','[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:','custom:agentcomplete','[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','addVariable','hasOwnProperty','[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s','variable','value','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss'];(function(_0x247ca4,_0x1e7ec5){var _0x432c92=function(_0x5d5de1){while(--_0x5d5de1){_0x247ca4['push'](_0x247ca4['shift']());}};_0x432c92(++_0x1e7ec5);}(_0xfd49,0x15b));var _0x9fd4=function(_0x451438,_0x52c4c3){_0x451438=_0x451438-0x0;var _0x435d62=_0xfd49[_0x451438];return _0x435d62;};'use strict';var _=require(_0x9fd4('0x0'));var moment=require(_0x9fd4('0x1'));var util=require(_0x9fd4('0x2'));var Redis=require(_0x9fd4('0x3'));var config=require('../../../config/environment');var logger=require('../../../config/logger')(_0x9fd4('0x4'));var ami=require(_0x9fd4('0x5'));config['redis']=_[_0x9fd4('0x6')](config[_0x9fd4('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x9fd4('0x8'))(new Redis(config[_0x9fd4('0x7')]));function VoiceAgentReport(_0x1d6e33){this['channels']={};this[_0x9fd4('0x9')]=_0x1d6e33[_0x9fd4('0x9')];this[_0x9fd4('0xa')]=_0x1d6e33[_0x9fd4('0xa')];this[_0x9fd4('0xb')]={};ami['on'](_0x9fd4('0xc'),this['syncAgentCalled'][_0x9fd4('0xd')](this));ami['on'](_0x9fd4('0xe'),this[_0x9fd4('0xf')][_0x9fd4('0xd')](this));ami['on']('agentringnoanswer',this[_0x9fd4('0x10')][_0x9fd4('0xd')](this));ami['on']('queuecallerabandon',this[_0x9fd4('0x11')][_0x9fd4('0xd')](this));ami['on'](_0x9fd4('0x12'),this[_0x9fd4('0x13')][_0x9fd4('0xd')](this));ami['on'](_0x9fd4('0x14'),this[_0x9fd4('0x15')][_0x9fd4('0xd')](this));ami['on'](_0x9fd4('0x16'),this[_0x9fd4('0x17')]['bind'](this));ami['on'](_0x9fd4('0x18'),this[_0x9fd4('0x19')][_0x9fd4('0xd')](this));ami['on']('musiconholdstop',this[_0x9fd4('0x1a')][_0x9fd4('0xd')](this));ami['on']('attendedtransfer',this['syncAttendedTransfer']['bind'](this));ami['on'](_0x9fd4('0x1b'),this[_0x9fd4('0x1c')][_0x9fd4('0xd')](this));}VoiceAgentReport['prototype']['emit']=function(_0x6a361,_0x4d41cc,_0x3cbe05){io['to'](_0x6a361)[_0x9fd4('0x1d')](_0x4d41cc,_0x3cbe05);};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x1f')]=function(_0x55f0ae){return _0x55f0ae!==null&&!_[_0x9fd4('0x20')](_0x55f0ae);};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x21')]=function(_0x25628c){try{if(this[_0x9fd4('0x1f')](_0x25628c)){logger[_0x9fd4('0x22')](_0x9fd4('0x23'),_0x25628c[_0x9fd4('0x24')],_0x25628c[_0x9fd4('0x25')],_0x25628c['destuniqueid']);logger['debug']('[%s][voiceAgentReport][agentcalled]\x20event:',_0x25628c[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x25628c,{'showHidden':![],'depth':null}));if(_[_0x9fd4('0x20')](this['channels'][_0x25628c[_0x9fd4('0x24')]])){this[_0x9fd4('0x27')][_0x25628c[_0x9fd4('0x24')]]={};}if(_[_0x9fd4('0x20')](this[_0x9fd4('0x27')][_0x25628c['uniqueid']][_0x25628c[_0x9fd4('0x28')]])){this[_0x9fd4('0x27')][_0x25628c[_0x9fd4('0x24')]][_0x25628c['destuniqueid']]={'agentcalledAt':moment()[_0x9fd4('0x29')](_0x9fd4('0x2a')),'lastevent':_0x9fd4('0x2b'),'mandatoryDisposition':this[_0x9fd4('0x9')][_0x25628c['queue']]?this[_0x9fd4('0x9')][_0x25628c['queue']]['mandatoryDisposition']||![]:![],'type':this[_0x9fd4('0x9')][_0x25628c['queue']]?this['voiceQueues'][_0x25628c[_0x9fd4('0x2c')]]['type']||_0x9fd4('0x2d'):'inbound','variables':this[_0x9fd4('0xb')][_0x25628c[_0x9fd4('0x24')]]};}_[_0x9fd4('0x2e')](this[_0x9fd4('0x27')][_0x25628c[_0x9fd4('0x24')]][_0x25628c[_0x9fd4('0x28')]],_[_0x9fd4('0x2f')](_0x25628c,[_0x9fd4('0x30'),_0x9fd4('0x31')]));logger[_0x9fd4('0x32')](_0x9fd4('0x33'),_0x25628c[_0x9fd4('0x24')],util[_0x9fd4('0x26')](this['channels'][_0x25628c[_0x9fd4('0x24')]][_0x25628c[_0x9fd4('0x28')]],{'showHidden':![],'depth':null}));ami[_0x9fd4('0x1d')](_0x9fd4('0x34'),this['channels'][_0x25628c[_0x9fd4('0x24')]][_0x25628c['destuniqueid']]);logger[_0x9fd4('0x32')](_0x9fd4('0x35'),_0x25628c[_0x9fd4('0x24')],util['inspect'](this[_0x9fd4('0x27')][_0x25628c[_0x9fd4('0x24')]][_0x25628c[_0x9fd4('0x28')]],{'showHidden':![],'depth':null}));this[_0x9fd4('0x1d')](util[_0x9fd4('0x29')](_0x9fd4('0x36'),_0x25628c[_0x9fd4('0x25')]),_0x9fd4('0x37'),this[_0x9fd4('0x27')][_0x25628c[_0x9fd4('0x24')]][_0x25628c[_0x9fd4('0x28')]]);}}catch(_0x1fe168){logger[_0x9fd4('0x38')](_0x9fd4('0x39'),_0x25628c[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x1fe168,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')]['syncAgentConnect']=function(_0x498b3f){try{if(this[_0x9fd4('0x1f')](_0x498b3f)){if(this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]]){logger['debug'](_0x9fd4('0x3a'),_0x498b3f[_0x9fd4('0x24')],util['inspect'](_0x498b3f,{'showHidden':![],'depth':null}));for(var _0x89cd08 in this['channels'][_0x498b3f[_0x9fd4('0x24')]]){if(this[_0x9fd4('0x27')][_0x498b3f['uniqueid']]['hasOwnProperty'](_0x89cd08)){if(_0x498b3f[_0x9fd4('0x28')]===_0x89cd08){logger[_0x9fd4('0x22')]('[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect',_0x498b3f[_0x9fd4('0x24')],_0x498b3f[_0x9fd4('0x25')],_0x498b3f[_0x9fd4('0x28')]);this[_0x9fd4('0x27')][_0x498b3f['uniqueid']][_0x89cd08][_0x9fd4('0x3b')]=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x3c')]=_0x498b3f[_0x9fd4('0x3c')];this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['connectedlinenum']=_0x498b3f['connectedlinenum'];this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x3d')]=_0x498b3f['destchannelstate'];this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['destchannelstatedesc']=_0x498b3f[_0x9fd4('0x3e')];this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['holdtime']=_0x498b3f[_0x9fd4('0x3f')];this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['lastevent']=_0x9fd4('0x40');_[_0x9fd4('0x2e')](this[_0x9fd4('0xa')][_0x498b3f[_0x9fd4('0x41')]],_[_0x9fd4('0x42')](_0x498b3f,[_0x9fd4('0x2c'),_0x9fd4('0x43')]));logger['debug'](_0x9fd4('0x44'),_0x498b3f[_0x9fd4('0x24')],util[_0x9fd4('0x26')](this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x498b3f[_0x9fd4('0x28')]],{'showHidden':![],'depth':null}));ami[_0x9fd4('0x1d')](_0x9fd4('0x45'),this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x498b3f['destuniqueid']]);logger['debug']('[%s][voiceAgentReport][agentcalled]\x20sending\x20user:agentconnect\x20event:',_0x498b3f[_0x9fd4('0x24')],util[_0x9fd4('0x26')](this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x498b3f[_0x9fd4('0x28')]],{'showHidden':![],'depth':null}));this['emit'](util[_0x9fd4('0x29')](_0x9fd4('0x36'),_0x498b3f[_0x9fd4('0x25')]),'user:agentconnect',this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x498b3f['destuniqueid']]);}else if(!this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x46')]&&!this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x12')]){logger['info']('[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere',_0x498b3f['uniqueid'],this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['membername'],_0x89cd08);this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x46')]=!![];this['channels'][_0x498b3f['uniqueid']][_0x89cd08][_0x9fd4('0x47')]=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));this['channels'][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x48')]=_0x498b3f[_0x9fd4('0x28')];this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x49')]=_0x498b3f[_0x9fd4('0x25')];this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08][_0x9fd4('0x4a')]='answered_elsewhere';this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]['reason']=_0x9fd4('0x4b');logger[_0x9fd4('0x32')](_0x9fd4('0x4c'),_0x498b3f[_0x9fd4('0x24')],util['inspect'](this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08],{'showHidden':![],'depth':null}));ami[_0x9fd4('0x1d')](_0x9fd4('0x4d'),this[_0x9fd4('0x27')][_0x498b3f[_0x9fd4('0x24')]][_0x89cd08]);}}}}}}catch(_0x1193a6){logger[_0x9fd4('0x38')](_0x9fd4('0x4e'),_0x498b3f[_0x9fd4('0x24')],util['inspect'](_0x1193a6,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x10')]=function(_0x2bdb9d){try{if(this['isNotNull'](_0x2bdb9d)){logger[_0x9fd4('0x32')](_0x9fd4('0x4f'),_0x2bdb9d['uniqueid'],util[_0x9fd4('0x26')](_0x2bdb9d,{'showHidden':![],'depth':null}));if(this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]]&&this['channels'][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d['destuniqueid']]){logger[_0x9fd4('0x22')](_0x9fd4('0x50'),_0x2bdb9d[_0x9fd4('0x24')],_0x2bdb9d['membername'],_0x2bdb9d['destuniqueid']);this[_0x9fd4('0x27')][_0x2bdb9d['uniqueid']][_0x2bdb9d[_0x9fd4('0x28')]][_0x9fd4('0x46')]=!![];this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d['destuniqueid']]['agentringnoanswerAt']=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d[_0x9fd4('0x28')]][_0x9fd4('0x4a')]=_0x9fd4('0x51');this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d[_0x9fd4('0x28')]][_0x9fd4('0x52')]=_0x9fd4('0x51');logger[_0x9fd4('0x32')](_0x9fd4('0x53'),_0x2bdb9d[_0x9fd4('0x24')],util[_0x9fd4('0x26')](this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d[_0x9fd4('0x28')]],{'showHidden':![],'depth':null}));ami[_0x9fd4('0x1d')]('custom:agentringnoanswer',this[_0x9fd4('0x27')][_0x2bdb9d[_0x9fd4('0x24')]][_0x2bdb9d[_0x9fd4('0x28')]]);}}}catch(_0xc60961){logger[_0x9fd4('0x38')](_0x9fd4('0x54'),_0x2bdb9d[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0xc60961,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x11')]=function(_0x4cbc0f){try{if(this[_0x9fd4('0x1f')](_0x4cbc0f)){logger[_0x9fd4('0x32')](_0x9fd4('0x55'),_0x4cbc0f[_0x9fd4('0x24')],util['inspect'](_0x4cbc0f,{'showHidden':![],'depth':null}));if(this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]]){for(var _0x2e22ab in this['channels'][_0x4cbc0f[_0x9fd4('0x24')]]){if(this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]]['hasOwnProperty'](_0x2e22ab)&&!this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab]['agentringnoanswer']&&!this[_0x9fd4('0x27')][_0x4cbc0f['uniqueid']][_0x2e22ab][_0x9fd4('0x12')]){logger[_0x9fd4('0x22')](_0x9fd4('0x56'),_0x4cbc0f['uniqueid'],this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab][_0x9fd4('0x25')],_0x2e22ab);this['channels'][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab]['agentringnoanswer']=!![];this['channels'][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab][_0x9fd4('0x47')]=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));this[_0x9fd4('0x27')][_0x4cbc0f['uniqueid']][_0x2e22ab][_0x9fd4('0x4a')]=_0x9fd4('0x57');this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab][_0x9fd4('0x52')]=_0x9fd4('0x57');logger['debug'](_0x9fd4('0x58'),_0x4cbc0f[_0x9fd4('0x24')],util['inspect'](this['channels'][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab],{'showHidden':![],'depth':null}));ami['emit'](_0x9fd4('0x59'),this[_0x9fd4('0x27')][_0x4cbc0f[_0x9fd4('0x24')]][_0x2e22ab]);}}}}}catch(_0x172803){logger[_0x9fd4('0x38')]('[%s][voiceAgentReport][queuecallerabandon]',_0x4cbc0f[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x172803,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x9fd4('0x13')]=function(_0xdb28c){try{if(this[_0x9fd4('0x1f')](_0xdb28c)){logger[_0x9fd4('0x32')](_0x9fd4('0x5a'),_0xdb28c[_0x9fd4('0x24')],util['inspect'](_0xdb28c,{'showHidden':![],'depth':null}));if(this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]]){for(var _0x282fc8 in this['channels'][_0xdb28c['uniqueid']]){if(this['channels'][_0xdb28c[_0x9fd4('0x24')]]['hasOwnProperty'](_0x282fc8)){if(this[_0x9fd4('0x27')][_0xdb28c['uniqueid']][_0x282fc8]['agentconnectAt']&&!this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8][_0x9fd4('0x12')]){logger[_0x9fd4('0x22')](_0x9fd4('0x5b'),_0xdb28c['uniqueid'],this['channels'][_0xdb28c['uniqueid']][_0x282fc8][_0x9fd4('0x25')],_0x282fc8);this[_0x9fd4('0x27')][_0xdb28c['uniqueid']][_0x282fc8][_0x9fd4('0x12')]=!![];this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8][_0x9fd4('0x5c')]=moment()[_0x9fd4('0x29')]('YYYY-MM-DD\x20HH:mm:ss');this['channels'][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8]['lastevent']=_0x9fd4('0x5d');this[_0x9fd4('0x27')][_0xdb28c['uniqueid']][_0x282fc8][_0x9fd4('0x52')]=_0xdb28c['reason']==_0x9fd4('0x5e')?'agent':_0xdb28c[_0x9fd4('0x52')];this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8][_0x9fd4('0x5f')]=_0xdb28c[_0x9fd4('0x5f')];if(this['voiceQueues'][_0xdb28c[_0x9fd4('0x2c')]]&&this[_0x9fd4('0x9')][_0xdb28c[_0x9fd4('0x2c')]][_0x9fd4('0x60')]){this['channels'][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8][_0x9fd4('0x61')]=this[_0x9fd4('0x9')][_0xdb28c[_0x9fd4('0x2c')]][_0x9fd4('0x62')];this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8]['agentacw']=!![];}this['agents'][_0xdb28c[_0x9fd4('0x41')]]=_['omit'](this[_0x9fd4('0xa')][_0xdb28c[_0x9fd4('0x41')]],['queue',_0x9fd4('0x43')]);logger[_0x9fd4('0x32')](_0x9fd4('0x63'),_0xdb28c[_0x9fd4('0x24')],util['inspect'](this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8],{'showHidden':![],'depth':null}));ami['emit'](_0x9fd4('0x64'),this[_0x9fd4('0x27')][_0xdb28c['uniqueid']][_0x282fc8]);logger[_0x9fd4('0x32')](_0x9fd4('0x65'),_0xdb28c[_0x9fd4('0x24')],util[_0x9fd4('0x26')](this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8],{'showHidden':![],'depth':null}));this[_0x9fd4('0x1d')](util[_0x9fd4('0x29')](_0x9fd4('0x36'),_0xdb28c[_0x9fd4('0x25')]),'user:agentcomplete',this[_0x9fd4('0x27')][_0xdb28c[_0x9fd4('0x24')]][_0x282fc8]);}}}}}}catch(_0x1c5291){logger[_0x9fd4('0x38')](_0x9fd4('0x66'),_0xdb28c[_0x9fd4('0x24')],util['inspect'](_0x1c5291,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0x9fd4('0x15')]=function(_0x432d71){try{if(this[_0x9fd4('0x1f')](_0x432d71)){logger['debug'](_0x9fd4('0x67'),_0x432d71[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x432d71,{'showHidden':![],'depth':null}));this[_0x9fd4('0x68')](_0x432d71[_0x9fd4('0x24')],_['keys'](_0x432d71['variable'])[0x0],_0x432d71['value']);if(this[_0x9fd4('0x27')][_0x432d71[_0x9fd4('0x24')]]){for(var _0x4ab635 in this['channels'][_0x432d71[_0x9fd4('0x24')]]){if(this[_0x9fd4('0x27')][_0x432d71[_0x9fd4('0x24')]][_0x9fd4('0x69')](_0x4ab635)){logger[_0x9fd4('0x22')](_0x9fd4('0x6a'),_0x432d71['uniqueid'],_0x4ab635,_['keys'](_0x432d71[_0x9fd4('0x6b')])[0x0],_0x432d71[_0x9fd4('0x6c')]);if(_[_0x9fd4('0x20')](this[_0x9fd4('0x27')][_0x432d71[_0x9fd4('0x24')]][_0x4ab635][_0x9fd4('0xb')])){this[_0x9fd4('0x27')][_0x432d71[_0x9fd4('0x24')]][_0x4ab635]['variables']={};}this[_0x9fd4('0x27')][_0x432d71[_0x9fd4('0x24')]][_0x4ab635][_0x9fd4('0xb')]=this['variables'][_0x432d71['uniqueid']];}}}}}catch(_0x214bf2){logger['error'](_0x9fd4('0x6d'),_0x432d71[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x214bf2,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype']['addVariable']=function(_0x457224,_0x2cfccd,_0x5dfd45){var _0x4ee53b=[_0x9fd4('0x6e'),_0x9fd4('0x6f'),_0x9fd4('0x70'),_0x9fd4('0x71'),_0x9fd4('0x72'),_0x9fd4('0x73'),_0x9fd4('0x74'),_0x9fd4('0x75'),_0x9fd4('0x76'),_0x9fd4('0x77'),_0x9fd4('0x78'),_0x9fd4('0x79'),'membercalls',_0x9fd4('0x7a'),_0x9fd4('0x7b'),'memberlastcall',_0x9fd4('0x25'),'memberpenalty',_0x9fd4('0x7c')];if(!_[_0x9fd4('0x7d')](_0x2cfccd)&&!_[_0x9fd4('0x7e')](_0x4ee53b,_0x2cfccd)){if(_[_0x9fd4('0x20')](this[_0x9fd4('0xb')][_0x457224])){this[_0x9fd4('0xb')][_0x457224]={};}this['variables'][_0x457224][_0x2cfccd]=_0x5dfd45;}};VoiceAgentReport[_0x9fd4('0x1e')]['syncHangup']=function(_0x3e0d79){try{if(this[_0x9fd4('0x1f')](_0x3e0d79)){logger['debug'](_0x9fd4('0x7f'),_0x3e0d79['uniqueid'],util[_0x9fd4('0x26')](_0x3e0d79,{'showHidden':![],'depth':null}));if(this['channels'][_0x3e0d79[_0x9fd4('0x24')]]){for(var _0x208cb8 in this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]]){if(this['channels'][_0x3e0d79[_0x9fd4('0x24')]][_0x9fd4('0x69')](_0x208cb8)){if(this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]][_0x208cb8][_0x9fd4('0x52')]==_0x9fd4('0x5e')&&this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]][_0x208cb8][_0x9fd4('0x12')]){logger['info'](_0x9fd4('0x80'),_0x3e0d79[_0x9fd4('0x24')],_0x208cb8);this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]][_0x208cb8][_0x9fd4('0x5c')]=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));}}}logger[_0x9fd4('0x32')](_0x9fd4('0x81'),_0x3e0d79[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_[_0x9fd4('0x82')](this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]]),{'showHidden':![],'depth':null}));ami['emit'](_0x9fd4('0x83'),_[_0x9fd4('0x82')](this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]]));delete this[_0x9fd4('0x27')][_0x3e0d79[_0x9fd4('0x24')]];}if(this[_0x9fd4('0xb')][_0x3e0d79[_0x9fd4('0x24')]]){delete this[_0x9fd4('0xb')][_0x3e0d79[_0x9fd4('0x24')]];}}}catch(_0x5436c8){logger[_0x9fd4('0x38')](_0x9fd4('0x84'),_0x3e0d79[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x5436c8,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x85')]=function(_0x57dd46){try{if(this[_0x9fd4('0x1f')](_0x57dd46)){logger['debug'](_0x9fd4('0x86'),_0x57dd46['uniqueid'],util[_0x9fd4('0x26')](_0x57dd46,{'showHidden':![],'depth':null}));if(this['channels'][_0x57dd46[_0x9fd4('0x87')]]){for(var _0xd29e9b in this[_0x9fd4('0x27')][_0x57dd46[_0x9fd4('0x87')]]){if(this[_0x9fd4('0x27')][_0x57dd46[_0x9fd4('0x87')]][_0x9fd4('0x69')](_0xd29e9b)){if(_0x57dd46[_0x9fd4('0x88')]===_0xd29e9b){logger[_0x9fd4('0x22')](_0x9fd4('0x89'),_0x57dd46[_0x9fd4('0x24')],this['channels'][_0x57dd46['transfereeuniqueid']][_0xd29e9b][_0x9fd4('0x25')],_0xd29e9b);var _0x502fde=moment();this['channels'][_0x57dd46[_0x9fd4('0x87')]][_0xd29e9b][_0x9fd4('0x12')]=!![];this[_0x9fd4('0x27')][_0x57dd46['transfereeuniqueid']][_0xd29e9b][_0x9fd4('0x5c')]=moment()[_0x9fd4('0x29')](_0x9fd4('0x2a'));this['channels'][_0x57dd46[_0x9fd4('0x87')]][_0xd29e9b][_0x9fd4('0x4a')]=_0x9fd4('0x5d');this['channels'][_0x57dd46[_0x9fd4('0x87')]][_0xd29e9b][_0x9fd4('0x52')]=_0x9fd4('0x5e');this['channels'][_0x57dd46['transfereeuniqueid']][_0xd29e9b]['talktime']=_0x502fde['diff'](this['channels'][_0x57dd46[_0x9fd4('0x87')]][_0xd29e9b][_0x9fd4('0x3b')],'seconds');}}}}if(this[_0x9fd4('0x27')][_0x57dd46[_0x9fd4('0x8a')]]){var _0x6735fc=this[_0x9fd4('0x27')][_0x57dd46['secondtransfereruniqueid']];this[_0x9fd4('0x27')][_0x57dd46[_0x9fd4('0x8a')]]=this['channels'][_0x57dd46[_0x9fd4('0x87')]];this[_0x9fd4('0x27')][_0x57dd46[_0x9fd4('0x87')]]=_0x6735fc;}}}catch(_0x554f14){logger[_0x9fd4('0x38')](_0x9fd4('0x8b'),_0x57dd46[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x554f14,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x1c')]=function(_0x1533bc){try{if(this[_0x9fd4('0x1f')](_0x1533bc)){logger[_0x9fd4('0x32')](_0x9fd4('0x8c'),_0x1533bc[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x1533bc,{'showHidden':![],'depth':null}));if(this[_0x9fd4('0x27')][_0x1533bc[_0x9fd4('0x87')]]){for(var _0x587230 in this['channels'][_0x1533bc[_0x9fd4('0x87')]]){if(this['channels'][_0x1533bc['transfereeuniqueid']][_0x9fd4('0x69')](_0x587230)){if(_0x1533bc[_0x9fd4('0x8d')]===_0x587230){logger[_0x9fd4('0x22')](_0x9fd4('0x8e'),_0x1533bc[_0x9fd4('0x24')],this[_0x9fd4('0x27')][_0x1533bc['transfereeuniqueid']][_0x587230][_0x9fd4('0x25')],_0x587230);var _0x138e24=moment();this[_0x9fd4('0x27')][_0x1533bc['transfereeuniqueid']][_0x587230][_0x9fd4('0x12')]=!![];this['channels'][_0x1533bc['transfereeuniqueid']][_0x587230]['agentcompleteAt']=_0x138e24;this[_0x9fd4('0x27')][_0x1533bc['transfereeuniqueid']][_0x587230][_0x9fd4('0x4a')]='complete';this[_0x9fd4('0x27')][_0x1533bc[_0x9fd4('0x87')]][_0x587230][_0x9fd4('0x52')]=_0x9fd4('0x5e');this[_0x9fd4('0x27')][_0x1533bc[_0x9fd4('0x87')]][_0x587230]['talktime']=_0x138e24[_0x9fd4('0x8f')](this['channels'][_0x1533bc[_0x9fd4('0x87')]][_0x587230]['agentconnectAt'],'seconds');}}}}}}catch(_0x39a7b1){logger[_0x9fd4('0x38')](_0x9fd4('0x90'),_0x1533bc[_0x9fd4('0x24')],util['inspect'](_0x39a7b1,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')]['syncMusicOnHoldStart']=function(_0x3899e7){var _0x158384='';try{if(this[_0x9fd4('0x1f')](_0x3899e7)){logger['debug']('[%s][voiceAgentReport][musiconholdstart]\x20event:',_0x3899e7[_0x9fd4('0x24')],util['inspect'](_0x3899e7,{'showHidden':![],'depth':null}));if(_0x3899e7[_0x9fd4('0x91')]){_0x158384=_0x3899e7[_0x9fd4('0x91')][_0x9fd4('0x92')](0x0,_0x3899e7['channel'][_0x9fd4('0x93')]('-'));if(this['agents'][_0x158384]){logger['info'](_0x9fd4('0x94'),_0x3899e7['uniqueid'],_0x158384);this[_0x9fd4('0xa')][_0x158384][_0x9fd4('0x95')]=!![];}}}}catch(_0x482719){logger[_0x9fd4('0x38')](_0x9fd4('0x96'),_0x3899e7[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x482719,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0x9fd4('0x1e')][_0x9fd4('0x1a')]=function(_0x53a86c){var _0x4ee50a='';try{if(this[_0x9fd4('0x1f')](_0x53a86c)){logger[_0x9fd4('0x32')](_0x9fd4('0x97'),_0x53a86c[_0x9fd4('0x24')],util['inspect'](_0x53a86c,{'showHidden':![],'depth':null}));if(_0x53a86c[_0x9fd4('0x91')]){_0x4ee50a=_0x53a86c[_0x9fd4('0x91')][_0x9fd4('0x92')](0x0,_0x53a86c[_0x9fd4('0x91')][_0x9fd4('0x93')]('-'));if(this['agents'][_0x4ee50a]){logger[_0x9fd4('0x22')](_0x9fd4('0x98'),_0x53a86c[_0x9fd4('0x24')],_0x4ee50a);this[_0x9fd4('0xa')][_0x4ee50a][_0x9fd4('0x95')]=![];}}}}catch(_0x34e2ce){logger[_0x9fd4('0x38')](_0x9fd4('0x99'),_0x53a86c[_0x9fd4('0x24')],util[_0x9fd4('0x26')](_0x34e2ce,{'showHidden':![],'depth':null}));}};module['exports']=VoiceAgentReport;