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