Built motion from commit (unavailable).|2.5.30
[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 _0x222b=['[%s][voiceCallReport][hangup]\x20sending\x20user:agentcomplete\x20event:','user:agentcomplete','resolve','then','transferType','undefined','getSettings','stopRecordingOnTransfer','StopMixMonitor','catch','Action','finally','webbar:stopmonitors','event','BlindTransfer','outbound','[%s][voiceCallReport][hangup]\x20sending\x20hangup\x20event:','custom:voiceCallReport','syncAttendedTransfer','origtransferercalleridnum','[%s][voiceCallReport][attendedtransfer]\x20event:','transfereeuniqueid','transfercalleridnum','transferconnectedlinenum','transfertargetcalleridnum','secondtransfereruniqueid','transfertargetuniqueid','origtransfereruniqueid','origtransfererlinkedid','routeid','ATTENDED','[%s][voiceCallReport][attendedtransfer]','extension','[%s][voiceCallReport][blindtransfer]\x20event:','transfererchannel','[%s][voiceCallReport][blindtransfer]','mohstarttime','[%s][voiceCallReport][musiconholdstart]','[%s][voiceCallReport][musiconholdstop]\x20event:','mohtime','milliseconds','[%s][voiceCallReport][musiconholdstop]','exports','bluebird','moment','ioredis','../../../config/environment','../../../config/logger','ami','../model/channel','../rpc/setting','unknown','not_inuse','inuse','invalid','unavailable','ringing','ringinuse','set','queue','agi','dial','FAILED','NO\x20ANSWER','BUSY','redis','defaults','localhost','socket.io-emitter','channels','agents','blindTransfers','coreshowchannel','syncNewExten','bind','newexten','newchannel','newstate','syncNewState','varset','hangup','syncHangup','newcallerid','syncNewCallerId','attendedtransfer','syncBlindTransfer','musiconholdstart','syncMusicOnHoldStart','musiconholdstop','syncMusicOnHoldStop','error','[voiceCallReport][coreshowchannels]','inspect','isNotNull','isUndefined','prototype','emit','[%s][voiceCallReport][newcallerid]\x20calleridname:%s\x20calleridnum:%s','uniqueid','calleridnum','debug','[%s][voiceCallReport][newcallerid]\x20event:','merge','pick','[%s][voiceCallReport][newcallerid]','syncNewChannel','[%s][voiceCallReport][newchannel]\x20event:','channel','OutgoingSpoolFailed','info','[%s][voiceCallReport][newchannel]\x20context:%s\x20exten:%s','context','exten','starttime','format','YYYY-MM-DD\x20HH:mm:ss','toNumber','channelstate','keys','from-sip','split','[%s][voiceCallReport][newchannel]\x20sending\x20user:agentconnect\x20event:','user:%s','name','accountcode','linkedid','application','toLowerCase','applicationdata','duration','subtract','seconds','disposition','includes','lastapplication','lastdata','startsWith','[%s][voiceCallReport][newexten]','[%s][voiceCallReport][newstate]\x20linkedid:%s\x20calleridname:%s\x20calleridnum:%s','calleridname','[%s][voiceCallReport][newstate]\x20event:','answered','answertime','holdtime','diff','xcally-motion-preview','connectedlinenum','connectedlinename','destinationchannel','UserId','[%s][voiceCallReport][newstate]','syncMixMonitorFilename','[%s][voiceCallReport][mixMonitorFilename]\x20monitorFilename:%s','endsWith','.wav49','replace','.WAV','monitorFilename','find','monitors','isNil','rec','[%s][voiceCallReport][mixMonitorFilename]','syncVarSet','[%s][voiceCallReport][varset]\x20event:','variable','[%s][voiceCallReport][varset]\x20variable:mixmonitor_filename\x20value:%s','value','xmd-phone','xmd-callerid','callerid','xmd-cdrtype','[%s][voiceCallReport][varset]\x20variable:xmd-cdrtype\x20value:%s','type','[%s][voiceCallReport][varset]\x20variable:xmd-queue\x20value:%s','xmd-originatecalleridnum','[%s][voiceCallReport][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','xmd-destination','[%s][voiceCallReport][varset]\x20variable:xmd-destination\x20value:%s','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','sipcalluniqueid','parse','sipcalllinkedid','[%s][voiceCallReport][varset]','[%s][voiceCallReport][hangup]\x20event:','[%s][voiceCallReport][hangup]\x20reason:%s','endtime','billableseconds','omit','destconnectedlinenum'];(function(_0x3c93a2,_0x11ce60){var _0x261302=function(_0x1832cf){while(--_0x1832cf){_0x3c93a2['push'](_0x3c93a2['shift']());}};_0x261302(++_0x11ce60);}(_0x222b,0xee));var _0xb222=function(_0xb113d7,_0x2fc306){_0xb113d7=_0xb113d7-0x0;var _0xd5a08d=_0x222b[_0xb113d7];return _0xd5a08d;};'use strict';var BPromise=require(_0xb222('0x0'));var _=require('lodash');var moment=require(_0xb222('0x1'));var util=require('util');var path=require('path');var Redis=require(_0xb222('0x2'));var config=require(_0xb222('0x3'));var logger=require(_0xb222('0x4'))(_0xb222('0x5'));var ami=require('../ami');var Channel=require(_0xb222('0x6'));var RpcSetting=require(_0xb222('0x7'));var statusDesc=[_0xb222('0x8'),_0xb222('0x9'),_0xb222('0xa'),'busy',_0xb222('0xb'),_0xb222('0xc'),_0xb222('0xd'),_0xb222('0xe'),'onhold'];var applications=[_0xb222('0xf'),_0xb222('0x10'),_0xb222('0x11'),_0xb222('0x12'),'playback','voicemail'];var dispositions=['NO\x20ANSWER','FAILED',_0xb222('0x13'),_0xb222('0x14'),_0xb222('0x14'),'NO\x20ANSWER','ANSWERED',_0xb222('0x15'),_0xb222('0x13'),'FAILED',_0xb222('0x13')];var actions={};config[_0xb222('0x16')]=_[_0xb222('0x17')](config[_0xb222('0x16')],{'host':_0xb222('0x18'),'port':0x18eb});var io=require(_0xb222('0x19'))(new Redis(config[_0xb222('0x16')]));function VoiceCallReport(_0x524e72){this['channels']=_0x524e72[_0xb222('0x1a')];this[_0xb222('0x1b')]=_0x524e72['agents'];this[_0xb222('0x1c')]={};ami['on'](_0xb222('0x1d'),this[_0xb222('0x1e')][_0xb222('0x1f')](this));ami['on'](_0xb222('0x20'),this['syncNewExten'][_0xb222('0x1f')](this));ami['on'](_0xb222('0x21'),this['syncNewChannel'][_0xb222('0x1f')](this));ami['on'](_0xb222('0x22'),this[_0xb222('0x23')]['bind'](this));ami['on'](_0xb222('0x24'),this['syncVarSet']['bind'](this));ami['on'](_0xb222('0x25'),this[_0xb222('0x26')][_0xb222('0x1f')](this));ami['on'](_0xb222('0x27'),this[_0xb222('0x28')][_0xb222('0x1f')](this));ami['on'](_0xb222('0x29'),this['syncAttendedTransfer'][_0xb222('0x1f')](this));ami['on']('blindtransfer',this[_0xb222('0x2a')][_0xb222('0x1f')](this));ami['on'](_0xb222('0x2b'),this[_0xb222('0x2c')][_0xb222('0x1f')](this));ami['on'](_0xb222('0x2d'),this[_0xb222('0x2e')][_0xb222('0x1f')](this));try{logger['info']('[voiceCallReport][coreshowchannels]\x20started');ami['actionCoreShowChannels']();}catch(_0x28ec9b){logger[_0xb222('0x2f')](_0xb222('0x30'),util[_0xb222('0x31')](_0x28ec9b,{'showHidden':![],'depth':null}));}}VoiceCallReport['prototype'][_0xb222('0x32')]=function(_0x3f4856){return _0x3f4856!==null&&!_[_0xb222('0x33')](_0x3f4856);};VoiceCallReport[_0xb222('0x34')][_0xb222('0x35')]=function(_0x39dfcf,_0x28f64b,_0x17cad7){io['to'](_0x39dfcf)[_0xb222('0x35')](_0x28f64b,_0x17cad7);};VoiceCallReport[_0xb222('0x34')][_0xb222('0x28')]=function(_0x3a3340){try{if(this[_0xb222('0x32')](_0x3a3340)){logger['info'](_0xb222('0x36'),_0x3a3340[_0xb222('0x37')],_0x3a3340['calleridname'],_0x3a3340[_0xb222('0x38')]);logger[_0xb222('0x39')](_0xb222('0x3a'),_0x3a3340[_0xb222('0x37')],util[_0xb222('0x31')](_0x3a3340,{'showHidden':![],'depth':null}));if(_0x3a3340['uniqueid']===_0x3a3340['linkedid']){if(!_['isUndefined'](this[_0xb222('0x1a')][_0x3a3340[_0xb222('0x37')]])){_[_0xb222('0x3b')](this[_0xb222('0x1a')][_0x3a3340[_0xb222('0x37')]],_[_0xb222('0x3c')](_0x3a3340,_['keys'](this['channels'][_0x3a3340[_0xb222('0x37')]])));}}}}catch(_0x2e9234){logger[_0xb222('0x2f')](_0xb222('0x3d'),_0x3a3340[_0xb222('0x37')],util[_0xb222('0x31')](_0x2e9234,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x3e')]=function(_0x27921e){try{if(this['isNotNull'](_0x27921e)){logger[_0xb222('0x39')](_0xb222('0x3f'),_0x27921e[_0xb222('0x37')],util['inspect'](_0x27921e,{'showHidden':![],'depth':null}));if(_0x27921e[_0xb222('0x37')]===_0x27921e['linkedid']&&_0x27921e[_0xb222('0x40')]!=_0xb222('0x41')){if(_[_0xb222('0x33')](this[_0xb222('0x1a')][_0x27921e['uniqueid']])){logger[_0xb222('0x42')](_0xb222('0x43'),_0x27921e[_0xb222('0x37')],_0x27921e[_0xb222('0x44')],_0x27921e[_0xb222('0x45')]);this[_0xb222('0x1a')][_0x27921e[_0xb222('0x37')]]=new Channel();this[_0xb222('0x1a')][_0x27921e[_0xb222('0x37')]][_0xb222('0x46')]=moment()[_0xb222('0x47')](_0xb222('0x48'));this[_0xb222('0x1a')][_0x27921e['uniqueid']]['disposition']=dispositions[_[_0xb222('0x49')](_0x27921e[_0xb222('0x4a')])];_[_0xb222('0x3b')](this[_0xb222('0x1a')][_0x27921e[_0xb222('0x37')]],_[_0xb222('0x3c')](_0x27921e,_[_0xb222('0x4b')](this[_0xb222('0x1a')][_0x27921e['uniqueid']])));if(_0x27921e[_0xb222('0x44')]===_0xb222('0x4c')){if(this[_0xb222('0x1b')][_0x27921e[_0xb222('0x40')]['split']('-')[0x0]]){this[_0xb222('0x1b')][_0x27921e[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]]['destconnectedlinenum']=_0x27921e[_0xb222('0x45')];logger[_0xb222('0x39')](_0xb222('0x4e'),_0x27921e[_0xb222('0x37')],util[_0xb222('0x31')]({'destaccountcode':this['agents'][_0x27921e[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]]['accountcode'],'destconnectedlinenum':_0x27921e[_0xb222('0x45')]},{'showHidden':![],'depth':null}));this[_0xb222('0x35')](util[_0xb222('0x47')](_0xb222('0x4f'),this[_0xb222('0x1b')][_0x27921e[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]][_0xb222('0x50')]),'user:agentconnect',{'destaccountcode':this[_0xb222('0x1b')][_0x27921e[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]][_0xb222('0x51')],'destconnectedlinenum':_0x27921e[_0xb222('0x45')]});}}}}}}catch(_0x4e1636){logger[_0xb222('0x2f')]('[%s][voiceCallReport][newchannel]',_0x27921e[_0xb222('0x37')],util[_0xb222('0x31')](_0x4e1636,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x1e')]=function(_0x53bb5d){try{if(this[_0xb222('0x32')](_0x53bb5d)){logger['debug']('[%s][voiceCallReport][newexten]\x20event:',_0x53bb5d['uniqueid'],util['inspect'](_0x53bb5d,{'showHidden':![],'depth':null}));if(_0x53bb5d[_0xb222('0x37')]===_0x53bb5d[_0xb222('0x52')]&&_0x53bb5d['exten']!='h'&&_0x53bb5d[_0xb222('0x40')]!=_0xb222('0x41')){_0x53bb5d[_0xb222('0x53')]=_0x53bb5d[_0xb222('0x53')][_0xb222('0x54')]();_0x53bb5d[_0xb222('0x55')]=(_0x53bb5d['appdata']||_0x53bb5d[_0xb222('0x55')])[_0xb222('0x54')]();logger[_0xb222('0x42')]('[%s][voiceCallReport][newexten]\x20application:%s\x20appdata:%s',_0x53bb5d[_0xb222('0x37')],_0x53bb5d[_0xb222('0x53')],_0x53bb5d[_0xb222('0x55')]);if(_[_0xb222('0x33')](this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]])){this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]]=new Channel();this[_0xb222('0x1a')][_0x53bb5d['uniqueid']]['starttime']=_0x53bb5d[_0xb222('0x56')]?moment()[_0xb222('0x57')](moment[_0xb222('0x56')](_0x53bb5d[_0xb222('0x56')])[_0xb222('0x58')](),_0xb222('0x58'))[_0xb222('0x47')](_0xb222('0x48')):moment()[_0xb222('0x47')](_0xb222('0x48'));this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]][_0xb222('0x59')]=_0xb222('0x14');}_['merge'](this[_0xb222('0x1a')][_0x53bb5d['uniqueid']],_[_0xb222('0x3c')](_0x53bb5d,_[_0xb222('0x4b')](this[_0xb222('0x1a')][_0x53bb5d['uniqueid']])));if(_[_0xb222('0x5a')](applications,_0x53bb5d['application'])){this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]][_0xb222('0x5b')]=_0x53bb5d['application'];this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]][_0xb222('0x5c')]=_0x53bb5d[_0xb222('0x55')];if(_0x53bb5d[_0xb222('0x53')]==='set'&&_[_0xb222('0x5d')](_0x53bb5d[_0xb222('0x55')],'cdr(')){var _0x8c36ae=_0x53bb5d[_0xb222('0x55')][_0xb222('0x4d')]('=');var _0x2351f3=_0x8c36ae[0x0]['match'](/cdr\((.*)\)/);if(_0x2351f3){this[_0xb222('0x1a')][_0x53bb5d[_0xb222('0x37')]][_0x2351f3[0x1]]=_0x8c36ae[0x1];}}else if(_0x53bb5d[_0xb222('0x53')]===_0xb222('0x10')){this['channels'][_0x53bb5d[_0xb222('0x37')]][_0xb222('0x10')]=_0x53bb5d[_0xb222('0x55')][_0xb222('0x4d')](',')[0x0];}}}}}catch(_0x295ce9){logger['error'](_0xb222('0x5e'),_0x53bb5d[_0xb222('0x37')],util[_0xb222('0x31')](_0x295ce9,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')]['syncNewState']=function(_0x34d2ee){try{if(this[_0xb222('0x32')](_0x34d2ee)){logger[_0xb222('0x42')](_0xb222('0x5f'),_0x34d2ee['uniqueid'],_0x34d2ee[_0xb222('0x52')],_0x34d2ee[_0xb222('0x60')],_0x34d2ee['calleridnum']);logger['debug'](_0xb222('0x61'),_0x34d2ee['uniqueid'],util['inspect'](_0x34d2ee,{'showHidden':![],'depth':null}));if(_0x34d2ee[_0xb222('0x37')]!==_0x34d2ee['linkedid']){if(this['channels'][_0x34d2ee[_0xb222('0x52')]]){if(_0x34d2ee[_0xb222('0x4a')]==='6'){if(!this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]]['answered']){var _0x1fb820=moment();this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x62')]=!![];this[_0xb222('0x1a')][_0x34d2ee['linkedid']][_0xb222('0x63')]=_0x1fb820[_0xb222('0x47')](_0xb222('0x48'));if(this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x46')]){this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x64')]=_0x1fb820[_0xb222('0x65')](this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x46')],_0xb222('0x58'));}}this[_0xb222('0x1a')][_0x34d2ee['linkedid']][_0xb222('0x52')]=_0x34d2ee[_0xb222('0x37')];if(_0x34d2ee['calleridnum']!==_0xb222('0x66')){this[_0xb222('0x1a')][_0x34d2ee['linkedid']][_0xb222('0x67')]=_0x34d2ee['calleridnum'];}this['channels'][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x68')]=_0x34d2ee[_0xb222('0x60')];this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x69')]=_0x34d2ee['channel'];this['channels'][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x59')]=dispositions[_['toNumber'](_0x34d2ee['channelstate'])];if(this[_0xb222('0x1b')][_0x34d2ee[_0xb222('0x40')]['split']('-')[0x0]]){this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]][_0xb222('0x6a')]=this[_0xb222('0x1b')][_0x34d2ee[_0xb222('0x40')]['split']('-')[0x0]]['id'];this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x52')]]['membername']=this['agents'][_0x34d2ee['channel']['split']('-')[0x0]][_0xb222('0x50')];}}}}else{if(this[_0xb222('0x1a')][_0x34d2ee['uniqueid']]){if(_0x34d2ee[_0xb222('0x4a')]==='6'){if(this[_0xb222('0x1b')][_0x34d2ee[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]]){this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x37')]][_0xb222('0x6a')]=this[_0xb222('0x1b')][_0x34d2ee[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]]['id'];this[_0xb222('0x1a')][_0x34d2ee[_0xb222('0x37')]]['membername']=this[_0xb222('0x1b')][_0x34d2ee[_0xb222('0x40')]['split']('-')[0x0]]['name'];}}}}}}catch(_0x21eeb3){logger[_0xb222('0x2f')](_0xb222('0x6b'),_0x34d2ee[_0xb222('0x37')],util[_0xb222('0x31')](_0x21eeb3,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x6c')]=function(_0x94b9ab,_0x354eb0){try{if(this['channels'][_0x94b9ab]){logger[_0xb222('0x42')](_0xb222('0x6d'),_0x94b9ab,_0x354eb0);this['channels'][_0x94b9ab]['monitor']=!![];if(_[_0xb222('0x6e')](_0x354eb0,_0xb222('0x6f'))){_0x354eb0=_0x354eb0[_0xb222('0x70')]('.wav49',_0xb222('0x71'));}this['channels'][_0x94b9ab][_0xb222('0x72')]=_0x354eb0;var _0x23e8bf=_[_0xb222('0x73')](this[_0xb222('0x1a')][_0x94b9ab][_0xb222('0x74')],{'filename':_0x354eb0});if(_[_0xb222('0x75')](_0x23e8bf)){this['channels'][_0x94b9ab][_0xb222('0x74')]['push']({'filename':_0x354eb0,'createdAt':moment()[_0xb222('0x47')](_0xb222('0x48')),'mixmonitorid':'','status':_0xb222('0x76')});}}}catch(_0x4989c){logger[_0xb222('0x2f')](_0xb222('0x77'),_0x94b9ab,util[_0xb222('0x31')](_0x4989c,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x78')]=function(_0x30d5fb){try{if(this[_0xb222('0x32')](_0x30d5fb)){logger['debug'](_0xb222('0x79'),_0x30d5fb[_0xb222('0x37')],util[_0xb222('0x31')](_0x30d5fb,{'showHidden':![],'depth':null}));if(this['channels'][_0x30d5fb['uniqueid']]&&_0x30d5fb[_0xb222('0x40')]!=_0xb222('0x41')){if(this['isNotNull'](_0x30d5fb[_0xb222('0x7a')])){if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')]['mixmonitor_filename'])){logger[_0xb222('0x42')](_0xb222('0x7b'),_0x30d5fb['uniqueid'],_0x30d5fb[_0xb222('0x7c')]);this['syncMixMonitorFilename'](_0x30d5fb['uniqueid'],_0x30d5fb[_0xb222('0x7c')]);}else if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x7d')])){logger[_0xb222('0x42')]('[%s][voiceCallReport][varset]\x20variable:xmd-phone\x20value:%s',_0x30d5fb[_0xb222('0x37')],_0x30d5fb[_0xb222('0x7c')]);this[_0xb222('0x1a')][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x38')]=_0x30d5fb[_0xb222('0x7c')];}else if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x7e')])){logger[_0xb222('0x42')]('[%s][voiceCallReport][varset]\x20variable:xmd-callerid\x20value:%s',_0x30d5fb[_0xb222('0x37')],_0x30d5fb['value']);this[_0xb222('0x1a')][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x7f')]=_0x30d5fb[_0xb222('0x7c')];}else if(this['isNotNull'](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x80')])){logger[_0xb222('0x42')](_0xb222('0x81'),_0x30d5fb[_0xb222('0x37')],_0x30d5fb[_0xb222('0x7c')]);this['channels'][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x82')]=_0x30d5fb[_0xb222('0x7c')];}else if(this[_0xb222('0x32')](_0x30d5fb['variable']['xmd-queue'])){logger[_0xb222('0x42')](_0xb222('0x83'),_0x30d5fb[_0xb222('0x37')],_0x30d5fb[_0xb222('0x7c')][_0xb222('0x4d')](',')[0x0]);this['channels'][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x10')]=_0x30d5fb['value'][_0xb222('0x4d')](',')[0x0];}else if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x84')])){logger['info'](_0xb222('0x85'),_0x30d5fb[_0xb222('0x37')],_0x30d5fb['value']);this['channels'][_0x30d5fb['uniqueid']]['originatecalleridnum']=_0x30d5fb['value'];}else if(this['isNotNull'](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x86')])){logger[_0xb222('0x42')](_0xb222('0x87'),_0x30d5fb['uniqueid'],_0x30d5fb['value']);this[_0xb222('0x1a')][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x88')]=_0x30d5fb[_0xb222('0x7c')];}else if(this[_0xb222('0x32')](_0x30d5fb['variable']['xmd-callerid-preview'])){logger[_0xb222('0x42')](_0xb222('0x89'),_0x30d5fb[_0xb222('0x37')],_0x30d5fb[_0xb222('0x7c')]);this[_0xb222('0x1a')][_0x30d5fb[_0xb222('0x37')]]['calleridpreview']=_0x30d5fb[_0xb222('0x7c')];}else if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x8a')])){logger[_0xb222('0x42')](_0xb222('0x8b'),_0x30d5fb[_0xb222('0x37')],_0x30d5fb[_0xb222('0x7c')]);this[_0xb222('0x1a')][_0x30d5fb[_0xb222('0x37')]][_0xb222('0x10')]=_0x30d5fb['value'];}else if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')][_0xb222('0x8c')])){logger[_0xb222('0x42')](_0xb222('0x8d'),_0x30d5fb['uniqueid'],_0x30d5fb[_0xb222('0x7c')]);this[_0xb222('0x1a')][_0x30d5fb['uniqueid']][_0xb222('0x8e')]=_0x30d5fb[_0xb222('0x7c')];}}}else if(this[_0xb222('0x32')](_0x30d5fb['variable']['mixmonitor_filename'])){if(_0x30d5fb[_0xb222('0x7c')]){var _0x2a8008=path[_0xb222('0x8f')](_0x30d5fb[_0xb222('0x7c')])[_0xb222('0x50')];logger[_0xb222('0x42')](_0xb222('0x7b'),_0x2a8008,_0x30d5fb['value']);this[_0xb222('0x6c')](_0x2a8008,_0x30d5fb[_0xb222('0x7c')]);}}else if(this['channels'][_0x30d5fb['linkedid']]){if(this[_0xb222('0x32')](_0x30d5fb[_0xb222('0x7a')])){if(this['isNotNull'](_0x30d5fb[_0xb222('0x7a')]['sipcallid'])){logger[_0xb222('0x42')](_0xb222('0x8d'),_0x30d5fb[_0xb222('0x52')],_0x30d5fb[_0xb222('0x7c')]);this[_0xb222('0x1a')][_0x30d5fb['linkedid']][_0xb222('0x90')]=_0x30d5fb[_0xb222('0x7c')];}}}}}catch(_0x518ba2){logger[_0xb222('0x2f')](_0xb222('0x91'),_0x30d5fb[_0xb222('0x37')],util[_0xb222('0x31')](_0x518ba2,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x26')]=function(_0x384312){try{if(this['isNotNull'](_0x384312)){logger[_0xb222('0x39')](_0xb222('0x92'),_0x384312[_0xb222('0x37')],util[_0xb222('0x31')](_0x384312,{'showHidden':![],'depth':null}));if(this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]]){logger[_0xb222('0x42')](_0xb222('0x93'),_0x384312[_0xb222('0x37')],_0x384312['cause-txt']);var _0x56d5b2=moment();this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x94')]=_0x56d5b2[_0xb222('0x47')]('YYYY-MM-DD\x20HH:mm:ss');this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x56')]=_0x56d5b2[_0xb222('0x65')](this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x46')],_0xb222('0x58'));if(this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]]['answered']){this['channels'][_0x384312[_0xb222('0x37')]][_0xb222('0x95')]=_0x56d5b2[_0xb222('0x65')](this[_0xb222('0x1a')][_0x384312['uniqueid']][_0xb222('0x63')],_0xb222('0x58'));this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]]['holdtime']=this[_0xb222('0x1a')][_0x384312['uniqueid']][_0xb222('0x56')]-this[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x95')];}if(_0x384312[_0xb222('0x44')]==='from-sip'){if(this[_0xb222('0x1b')][_0x384312[_0xb222('0x40')]['split']('-')[0x0]]){this[_0xb222('0x1b')][_0x384312[_0xb222('0x40')]['split']('-')[0x0]]=_[_0xb222('0x96')](this['agents'][_0x384312[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]],[_0xb222('0x97')]);logger[_0xb222('0x39')](_0xb222('0x98'),_0x384312[_0xb222('0x37')],util[_0xb222('0x31')]({'destaccountcode':this[_0xb222('0x1b')][_0x384312[_0xb222('0x40')]['split']('-')[0x0]]['accountcode']},{'showHidden':![],'depth':null}));this[_0xb222('0x35')](util[_0xb222('0x47')]('user:%s',this[_0xb222('0x1b')][_0x384312['channel']['split']('-')[0x0]][_0xb222('0x50')]),_0xb222('0x99'),{'destaccountcode':this['agents'][_0x384312[_0xb222('0x40')][_0xb222('0x4d')]('-')[0x0]][_0xb222('0x51')]});}}var _0x344592=this;Promise[_0xb222('0x9a')]()[_0xb222('0x9b')](function(){var _0x1a7d4a=_0x344592[_0xb222('0x1a')][_0x384312['uniqueid']];if(typeof _0x1a7d4a[_0xb222('0x9c')]===_0xb222('0x9d'))return;if(_['isEmpty'](_0x1a7d4a[_0xb222('0x74')]))return;return RpcSetting[_0xb222('0x9e')]()[_0xb222('0x9b')](function(_0x9c01a3){if(!_0x9c01a3[_0xb222('0x9f')])return;return Promise['resolve']()[_0xb222('0x9b')](function(){return ami['Action']({'action':_0xb222('0xa0'),'channel':_0x1a7d4a[_0xb222('0x40')]})[_0xb222('0xa1')](function(){});})[_0xb222('0x9b')](function(){return ami[_0xb222('0xa2')]({'action':'StopMixMonitor','channel':_0x1a7d4a['destinationchannel']})[_0xb222('0xa1')](function(){})[_0xb222('0xa3')](function(){var _0x2693f5=_0x344592[_0xb222('0x1b')][_0x1a7d4a[_0xb222('0x69')]['split']('-')[0x0]];if(!_0x2693f5)return;io[_0xb222('0x35')](_0xb222('0xa4'),{'agentId':_0x2693f5['id'],'uniqueid':_0x1a7d4a['uniqueid']});});});});})['then'](function(){if(_0x384312[_0xb222('0xa5')]===_0xb222('0xa6')){_0x344592[_0xb222('0x1c')][_0x384312[_0xb222('0x37')]]=_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]];}else{if(_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x82')]===_0xb222('0xa7')&&_0x344592[_0xb222('0x1c')][_0x384312[_0xb222('0x37')]]){_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x37')]=[_0x344592['channels'][_0x384312[_0xb222('0x37')]][_0xb222('0x52')],_0x344592[_0xb222('0x1a')][_0x384312['uniqueid']][_0xb222('0x52')]=_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]][_0xb222('0x37')]][0x0];delete _0x344592[_0xb222('0x1c')][_0x384312[_0xb222('0x37')]];}}logger['debug'](_0xb222('0xa8'),_0x384312['uniqueid'],util[_0xb222('0x31')](_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]],{'showHidden':![],'depth':null}));ami['emit'](_0xb222('0xa9'),_0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]]);delete _0x344592[_0xb222('0x1a')][_0x384312[_0xb222('0x37')]];});}}}catch(_0x935430){logger[_0xb222('0x2f')]('[%s][voiceCallReport][hangup]',_0x384312[_0xb222('0x37')],util[_0xb222('0x31')](_0x935430,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0xaa')]=function(_0x590bd5){try{if(this[_0xb222('0x32')](_0x590bd5)){logger[_0xb222('0x42')]('[%s][voiceCallReport][attendedtransfer]\x20transfercalleridnum:%s\x20transferconnectedlinenum:%s',_0x590bd5['uniqueid'],_0x590bd5[_0xb222('0xab')],_0x590bd5['transfertargetcalleridnum']);logger[_0xb222('0x39')](_0xb222('0xac'),_0x590bd5[_0xb222('0x37')],util[_0xb222('0x31')](_0x590bd5,{'showHidden':![],'depth':null}));if(this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xad')]]){this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xad')]][_0xb222('0xae')]=_0x590bd5['origtransferercalleridnum'];this[_0xb222('0x1a')][_0x590bd5['transfereeuniqueid']][_0xb222('0xaf')]=_0x590bd5[_0xb222('0xb0')];if(this[_0xb222('0x1a')][_0x590bd5['secondtransfereruniqueid']]){var _0x2057b7=this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb1')]];this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb1')]]=this[_0xb222('0x1a')][_0x590bd5['transfereeuniqueid']];this[_0xb222('0x1a')][_0x590bd5['transfereeuniqueid']]=_0x2057b7;}}else if(this['channels'][_0x590bd5[_0xb222('0xb2')]]){this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb2')]][_0xb222('0xae')]=_0x590bd5[_0xb222('0xab')];this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb2')]]['transferconnectedlinenum']=_0x590bd5[_0xb222('0xb0')];if(this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb3')]]){var _0x2057b7=this[_0xb222('0x1a')][_0x590bd5['origtransfereruniqueid']];this['channels'][_0x590bd5[_0xb222('0xb3')]]=this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb2')]];this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb2')]]=_0x2057b7;}}if((this[_0xb222('0x1a')][_0x590bd5['origtransfereruniqueid']]||this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb4')]])&&this[_0xb222('0x1a')][_0x590bd5['secondtransfereruniqueid']]){var _0x11f399=_['some']([this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb3')]],this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb4')]],this['channels'][_0x590bd5[_0xb222('0xb1')]]],function(_0x3a2b13){return _0x3a2b13&&_0x3a2b13[_0xb222('0x82')]===_0xb222('0xa7')&&_0x3a2b13[_0xb222('0xb5')];});if(_0x11f399){if(this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb3')]])this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb3')]]['transferType']=_0xb222('0xb6');if(this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb4')]])this[_0xb222('0x1a')][_0x590bd5['origtransfererlinkedid']][_0xb222('0x9c')]=_0xb222('0xb6');this[_0xb222('0x1a')][_0x590bd5[_0xb222('0xb1')]]['transferType']='ATTENDED';}}}}catch(_0x4bf0f1){logger[_0xb222('0x2f')](_0xb222('0xb7'),_0x590bd5[_0xb222('0x37')],util[_0xb222('0x31')](_0x4bf0f1,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x2a')]=function(_0x4f631a){try{if(this['isNotNull'](_0x4f631a)){logger[_0xb222('0x42')]('[%s][voiceCallReport][blindtransfer]\x20transfercalleridnum:%s\x20transferconnectedlinenum:%s',_0x4f631a[_0xb222('0x37')],_0x4f631a['transfereecalleridnum'],_0x4f631a[_0xb222('0xb8')]);logger[_0xb222('0x39')](_0xb222('0xb9'),_0x4f631a['uniqueid'],util['inspect'](_0x4f631a,{'showHidden':![],'depth':null}));if(this[_0xb222('0x1a')][_0x4f631a['transfereeuniqueid']]){this[_0xb222('0x1a')][_0x4f631a[_0xb222('0xad')]][_0xb222('0xae')]=_0x4f631a['transfereecalleridnum'];this[_0xb222('0x1a')][_0x4f631a[_0xb222('0xad')]][_0xb222('0xaf')]=_0x4f631a[_0xb222('0xb8')];this[_0xb222('0x1a')][_0x4f631a['transfereeuniqueid']][_0xb222('0x9c')]='BLIND';this['syncHangup']({'event':'BlindTransfer','uniqueid':_0x4f631a[_0xb222('0xad')],'context':_0x4f631a[_0xb222('0x44')],'channel':_0x4f631a[_0xb222('0xba')]});}else{this[_0xb222('0x1a')][_0x4f631a['transfereruniqueid']][_0xb222('0x9c')]='BLIND';}}}catch(_0x25874c){logger[_0xb222('0x2f')](_0xb222('0xbb'),_0x4f631a[_0xb222('0x37')],util[_0xb222('0x31')](_0x25874c,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x2c')]=function(_0x470356){try{if(this['isNotNull'](_0x470356)){logger[_0xb222('0x39')]('[%s][voiceCallReport][musiconholdstart]\x20event:',_0x470356[_0xb222('0x37')],util[_0xb222('0x31')](_0x470356,{'showHidden':![],'depth':null}));if(this['channels'][_0x470356[_0xb222('0x37')]]){if(!_[_0xb222('0x75')](this[_0xb222('0x1a')][_0x470356[_0xb222('0x37')]][_0xb222('0x63')])){this[_0xb222('0x1a')][_0x470356[_0xb222('0x37')]][_0xb222('0xbc')]=moment()[_0xb222('0x47')](_0xb222('0x48'));logger[_0xb222('0x42')]('[%s][voiceCallReport][musiconholdstart]\x20mohstarttime:%s',_0x470356[_0xb222('0x37')],this[_0xb222('0x1a')][_0x470356[_0xb222('0x37')]][_0xb222('0xbc')]);}}}}catch(_0x3bdb43){logger['error'](_0xb222('0xbd'),_0x470356[_0xb222('0x37')],util['inspect'](_0x3bdb43,{'showHidden':![],'depth':null}));}};VoiceCallReport[_0xb222('0x34')][_0xb222('0x2e')]=function(_0x5a9974){try{if(this['isNotNull'](_0x5a9974)){logger[_0xb222('0x39')](_0xb222('0xbe'),_0x5a9974[_0xb222('0x37')],util[_0xb222('0x31')](_0x5a9974,{'showHidden':![],'depth':null}));if(this[_0xb222('0x1a')][_0x5a9974['uniqueid']]){if(!_[_0xb222('0x75')](this[_0xb222('0x1a')][_0x5a9974[_0xb222('0x37')]][_0xb222('0xbc')])){this[_0xb222('0x1a')][_0x5a9974['uniqueid']][_0xb222('0xbf')]+=moment()[_0xb222('0xc0')](0x0)[_0xb222('0x65')](this['channels'][_0x5a9974['uniqueid']]['mohstarttime'],_0xb222('0x58'));logger[_0xb222('0x42')]('[%s][voiceCallReport][musiconholdstop]\x20mohtime:%s',_0x5a9974['uniqueid'],this[_0xb222('0x1a')][_0x5a9974['uniqueid']][_0xb222('0xbf')]);delete this['channels'][_0x5a9974[_0xb222('0x37')]][_0xb222('0xbc')];}}}}catch(_0x2a4d4d){logger['error'](_0xb222('0xc1'),_0x5a9974['uniqueid'],util[_0xb222('0x31')](_0x2a4d4d,{'showHidden':![],'depth':null}));}};module[_0xb222('0xc2')]=VoiceCallReport;