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