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