2803ae9c8fbddc1c284dfcd8238af0b894cdf1b2
[motion2.git] / server / services / ami / report / voiceCallReport.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 _0x3e80=['format','YYYY-MM-DD\x20HH:mm:ss','disposition','channelstate','pick','keys','from-sip','split','destconnectedlinenum','exten','[%s][voiceCallReport][newchannel]\x20sending\x20user:agentconnect\x20event:','name','user:agentconnect','[%s][voiceCallReport][newchannel]','[%s][voiceCallReport][newexten]\x20event:','toLowerCase','appdata','applicationdata','[%s][voiceCallReport][newexten]\x20application:%s\x20appdata:%s','application','starttime','duration','subtract','seconds','includes','lastdata','startsWith','match','[%s][voiceCallReport][newexten]','[%s][voiceCallReport][newstate]\x20event:','answered','answertime','diff','xcally-motion-preview','connectedlinenum','connectedlinename','destinationchannel','toNumber','UserId','membername','[%s][voiceCallReport][newstate]','syncMixMonitorFilename','[%s][voiceCallReport][mixMonitorFilename]\x20monitorFilename:%s','monitor','endsWith','.wav49','replace','.WAV','monitors','isNil','push','[%s][voiceCallReport][mixMonitorFilename]','variable','[%s][voiceCallReport][varset]\x20variable:mixmonitor_filename\x20value:%s','xmd-phone','[%s][voiceCallReport][varset]\x20variable:xmd-phone\x20value:%s','value','xmd-callerid','[%s][voiceCallReport][varset]\x20variable:xmd-callerid\x20value:%s','callerid','xmd-cdrtype','[%s][voiceCallReport][varset]\x20variable:xmd-cdrtype\x20value:%s','type','xmd-queue','[%s][voiceCallReport][varset]\x20variable:xmd-queue\x20value:%s','xmd-originatecalleridnum','originatecalleridnum','xmd-destination','[%s][voiceCallReport][varset]\x20variable:xmd-destination\x20value:%s','destination','xmd-callerid-preview','[%s][voiceCallReport][varset]\x20variable:xmd-callerid-preview\x20value:%s','[%s][voiceCallReport][varset]\x20variable:xmcs-queue\x20value:%s','sipcallid','[%s][voiceCallReport][varset]\x20variable:sipcallid\x20value:%s','mixmonitor_filename','parse','sipcalllinkedid','syncHangup','[%s][voiceCallReport][hangup]\x20reason:%s','endtime','billableseconds','context','omit','[%s][voiceCallReport][hangup]\x20sending\x20user:agentcomplete\x20event:','accountcode','event','BlindTransfer','outbound','[%s][voiceCallReport][hangup]','syncAttendedTransfer','[%s][voiceCallReport][attendedtransfer]\x20transfercalleridnum:%s\x20transferconnectedlinenum:%s','origtransferercalleridnum','transfertargetcalleridnum','[%s][voiceCallReport][attendedtransfer]\x20event:','transfereeuniqueid','transfercalleridnum','transferconnectedlinenum','secondtransfereruniqueid','transfertargetuniqueid','origtransfereruniqueid','[%s][voiceCallReport][attendedtransfer]','[%s][voiceCallReport][blindtransfer]\x20transfercalleridnum:%s\x20transferconnectedlinenum:%s','extension','[%s][voiceCallReport][blindtransfer]\x20event:','transfereecalleridnum','[%s][voiceCallReport][blindtransfer]','[%s][voiceCallReport][musiconholdstart]\x20event:','mohstarttime','[%s][voiceCallReport][musiconholdstart]','[%s][voiceCallReport][musiconholdstop]\x20event:','milliseconds','[%s][voiceCallReport][musiconholdstop]\x20mohtime:%s','mohtime','[%s][voiceCallReport][musiconholdstop]','exports','bluebird','lodash','moment','util','path','ioredis','../../../config/logger','ami','../ami','not_inuse','inuse','busy','invalid','unavailable','ringing','set','queue','agi','dial','playback','voicemail','NO\x20ANSWER','FAILED','ANSWERED','BUSY','redis','defaults','localhost','channels','agents','blindTransfers','coreshowchannel','bind','syncNewExten','newchannel','syncNewChannel','newstate','syncNewState','varset','syncVarSet','newcallerid','syncNewCallerId','attendedtransfer','blindtransfer','syncBlindTransfer','syncMusicOnHoldStart','musiconholdstop','syncMusicOnHoldStop','info','[voiceCallReport][coreshowchannels]\x20started','actionCoreShowChannels','[voiceCallReport][coreshowchannels]','prototype','isNotNull','emit','uniqueid','calleridname','calleridnum','debug','[%s][voiceCallReport][newcallerid]\x20event:','inspect','linkedid','isUndefined','merge','error','[%s][voiceCallReport][newcallerid]','[%s][voiceCallReport][newchannel]\x20event:','channel','[%s][voiceCallReport][newchannel]\x20context:%s\x20exten:%s'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0x3e80,0x1e6));var _0x03e8=function(_0x1034ca,_0x14ecd6){_0x1034ca=_0x1034ca-0x0;var _0x1a023a=_0x3e80[_0x1034ca];return _0x1a023a;};'use strict';var BPromise=require(_0x03e8('0x0'));var _=require(_0x03e8('0x1'));var moment=require(_0x03e8('0x2'));var util=require(_0x03e8('0x3'));var path=require(_0x03e8('0x4'));var Redis=require(_0x03e8('0x5'));var config=require('../../../config/environment');var logger=require(_0x03e8('0x6'))(_0x03e8('0x7'));var ami=require(_0x03e8('0x8'));var Channel=require('../model/channel');var statusDesc=['unknown',_0x03e8('0x9'),_0x03e8('0xa'),_0x03e8('0xb'),_0x03e8('0xc'),_0x03e8('0xd'),_0x03e8('0xe'),'ringinuse','onhold'];var applications=[_0x03e8('0xf'),_0x03e8('0x10'),_0x03e8('0x11'),_0x03e8('0x12'),_0x03e8('0x13'),_0x03e8('0x14')];var dispositions=[_0x03e8('0x15'),'FAILED',_0x03e8('0x16'),_0x03e8('0x15'),_0x03e8('0x15'),_0x03e8('0x15'),_0x03e8('0x17'),_0x03e8('0x18'),_0x03e8('0x16'),_0x03e8('0x16'),_0x03e8('0x16')];var actions={};config[_0x03e8('0x19')]=_[_0x03e8('0x1a')](config[_0x03e8('0x19')],{'host':_0x03e8('0x1b'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x03e8('0x19')]));function VoiceCallReport(_0x5bb4cf){this[_0x03e8('0x1c')]=_0x5bb4cf['channels'];this[_0x03e8('0x1d')]=_0x5bb4cf[_0x03e8('0x1d')];this[_0x03e8('0x1e')]={};ami['on'](_0x03e8('0x1f'),this['syncNewExten'][_0x03e8('0x20')](this));ami['on']('newexten',this[_0x03e8('0x21')][_0x03e8('0x20')](this));ami['on'](_0x03e8('0x22'),this[_0x03e8('0x23')][_0x03e8('0x20')](this));ami['on'](_0x03e8('0x24'),this[_0x03e8('0x25')]['bind'](this));ami['on'](_0x03e8('0x26'),this[_0x03e8('0x27')][_0x03e8('0x20')](this));ami['on']('hangup',this['syncHangup'][_0x03e8('0x20')](this));ami['on'](_0x03e8('0x28'),this[_0x03e8('0x29')]['bind'](this));ami['on'](_0x03e8('0x2a'),this['syncAttendedTransfer'][_0x03e8('0x20')](this));ami['on'](_0x03e8('0x2b'),this[_0x03e8('0x2c')]['bind'](this));ami['on']('musiconholdstart',this[_0x03e8('0x2d')][_0x03e8('0x20')](this));ami['on'](_0x03e8('0x2e'),this[_0x03e8('0x2f')]['bind'](this));try{logger[_0x03e8('0x30')](_0x03e8('0x31'));ami[_0x03e8('0x32')]();}catch(_0x3e68e6){logger['error'](_0x03e8('0x33'),util['inspect'](_0x3e68e6,{'showHidden':![],'depth':null}));}}VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x35')]=function(_0x1714d3){return _0x1714d3!==null&&!_['isUndefined'](_0x1714d3);};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x36')]=function(_0x4689ad,_0x47a827,_0x51e898){io['to'](_0x4689ad)['emit'](_0x47a827,_0x51e898);};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x29')]=function(_0x2b00be){try{if(this[_0x03e8('0x35')](_0x2b00be)){logger['info']('[%s][voiceCallReport][newcallerid]\x20calleridname:%s\x20calleridnum:%s',_0x2b00be[_0x03e8('0x37')],_0x2b00be[_0x03e8('0x38')],_0x2b00be[_0x03e8('0x39')]);logger[_0x03e8('0x3a')](_0x03e8('0x3b'),_0x2b00be[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x2b00be,{'showHidden':![],'depth':null}));if(_0x2b00be[_0x03e8('0x37')]===_0x2b00be[_0x03e8('0x3d')]){if(!_[_0x03e8('0x3e')](this[_0x03e8('0x1c')][_0x2b00be['uniqueid']])){_[_0x03e8('0x3f')](this[_0x03e8('0x1c')][_0x2b00be[_0x03e8('0x37')]],_['pick'](_0x2b00be,_['keys'](this[_0x03e8('0x1c')][_0x2b00be[_0x03e8('0x37')]])));}}}}catch(_0x27aa40){logger[_0x03e8('0x40')](_0x03e8('0x41'),_0x2b00be[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x27aa40,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x23')]=function(_0x4e91ed){try{if(this['isNotNull'](_0x4e91ed)){logger[_0x03e8('0x3a')](_0x03e8('0x42'),_0x4e91ed['uniqueid'],util[_0x03e8('0x3c')](_0x4e91ed,{'showHidden':![],'depth':null}));if(_0x4e91ed[_0x03e8('0x37')]===_0x4e91ed[_0x03e8('0x3d')]&&_0x4e91ed[_0x03e8('0x43')]!='OutgoingSpoolFailed'){if(_['isUndefined'](this[_0x03e8('0x1c')][_0x4e91ed[_0x03e8('0x37')]])){logger[_0x03e8('0x30')](_0x03e8('0x44'),_0x4e91ed['uniqueid'],_0x4e91ed['context'],_0x4e91ed['exten']);this[_0x03e8('0x1c')][_0x4e91ed[_0x03e8('0x37')]]=new Channel();this[_0x03e8('0x1c')][_0x4e91ed[_0x03e8('0x37')]]['starttime']=moment()[_0x03e8('0x45')](_0x03e8('0x46'));this['channels'][_0x4e91ed[_0x03e8('0x37')]][_0x03e8('0x47')]=dispositions[_['toNumber'](_0x4e91ed[_0x03e8('0x48')])];_['merge'](this[_0x03e8('0x1c')][_0x4e91ed[_0x03e8('0x37')]],_[_0x03e8('0x49')](_0x4e91ed,_[_0x03e8('0x4a')](this[_0x03e8('0x1c')][_0x4e91ed[_0x03e8('0x37')]])));if(_0x4e91ed['context']===_0x03e8('0x4b')){if(this[_0x03e8('0x1d')][_0x4e91ed[_0x03e8('0x43')]['split']('-')[0x0]]){this[_0x03e8('0x1d')][_0x4e91ed[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]][_0x03e8('0x4d')]=_0x4e91ed[_0x03e8('0x4e')];logger['debug'](_0x03e8('0x4f'),_0x4e91ed[_0x03e8('0x37')],util[_0x03e8('0x3c')]({'destaccountcode':this[_0x03e8('0x1d')][_0x4e91ed[_0x03e8('0x43')]['split']('-')[0x0]]['accountcode'],'destconnectedlinenum':_0x4e91ed['exten']},{'showHidden':![],'depth':null}));this[_0x03e8('0x36')](util[_0x03e8('0x45')]('user:%s',this[_0x03e8('0x1d')][_0x4e91ed[_0x03e8('0x43')]['split']('-')[0x0]][_0x03e8('0x50')]),_0x03e8('0x51'),{'destaccountcode':this[_0x03e8('0x1d')][_0x4e91ed['channel'][_0x03e8('0x4c')]('-')[0x0]]['accountcode'],'destconnectedlinenum':_0x4e91ed['exten']});}}}}}}catch(_0x5a8a8a){logger['error'](_0x03e8('0x52'),_0x4e91ed['uniqueid'],util[_0x03e8('0x3c')](_0x5a8a8a,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')]['syncNewExten']=function(_0x5de6e7){try{if(this['isNotNull'](_0x5de6e7)){logger[_0x03e8('0x3a')](_0x03e8('0x53'),_0x5de6e7[_0x03e8('0x37')],util['inspect'](_0x5de6e7,{'showHidden':![],'depth':null}));if(_0x5de6e7[_0x03e8('0x37')]===_0x5de6e7[_0x03e8('0x3d')]&&_0x5de6e7[_0x03e8('0x4e')]!='h'&&_0x5de6e7[_0x03e8('0x43')]!='OutgoingSpoolFailed'){_0x5de6e7['application']=_0x5de6e7['application'][_0x03e8('0x54')]();_0x5de6e7['applicationdata']=(_0x5de6e7[_0x03e8('0x55')]||_0x5de6e7[_0x03e8('0x56')])[_0x03e8('0x54')]();logger[_0x03e8('0x30')](_0x03e8('0x57'),_0x5de6e7[_0x03e8('0x37')],_0x5de6e7[_0x03e8('0x58')],_0x5de6e7[_0x03e8('0x56')]);if(_[_0x03e8('0x3e')](this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]])){this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]]=new Channel();this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]][_0x03e8('0x59')]=_0x5de6e7[_0x03e8('0x5a')]?moment()[_0x03e8('0x5b')](moment[_0x03e8('0x5a')](_0x5de6e7[_0x03e8('0x5a')])[_0x03e8('0x5c')](),_0x03e8('0x5c'))[_0x03e8('0x45')](_0x03e8('0x46')):moment()['format'](_0x03e8('0x46'));this[_0x03e8('0x1c')][_0x5de6e7['uniqueid']]['disposition']=_0x03e8('0x15');}_[_0x03e8('0x3f')](this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]],_['pick'](_0x5de6e7,_[_0x03e8('0x4a')](this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]])));if(_[_0x03e8('0x5d')](applications,_0x5de6e7['application'])){this[_0x03e8('0x1c')][_0x5de6e7[_0x03e8('0x37')]]['lastapplication']=_0x5de6e7[_0x03e8('0x58')];this['channels'][_0x5de6e7[_0x03e8('0x37')]][_0x03e8('0x5e')]=_0x5de6e7[_0x03e8('0x56')];if(_0x5de6e7['application']===_0x03e8('0xf')&&_[_0x03e8('0x5f')](_0x5de6e7[_0x03e8('0x56')],'cdr(')){var _0x4f64e8=_0x5de6e7[_0x03e8('0x56')][_0x03e8('0x4c')]('=');var _0x5c8040=_0x4f64e8[0x0][_0x03e8('0x60')](/cdr\((.*)\)/);if(_0x5c8040){this[_0x03e8('0x1c')][_0x5de6e7['uniqueid']][_0x5c8040[0x1]]=_0x4f64e8[0x1];}}else if(_0x5de6e7['application']===_0x03e8('0x10')){this[_0x03e8('0x1c')][_0x5de6e7['uniqueid']]['queue']=_0x5de6e7[_0x03e8('0x56')][_0x03e8('0x4c')](',')[0x0];}}}}}catch(_0x5617d1){logger[_0x03e8('0x40')](_0x03e8('0x61'),_0x5de6e7['uniqueid'],util[_0x03e8('0x3c')](_0x5617d1,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')]['syncNewState']=function(_0x16abff){try{if(this[_0x03e8('0x35')](_0x16abff)){logger[_0x03e8('0x30')]('[%s][voiceCallReport][newstate]\x20linkedid:%s\x20calleridname:%s\x20calleridnum:%s',_0x16abff[_0x03e8('0x37')],_0x16abff[_0x03e8('0x3d')],_0x16abff[_0x03e8('0x38')],_0x16abff[_0x03e8('0x39')]);logger['debug'](_0x03e8('0x62'),_0x16abff['uniqueid'],util[_0x03e8('0x3c')](_0x16abff,{'showHidden':![],'depth':null}));if(_0x16abff[_0x03e8('0x37')]!==_0x16abff['linkedid']){if(this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]]){if(_0x16abff[_0x03e8('0x48')]==='6'){if(!this['channels'][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x63')]){var _0x165fe0=moment();this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x63')]=!![];this[_0x03e8('0x1c')][_0x16abff['linkedid']][_0x03e8('0x64')]=_0x165fe0[_0x03e8('0x45')](_0x03e8('0x46'));if(this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]]['starttime']){this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]]['holdtime']=_0x165fe0[_0x03e8('0x65')](this['channels'][_0x16abff[_0x03e8('0x3d')]]['starttime'],'seconds');}}this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x3d')]=_0x16abff[_0x03e8('0x37')];if(_0x16abff[_0x03e8('0x39')]!==_0x03e8('0x66')){this['channels'][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x67')]=_0x16abff[_0x03e8('0x39')];}this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x68')]=_0x16abff[_0x03e8('0x38')];this[_0x03e8('0x1c')][_0x16abff['linkedid']][_0x03e8('0x69')]=_0x16abff[_0x03e8('0x43')];this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x47')]=dispositions[_[_0x03e8('0x6a')](_0x16abff['channelstate'])];if(this[_0x03e8('0x1d')][_0x16abff[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]){this['channels'][_0x16abff['linkedid']][_0x03e8('0x6b')]=this[_0x03e8('0x1d')][_0x16abff[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]['id'];this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x3d')]][_0x03e8('0x6c')]=this[_0x03e8('0x1d')][_0x16abff[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]][_0x03e8('0x50')];}}}}else{if(this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x37')]]){if(_0x16abff['channelstate']==='6'){if(this[_0x03e8('0x1d')][_0x16abff['channel'][_0x03e8('0x4c')]('-')[0x0]]){this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x37')]]['UserId']=this['agents'][_0x16abff[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]['id'];this[_0x03e8('0x1c')][_0x16abff[_0x03e8('0x37')]][_0x03e8('0x6c')]=this['agents'][_0x16abff[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]['name'];}}}}}}catch(_0x2063b9){logger['error'](_0x03e8('0x6d'),_0x16abff[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x2063b9,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x6e')]=function(_0x5757ed,_0x4f0f17){try{if(this[_0x03e8('0x1c')][_0x5757ed]){logger['info'](_0x03e8('0x6f'),_0x5757ed,_0x4f0f17);this[_0x03e8('0x1c')][_0x5757ed][_0x03e8('0x70')]=!![];if(_[_0x03e8('0x71')](_0x4f0f17,_0x03e8('0x72'))){_0x4f0f17=_0x4f0f17[_0x03e8('0x73')]('.wav49',_0x03e8('0x74'));}this[_0x03e8('0x1c')][_0x5757ed]['monitorFilename']=_0x4f0f17;var _0x5f38b4=_['find'](this[_0x03e8('0x1c')][_0x5757ed][_0x03e8('0x75')],{'filename':_0x4f0f17});if(_[_0x03e8('0x76')](_0x5f38b4)){this[_0x03e8('0x1c')][_0x5757ed]['monitors'][_0x03e8('0x77')]({'filename':_0x4f0f17,'createdAt':moment()[_0x03e8('0x45')](_0x03e8('0x46')),'mixmonitorid':'','status':'rec'});}}}catch(_0x434129){logger[_0x03e8('0x40')](_0x03e8('0x78'),_0x5757ed,util[_0x03e8('0x3c')](_0x434129,{'showHidden':![],'depth':null}));}};VoiceCallReport['prototype'][_0x03e8('0x27')]=function(_0x3f51b4){try{if(this[_0x03e8('0x35')](_0x3f51b4)){logger[_0x03e8('0x3a')]('[%s][voiceCallReport][varset]\x20event:',_0x3f51b4[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x3f51b4,{'showHidden':![],'depth':null}));if(this[_0x03e8('0x1c')][_0x3f51b4['uniqueid']]&&_0x3f51b4[_0x03e8('0x43')]!='OutgoingSpoolFailed'){if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')])){if(this[_0x03e8('0x35')](_0x3f51b4['variable']['mixmonitor_filename'])){logger[_0x03e8('0x30')](_0x03e8('0x7a'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4['value']);this[_0x03e8('0x6e')](_0x3f51b4[_0x03e8('0x37')],_0x3f51b4['value']);}else if(this[_0x03e8('0x35')](_0x3f51b4['variable'][_0x03e8('0x7b')])){logger[_0x03e8('0x30')](_0x03e8('0x7c'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4['value']);this[_0x03e8('0x1c')][_0x3f51b4[_0x03e8('0x37')]][_0x03e8('0x39')]=_0x3f51b4[_0x03e8('0x7d')];}else if(this['isNotNull'](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x7e')])){logger[_0x03e8('0x30')](_0x03e8('0x7f'),_0x3f51b4['uniqueid'],_0x3f51b4[_0x03e8('0x7d')]);this['channels'][_0x3f51b4[_0x03e8('0x37')]][_0x03e8('0x80')]=_0x3f51b4[_0x03e8('0x7d')];}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x81')])){logger[_0x03e8('0x30')](_0x03e8('0x82'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this['channels'][_0x3f51b4[_0x03e8('0x37')]][_0x03e8('0x83')]=_0x3f51b4[_0x03e8('0x7d')];}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x84')])){logger['info'](_0x03e8('0x85'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]['split'](',')[0x0]);this[_0x03e8('0x1c')][_0x3f51b4['uniqueid']][_0x03e8('0x10')]=_0x3f51b4['value'][_0x03e8('0x4c')](',')[0x0];}else if(this['isNotNull'](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x86')])){logger[_0x03e8('0x30')]('[%s][voiceCallReport][varset]\x20variable:xmd-originatecalleridnum\x20value:%s',_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this['channels'][_0x3f51b4[_0x03e8('0x37')]][_0x03e8('0x87')]=_0x3f51b4[_0x03e8('0x7d')];}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x88')])){logger[_0x03e8('0x30')](_0x03e8('0x89'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this[_0x03e8('0x1c')][_0x3f51b4[_0x03e8('0x37')]][_0x03e8('0x8a')]=_0x3f51b4['value'];}else if(this['isNotNull'](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x8b')])){logger['info'](_0x03e8('0x8c'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this[_0x03e8('0x1c')][_0x3f51b4[_0x03e8('0x37')]]['calleridpreview']=_0x3f51b4[_0x03e8('0x7d')];}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')]['xmcs-queue'])){logger[_0x03e8('0x30')](_0x03e8('0x8d'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this[_0x03e8('0x1c')][_0x3f51b4['uniqueid']]['queue']=_0x3f51b4['value'];}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x8e')])){logger[_0x03e8('0x30')](_0x03e8('0x8f'),_0x3f51b4[_0x03e8('0x37')],_0x3f51b4[_0x03e8('0x7d')]);this[_0x03e8('0x1c')][_0x3f51b4['uniqueid']]['sipcalluniqueid']=_0x3f51b4[_0x03e8('0x7d')];}}}else if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x90')])){if(_0x3f51b4[_0x03e8('0x7d')]){var _0x5cb238=path[_0x03e8('0x91')](_0x3f51b4[_0x03e8('0x7d')])['name'];logger['info'](_0x03e8('0x7a'),_0x5cb238,_0x3f51b4[_0x03e8('0x7d')]);this[_0x03e8('0x6e')](_0x5cb238,_0x3f51b4[_0x03e8('0x7d')]);}}else if(this[_0x03e8('0x1c')][_0x3f51b4[_0x03e8('0x3d')]]){if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')])){if(this[_0x03e8('0x35')](_0x3f51b4[_0x03e8('0x79')][_0x03e8('0x8e')])){logger[_0x03e8('0x30')]('[%s][voiceCallReport][varset]\x20variable:sipcallid\x20value:%s',_0x3f51b4[_0x03e8('0x3d')],_0x3f51b4['value']);this[_0x03e8('0x1c')][_0x3f51b4['linkedid']][_0x03e8('0x92')]=_0x3f51b4[_0x03e8('0x7d')];}}}}}catch(_0x32b09c){logger['error']('[%s][voiceCallReport][varset]',_0x3f51b4[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x32b09c,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x93')]=function(_0xa6926b){try{if(this[_0x03e8('0x35')](_0xa6926b)){logger[_0x03e8('0x3a')]('[%s][voiceCallReport][hangup]\x20event:',_0xa6926b[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0xa6926b,{'showHidden':![],'depth':null}));if(this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]]){logger[_0x03e8('0x30')](_0x03e8('0x94'),_0xa6926b[_0x03e8('0x37')],_0xa6926b['cause-txt']);var _0xb39fec=moment();this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]][_0x03e8('0x95')]=_0xb39fec[_0x03e8('0x45')](_0x03e8('0x46'));this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]][_0x03e8('0x5a')]=_0xb39fec[_0x03e8('0x65')](this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x59')],_0x03e8('0x5c'));if(this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]][_0x03e8('0x63')]){this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x96')]=_0xb39fec[_0x03e8('0x65')](this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x64')],'seconds');this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]]['holdtime']=this['channels'][_0xa6926b[_0x03e8('0x37')]][_0x03e8('0x5a')]-this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]]['billableseconds'];}if(_0xa6926b[_0x03e8('0x97')]===_0x03e8('0x4b')){if(this[_0x03e8('0x1d')][_0xa6926b[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]){this[_0x03e8('0x1d')][_0xa6926b[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]]=_[_0x03e8('0x98')](this[_0x03e8('0x1d')][_0xa6926b[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]],['destconnectedlinenum']);logger[_0x03e8('0x3a')](_0x03e8('0x99'),_0xa6926b[_0x03e8('0x37')],util['inspect']({'destaccountcode':this[_0x03e8('0x1d')][_0xa6926b['channel']['split']('-')[0x0]][_0x03e8('0x9a')]},{'showHidden':![],'depth':null}));this['emit'](util['format']('user:%s',this[_0x03e8('0x1d')][_0xa6926b[_0x03e8('0x43')][_0x03e8('0x4c')]('-')[0x0]][_0x03e8('0x50')]),'user:agentcomplete',{'destaccountcode':this[_0x03e8('0x1d')][_0xa6926b[_0x03e8('0x43')]['split']('-')[0x0]][_0x03e8('0x9a')]});}}if(_0xa6926b[_0x03e8('0x9b')]===_0x03e8('0x9c')){this[_0x03e8('0x1e')][_0xa6926b[_0x03e8('0x37')]]=this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]];}else{if(this['channels'][_0xa6926b[_0x03e8('0x37')]][_0x03e8('0x83')]===_0x03e8('0x9d')&&this[_0x03e8('0x1e')][_0xa6926b[_0x03e8('0x37')]]){this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x37')]=[this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x3d')],this[_0x03e8('0x1c')][_0xa6926b['uniqueid']]['linkedid']=this[_0x03e8('0x1c')][_0xa6926b['uniqueid']][_0x03e8('0x37')]][0x0];delete this['blindTransfers'][_0xa6926b[_0x03e8('0x37')]];}}logger[_0x03e8('0x3a')]('[%s][voiceCallReport][hangup]\x20sending\x20hangup\x20event:',_0xa6926b[_0x03e8('0x37')],util[_0x03e8('0x3c')](this['channels'][_0xa6926b['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x03e8('0x36')]('custom:voiceCallReport',this[_0x03e8('0x1c')][_0xa6926b[_0x03e8('0x37')]]);delete this['channels'][_0xa6926b['uniqueid']];}}}catch(_0x3fc940){logger[_0x03e8('0x40')](_0x03e8('0x9e'),_0xa6926b[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x3fc940,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x9f')]=function(_0x25a8fa){try{if(this[_0x03e8('0x35')](_0x25a8fa)){logger[_0x03e8('0x30')](_0x03e8('0xa0'),_0x25a8fa['uniqueid'],_0x25a8fa[_0x03e8('0xa1')],_0x25a8fa[_0x03e8('0xa2')]);logger['debug'](_0x03e8('0xa3'),_0x25a8fa[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x25a8fa,{'showHidden':![],'depth':null}));if(this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa4')]]){this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa4')]][_0x03e8('0xa5')]=_0x25a8fa[_0x03e8('0xa1')];this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa4')]][_0x03e8('0xa6')]=_0x25a8fa['transfertargetcalleridnum'];if(this['channels'][_0x25a8fa[_0x03e8('0xa7')]]){var _0x192e21=this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa7')]];this[_0x03e8('0x1c')][_0x25a8fa['secondtransfereruniqueid']]=this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa4')]];this['channels'][_0x25a8fa['transfereeuniqueid']]=_0x192e21;}}else if(this['channels'][_0x25a8fa[_0x03e8('0xa8')]]){this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa8')]][_0x03e8('0xa5')]=_0x25a8fa['origtransferercalleridnum'];this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa8')]][_0x03e8('0xa6')]=_0x25a8fa[_0x03e8('0xa2')];if(this['channels'][_0x25a8fa[_0x03e8('0xa9')]]){var _0x192e21=this[_0x03e8('0x1c')][_0x25a8fa[_0x03e8('0xa9')]];this[_0x03e8('0x1c')][_0x25a8fa['origtransfereruniqueid']]=this['channels'][_0x25a8fa[_0x03e8('0xa8')]];this['channels'][_0x25a8fa[_0x03e8('0xa8')]]=_0x192e21;}}}}catch(_0x20b3a9){logger[_0x03e8('0x40')](_0x03e8('0xaa'),_0x25a8fa[_0x03e8('0x37')],util['inspect'](_0x20b3a9,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')][_0x03e8('0x2c')]=function(_0x270230){try{if(this[_0x03e8('0x35')](_0x270230)){logger['info'](_0x03e8('0xab'),_0x270230[_0x03e8('0x37')],_0x270230['transfereecalleridnum'],_0x270230[_0x03e8('0xac')]);logger['debug'](_0x03e8('0xad'),_0x270230[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x270230,{'showHidden':![],'depth':null}));if(this[_0x03e8('0x1c')][_0x270230['transfereeuniqueid']]){this[_0x03e8('0x1c')][_0x270230[_0x03e8('0xa4')]]['transfercalleridnum']=_0x270230[_0x03e8('0xae')];this[_0x03e8('0x1c')][_0x270230[_0x03e8('0xa4')]][_0x03e8('0xa6')]=_0x270230[_0x03e8('0xac')];this[_0x03e8('0x93')]({'event':'BlindTransfer','uniqueid':_0x270230[_0x03e8('0xa4')],'context':_0x270230['context'],'channel':_0x270230['transfererchannel']});}}}catch(_0xdd22bb){logger['error'](_0x03e8('0xaf'),_0x270230[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0xdd22bb,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0x03e8('0x34')]['syncMusicOnHoldStart']=function(_0x4f74f2){try{if(this[_0x03e8('0x35')](_0x4f74f2)){logger['debug'](_0x03e8('0xb0'),_0x4f74f2[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x4f74f2,{'showHidden':![],'depth':null}));if(this['channels'][_0x4f74f2['uniqueid']]){if(!_[_0x03e8('0x76')](this[_0x03e8('0x1c')][_0x4f74f2[_0x03e8('0x37')]][_0x03e8('0x64')])){this['channels'][_0x4f74f2[_0x03e8('0x37')]][_0x03e8('0xb1')]=moment()[_0x03e8('0x45')](_0x03e8('0x46'));logger[_0x03e8('0x30')]('[%s][voiceCallReport][musiconholdstart]\x20mohstarttime:%s',_0x4f74f2['uniqueid'],this['channels'][_0x4f74f2[_0x03e8('0x37')]]['mohstarttime']);}}}}catch(_0x93c365){logger[_0x03e8('0x40')](_0x03e8('0xb2'),_0x4f74f2[_0x03e8('0x37')],util[_0x03e8('0x3c')](_0x93c365,{'showHidden':![],'depth':null}));}};VoiceCallReport['prototype'][_0x03e8('0x2f')]=function(_0x4136bf){try{if(this[_0x03e8('0x35')](_0x4136bf)){logger[_0x03e8('0x3a')](_0x03e8('0xb3'),_0x4136bf['uniqueid'],util[_0x03e8('0x3c')](_0x4136bf,{'showHidden':![],'depth':null}));if(this['channels'][_0x4136bf[_0x03e8('0x37')]]){if(!_[_0x03e8('0x76')](this[_0x03e8('0x1c')][_0x4136bf['uniqueid']][_0x03e8('0xb1')])){this[_0x03e8('0x1c')][_0x4136bf[_0x03e8('0x37')]]['mohtime']+=moment()[_0x03e8('0xb4')](0x0)[_0x03e8('0x65')](this[_0x03e8('0x1c')][_0x4136bf[_0x03e8('0x37')]][_0x03e8('0xb1')],_0x03e8('0x5c'));logger[_0x03e8('0x30')](_0x03e8('0xb5'),_0x4136bf['uniqueid'],this[_0x03e8('0x1c')][_0x4136bf[_0x03e8('0x37')]][_0x03e8('0xb6')]);delete this[_0x03e8('0x1c')][_0x4136bf[_0x03e8('0x37')]]['mohstarttime'];}}}}catch(_0x4ac272){logger[_0x03e8('0x40')](_0x03e8('0xb7'),_0x4136bf['uniqueid'],util['inspect'](_0x4ac272,{'showHidden':![],'depth':null}));}};module[_0x03e8('0xb8')]=VoiceCallReport;