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