Built motion from commit 20b39a97.|2.6.29
[motion2.git] / server / services / ami / report / voiceDialReport.js
index b23e6bd..1e34009 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x09eb=['set','applicationdata','toLowerCase','startsWith','cdr(','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','match','[%s][voiceDialReport][newexten]','exports','lodash','moment','ioredis','../../../config/environment','../../../config/logger','ami','redis','defaults','localhost','socket.io-emitter','channels','outboundChannels','outbound','syncDialBegin','bind','dialend','varset','syncVarSet','hangup','syncHangup','isNotNull','isUndefined','emit','prototype','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','substring','lastIndexOf','channel','event','info','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','debug','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','applications','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','[%s][voiceDialReport][dialbegin]','syncDialEnd','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinename','answertime','lastevent','connect','[%s][voiceDialReport][dialend]\x20agent:%s\x20lastevent:connect','[%s][voiceDialReport][dialend]\x20sending\x20dialconnect\x20event:','custom:dialconnect','[%s][voiceDialReport][dialend]\x20sending\x20voice_outbound_channel:save\x20event:','voice_outbound_channel:save','error','[%s][voiceDialReport][dialend]','[%s][voiceDialReport][varset]\x20event:','variable','variables','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','outboundrouteid','keys','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','voice:outbound','[%s][voiceDialReport][varset]','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','memberdynamic','memberlastcall','memberrealtime','isNil','includes','[%s][voiceDialReport][hangup]\x20event:','cause-txt','duration','endtime','diff','starttime','complete','total','answered','holdtime','seconds','sumBillable','billableseconds','sumDuration','[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:','custom:voiceDialReport','[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:','voice_outbound:save','[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event','stringify','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:','deleteChannelAfterTimeout','linkedid','application'];(function(_0x2501fe,_0x203a72){var _0x2db038=function(_0x4365cf){while(--_0x4365cf){_0x2501fe['push'](_0x2501fe['shift']());}};_0x2db038(++_0x203a72);}(_0x09eb,0x1d9));var _0xb09e=function(_0x445101,_0x2414bf){_0x445101=_0x445101-0x0;var _0x3c3d04=_0x09eb[_0x445101];return _0x3c3d04;};'use strict';var _=require(_0xb09e('0x0'));var moment=require(_0xb09e('0x1'));var util=require('util');var Redis=require(_0xb09e('0x2'));var config=require(_0xb09e('0x3'));var logger=require(_0xb09e('0x4'))(_0xb09e('0x5'));var ami=require('../ami');config[_0xb09e('0x6')]=_[_0xb09e('0x7')](config[_0xb09e('0x6')],{'host':_0xb09e('0x8'),'port':0x18eb});var io=require(_0xb09e('0x9'))(new Redis(config[_0xb09e('0x6')]));function VoiceDialReport(_0x277a66){this[_0xb09e('0xa')]=_0x277a66[_0xb09e('0xb')];this['outbound']=_0x277a66[_0xb09e('0xc')];this['applications']={};this['variables']={};ami['on']('dialbegin',this[_0xb09e('0xd')][_0xb09e('0xe')](this));ami['on'](_0xb09e('0xf'),this['syncDialEnd'][_0xb09e('0xe')](this));ami['on'](_0xb09e('0x10'),this[_0xb09e('0x11')]['bind'](this));ami['on'](_0xb09e('0x12'),this[_0xb09e('0x13')][_0xb09e('0xe')](this));}VoiceDialReport['prototype'][_0xb09e('0x14')]=function(_0xec91f7){return _0xec91f7!==null&&!_[_0xb09e('0x15')](_0xec91f7);};VoiceDialReport['prototype'][_0xb09e('0x16')]=function(_0x12cf6f,_0x80c6c8,_0x571ec9){io['to'](_0x12cf6f)[_0xb09e('0x16')](_0x80c6c8,_0x571ec9);};VoiceDialReport[_0xb09e('0x17')][_0xb09e('0xd')]=function(_0x42ce13){try{if(this[_0xb09e('0x14')](_0x42ce13)){logger['debug'](_0xb09e('0x18'),_0x42ce13[_0xb09e('0x19')],util[_0xb09e('0x1a')](_0x42ce13,{'showHidden':![],'depth':null}));if(this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]]){_[_0xb09e('0x1b')](this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]],{'starttime':moment()[_0xb09e('0x1c')](_0xb09e('0x1d')),'lastevent':_0xb09e('0x1e'),'interface':_0x42ce13['channel'][_0xb09e('0x1f')](0x0,_0x42ce13['channel'][_0xb09e('0x20')]('-')),'membername':_0x42ce13[_0xb09e('0x21')][_0xb09e('0x1f')](_0x42ce13[_0xb09e('0x21')]['lastIndexOf']('/')+0x1,_0x42ce13[_0xb09e('0x21')]['lastIndexOf']('-'))},_['omit'](_0x42ce13,[_0xb09e('0x22'),'privilege']));logger[_0xb09e('0x23')](_0xb09e('0x24'),_0x42ce13[_0xb09e('0x19')],this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]][_0xb09e('0x25')],this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]]['interface']);logger[_0xb09e('0x26')](_0xb09e('0x27'),_0x42ce13['uniqueid'],util[_0xb09e('0x1a')](this['channels'][_0x42ce13[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));if(this[_0xb09e('0x28')][_0x42ce13[_0xb09e('0x19')]])_[_0xb09e('0x1b')](this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]],this[_0xb09e('0x28')][_0x42ce13[_0xb09e('0x19')]]);this[_0xb09e('0x16')]('voice:outbound','voice_outbound_channel:save',this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]]);logger['debug'](_0xb09e('0x29'),_0x42ce13[_0xb09e('0x19')],util['inspect'](this[_0xb09e('0xa')][_0x42ce13[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));ami['emit']('custom:dialbegin',this['channels'][_0x42ce13[_0xb09e('0x19')]]);}}}catch(_0x530e0f){logger['error'](_0xb09e('0x2a'),_0x42ce13[_0xb09e('0x19')],util['inspect'](_0x530e0f,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb09e('0x17')][_0xb09e('0x2b')]=function(_0x1b2c84){try{if(this[_0xb09e('0x14')](_0x1b2c84)){logger[_0xb09e('0x26')](_0xb09e('0x2c'),_0x1b2c84['uniqueid'],util['inspect'](_0x1b2c84,{'showHidden':![],'depth':null}));if(this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]]){this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]][_0xb09e('0x2d')]=_0x1b2c84[_0xb09e('0x2d')];if(_0x1b2c84['dialstatus']===_0xb09e('0x2e')){this['channels'][_0x1b2c84[_0xb09e('0x19')]]['connectedlinenum']=_0x1b2c84['connectedlinenum'];this['channels'][_0x1b2c84['uniqueid']][_0xb09e('0x2f')]=_0x1b2c84['connectedlinename'];this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]][_0xb09e('0x30')]=moment()[_0xb09e('0x1c')](_0xb09e('0x1d'));this['channels'][_0x1b2c84[_0xb09e('0x19')]][_0xb09e('0x31')]=_0xb09e('0x32');logger[_0xb09e('0x23')](_0xb09e('0x33'),_0x1b2c84[_0xb09e('0x19')],_0x1b2c84['channel'][_0xb09e('0x1f')](_0x1b2c84[_0xb09e('0x21')][_0xb09e('0x20')]('/')+0x1,_0x1b2c84[_0xb09e('0x21')][_0xb09e('0x20')]('-')));logger[_0xb09e('0x26')](_0xb09e('0x34'),_0x1b2c84[_0xb09e('0x19')],util[_0xb09e('0x1a')](this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));ami[_0xb09e('0x16')](_0xb09e('0x35'),this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]]);}logger[_0xb09e('0x26')](_0xb09e('0x36'),_0x1b2c84['uniqueid'],util[_0xb09e('0x1a')](this['channels'][_0x1b2c84[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));this[_0xb09e('0x16')]('voice:outbound',_0xb09e('0x37'),this[_0xb09e('0xa')][_0x1b2c84[_0xb09e('0x19')]]);}}}catch(_0x3bd9f2){logger[_0xb09e('0x38')](_0xb09e('0x39'),_0x1b2c84[_0xb09e('0x19')],util['inspect'](_0x3bd9f2,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb09e('0x17')][_0xb09e('0x11')]=function(_0x4c95f1){try{if(this['isNotNull'](_0x4c95f1)){logger[_0xb09e('0x26')](_0xb09e('0x3a'),_0x4c95f1[_0xb09e('0x19')],util['inspect'](_0x4c95f1,{'showHidden':![],'depth':null}));this['addVariable'](_0x4c95f1[_0xb09e('0x19')],_['keys'](_0x4c95f1[_0xb09e('0x3b')])[0x0],_0x4c95f1['value']);if(this[_0xb09e('0x14')](_0x4c95f1[_0xb09e('0x3b')])&&this[_0xb09e('0x14')](_0x4c95f1[_0xb09e('0x3b')]['outboundrouteid'])){if(_[_0xb09e('0x15')](this['channels'][_0x4c95f1['uniqueid']])){this['channels'][_0x4c95f1['uniqueid']]={'routeId':_0x4c95f1['value'],'variables':this[_0xb09e('0x3c')][_0x4c95f1[_0xb09e('0x19')]],'motionChannel':_0xb09e('0x3d')};logger[_0xb09e('0x23')](_0xb09e('0x3e'),_0x4c95f1[_0xb09e('0x19')],_0x4c95f1[_0xb09e('0x3b')][_0xb09e('0x3f')],_[_0xb09e('0x40')](_0x4c95f1[_0xb09e('0x3b')])[0x0],_0x4c95f1['value']);logger[_0xb09e('0x26')](_0xb09e('0x41'),_0x4c95f1[_0xb09e('0x19')],util[_0xb09e('0x1a')](this['channels'][_0x4c95f1['uniqueid']],{'showHidden':![],'depth':null}));this['emit'](_0xb09e('0x42'),_0xb09e('0x37'),this[_0xb09e('0xa')][_0x4c95f1[_0xb09e('0x19')]]);}}}}catch(_0x459513){logger[_0xb09e('0x38')](_0xb09e('0x43'),_0x4c95f1[_0xb09e('0x19')],util[_0xb09e('0x1a')](_0x459513,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb09e('0x17')]['addVariable']=function(_0x2e25b1,_0x5c2ed1,_0x373b0a){var _0x6f6979=['rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter',_0xb09e('0x44'),_0xb09e('0x45'),_0xb09e('0x46'),_0xb09e('0x47'),_0xb09e('0x48'),_0xb09e('0x49'),_0xb09e('0x4a'),_0xb09e('0x4b'),_0xb09e('0x4c'),'membercalls',_0xb09e('0x4d'),'memberinterface',_0xb09e('0x4e'),_0xb09e('0x25'),'memberpenalty',_0xb09e('0x4f')];if(!_[_0xb09e('0x50')](_0x5c2ed1)&&!_[_0xb09e('0x51')](_0x6f6979,_0x5c2ed1)){if(_[_0xb09e('0x15')](this[_0xb09e('0x3c')][_0x2e25b1])){this[_0xb09e('0x3c')][_0x2e25b1]={};}this[_0xb09e('0x3c')][_0x2e25b1][_0x5c2ed1]=_0x373b0a;}};VoiceDialReport[_0xb09e('0x17')][_0xb09e('0x13')]=function(_0x25e368){try{if(this[_0xb09e('0x14')](_0x25e368)){logger[_0xb09e('0x26')](_0xb09e('0x52'),_0x25e368['uniqueid'],util[_0xb09e('0x1a')](_0x25e368,{'showHidden':![],'depth':null}));if(this[_0xb09e('0xa')][_0x25e368['uniqueid']]){logger[_0xb09e('0x23')]('[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete',_0x25e368[_0xb09e('0x19')],_0x25e368[_0xb09e('0x53')]);this[_0xb09e('0xa')][_0x25e368['uniqueid']]['endtime']=moment()[_0xb09e('0x1c')](_0xb09e('0x1d'));this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x54')]=moment(this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x55')])[_0xb09e('0x56')](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x57')],'seconds');this['channels'][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x31')]=_0xb09e('0x58');this[_0xb09e('0xc')][_0xb09e('0x59')]+=0x1;if(this['channels'][_0x25e368[_0xb09e('0x19')]]['answertime']){this[_0xb09e('0xc')][_0xb09e('0x5a')]+=0x1;this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x5b')]=moment(this['channels'][_0x25e368[_0xb09e('0x19')]]['answertime'])['diff'](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]]['starttime'],_0xb09e('0x5c'));this['channels'][_0x25e368[_0xb09e('0x19')]]['billableseconds']=moment(this[_0xb09e('0xa')][_0x25e368['uniqueid']][_0xb09e('0x55')])[_0xb09e('0x56')](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]]['answertime'],'seconds');this['outbound']['sumHoldTime']+=this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]][_0xb09e('0x5b')]||0x0;this[_0xb09e('0xc')][_0xb09e('0x5d')]+=this[_0xb09e('0xa')][_0x25e368['uniqueid']][_0xb09e('0x5e')];}this['outbound'][_0xb09e('0x5f')]+=this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]]['duration'];logger['debug'](_0xb09e('0x60'),_0x25e368[_0xb09e('0x19')],util['inspect'](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));ami[_0xb09e('0x16')](_0xb09e('0x61'),this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]]);logger['debug'](_0xb09e('0x62'),_0x25e368[_0xb09e('0x19')],util[_0xb09e('0x1a')](this[_0xb09e('0xa')][_0x25e368['uniqueid']],{'showHidden':![],'depth':null}));ami[_0xb09e('0x16')]('custom:dialend',this['channels'][_0x25e368[_0xb09e('0x19')]]);logger[_0xb09e('0x26')](_0xb09e('0x63'),_0x25e368[_0xb09e('0x19')],util[_0xb09e('0x1a')](this['channels'][_0x25e368['uniqueid']],{'showHidden':![],'depth':null}));this[_0xb09e('0x16')](_0xb09e('0x42'),_0xb09e('0x64'),this[_0xb09e('0xc')]);logger[_0xb09e('0x23')](_0xb09e('0x65'),JSON[_0xb09e('0x66')](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]]));logger[_0xb09e('0x26')](_0xb09e('0x67'),_0x25e368[_0xb09e('0x19')],util[_0xb09e('0x1a')](this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x19')]],{'showHidden':![],'depth':null}));this[_0xb09e('0x16')](_0xb09e('0x42'),'voice_outbound_channel:remove',this[_0xb09e('0xa')][_0x25e368['uniqueid']]);this[_0xb09e('0x68')](_0x25e368['uniqueid']);}else if(this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x69')]]){this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x69')]][_0xb09e('0x19')]=this[_0xb09e('0xa')][_0x25e368[_0xb09e('0x69')]]['destuniqueid'];}if(this[_0xb09e('0x3c')][_0x25e368[_0xb09e('0x19')]]){delete this[_0xb09e('0x3c')][_0x25e368[_0xb09e('0x19')]];}}}catch(_0x1597c8){logger[_0xb09e('0x38')]('[%s][voiceDialReport][hangup]',_0x25e368[_0xb09e('0x19')],util[_0xb09e('0x1a')](_0x1597c8,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb09e('0x17')]['syncNewExten']=function(_0x47e63f){try{if(this['isNotNull'](_0x47e63f)){logger['debug']('[%s][voiceDialReport][newexten]\x20event:',_0x47e63f[_0xb09e('0x19')],util['inspect'](_0x47e63f,{'showHidden':![],'depth':null}));if(_0x47e63f[_0xb09e('0x6a')]['toLowerCase']()===_0xb09e('0x6b')){_0x47e63f[_0xb09e('0x6c')]=(_0x47e63f['appdata']||_0x47e63f[_0xb09e('0x6c')])[_0xb09e('0x6d')]();if(_[_0xb09e('0x6e')](_0x47e63f[_0xb09e('0x6c')],_0xb09e('0x6f'))){if(_['isUndefined'](this[_0xb09e('0x28')][_0x47e63f[_0xb09e('0x19')]]))this['applications'][_0x47e63f[_0xb09e('0x19')]]={};logger[_0xb09e('0x23')](_0xb09e('0x70'),_0x47e63f[_0xb09e('0x19')],_0x47e63f[_0xb09e('0x6a')],_0x47e63f['applicationdata']);var _0x93f0d6=_0x47e63f[_0xb09e('0x6c')]['split']('=');var _0x43dbe3=_0x93f0d6[0x0][_0xb09e('0x71')](/cdr\((.*)\)/);if(_0x43dbe3)this[_0xb09e('0x28')][_0x47e63f['uniqueid']][_0x43dbe3[0x1]]=_0x93f0d6[0x1];}}}}catch(_0x17e9f7){logger[_0xb09e('0x38')](_0xb09e('0x72'),_0x47e63f['uniqueid'],util[_0xb09e('0x1a')](_0x17e9f7,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb09e('0x17')][_0xb09e('0x68')]=function(_0x4467d5,_0x57a9b7=0x2710){if(this[_0xb09e('0xa')][_0x4467d5]){setTimeout(()=>{delete this['channels'][_0x4467d5];},_0x57a9b7);}};module[_0xb09e('0x73')]=VoiceDialReport;
\ No newline at end of file
+var _0xc066=['[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','connectedlinename','answertime','lastevent','connect','info','[%s][voiceDialReport][dialend]\x20agent:%s\x20lastevent:connect','[%s][voiceDialReport][dialend]\x20sending\x20dialconnect\x20event:','[%s][voiceDialReport][dialend]\x20sending\x20voice_outbound_channel:save\x20event:','[%s][voiceDialReport][dialend]','[%s][voiceDialReport][varset]\x20event:','keys','variable','value','variables','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','outboundrouteid','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','voice:outbound','[%s][voiceDialReport][varset]','addVariable','rtpaudioqos','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepvtcallid','membercalls','memberdynamic','memberlastcall','memberrealtime','isNil','includes','syncHangup','[%s][voiceDialReport][hangup]\x20event:','cause-txt','endtime','duration','diff','seconds','complete','total','answered','holdtime','starttime','sumHoldTime','billableseconds','sumDuration','[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:','custom:voiceDialReport','[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:','custom:dialend','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:','voice_outbound:save','[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event','stringify','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:','voice_outbound_channel:remove','deleteChannelAfterTimeout','linkedid','destuniqueid','[%s][voiceDialReport][hangup]','syncNewExten','[%s][voiceDialReport][newexten]\x20event:','application','set','applicationdata','toLowerCase','startsWith','cdr(','split','match','[%s][voiceDialReport][newexten]','exports','lodash','moment','ioredis','../../../config/environment','../../../config/logger','../ami','redis','defaults','localhost','channels','outboundChannels','outbound','applications','dialbegin','syncDialBegin','dialend','syncDialEnd','bind','varset','syncVarSet','hangup','isUndefined','prototype','emit','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','merge','format','YYYY-MM-DD\x20HH:mm:ss','channel','substring','lastIndexOf','event','privilege','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','inspect','voice_outbound_channel:save','custom:dialbegin','error','[%s][voiceDialReport][dialbegin]','isNotNull'];(function(_0x17202,_0x28c231){var _0x5507c1=function(_0x5064c9){while(--_0x5064c9){_0x17202['push'](_0x17202['shift']());}};_0x5507c1(++_0x28c231);}(_0xc066,0xd1));var _0x6c06=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0xc066[_0xfae23b];return _0x200640;};'use strict';var _=require(_0x6c06('0x0'));var moment=require(_0x6c06('0x1'));var util=require('util');var Redis=require(_0x6c06('0x2'));var config=require(_0x6c06('0x3'));var logger=require(_0x6c06('0x4'))('ami');var ami=require(_0x6c06('0x5'));config[_0x6c06('0x6')]=_[_0x6c06('0x7')](config[_0x6c06('0x6')],{'host':_0x6c06('0x8'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6c06('0x6')]));function VoiceDialReport(_0x33ff95){this[_0x6c06('0x9')]=_0x33ff95[_0x6c06('0xa')];this[_0x6c06('0xb')]=_0x33ff95[_0x6c06('0xb')];this[_0x6c06('0xc')]={};this['variables']={};ami['on'](_0x6c06('0xd'),this[_0x6c06('0xe')]['bind'](this));ami['on'](_0x6c06('0xf'),this[_0x6c06('0x10')][_0x6c06('0x11')](this));ami['on'](_0x6c06('0x12'),this[_0x6c06('0x13')][_0x6c06('0x11')](this));ami['on'](_0x6c06('0x14'),this['syncHangup']['bind'](this));}VoiceDialReport['prototype']['isNotNull']=function(_0x1a91ac){return _0x1a91ac!==null&&!_[_0x6c06('0x15')](_0x1a91ac);};VoiceDialReport[_0x6c06('0x16')][_0x6c06('0x17')]=function(_0x5798e5,_0xb0eb33,_0x4a7e78){io['to'](_0x5798e5)[_0x6c06('0x17')](_0xb0eb33,_0x4a7e78);};VoiceDialReport[_0x6c06('0x16')][_0x6c06('0xe')]=function(_0x4222b2){try{if(this['isNotNull'](_0x4222b2)){logger[_0x6c06('0x18')](_0x6c06('0x19'),_0x4222b2[_0x6c06('0x1a')],util['inspect'](_0x4222b2,{'showHidden':![],'depth':null}));if(this[_0x6c06('0x9')][_0x4222b2[_0x6c06('0x1a')]]){_[_0x6c06('0x1b')](this['channels'][_0x4222b2[_0x6c06('0x1a')]],{'starttime':moment()[_0x6c06('0x1c')](_0x6c06('0x1d')),'lastevent':'called','interface':_0x4222b2[_0x6c06('0x1e')][_0x6c06('0x1f')](0x0,_0x4222b2[_0x6c06('0x1e')][_0x6c06('0x20')]('-')),'membername':_0x4222b2[_0x6c06('0x1e')][_0x6c06('0x1f')](_0x4222b2[_0x6c06('0x1e')]['lastIndexOf']('/')+0x1,_0x4222b2[_0x6c06('0x1e')]['lastIndexOf']('-'))},_['omit'](_0x4222b2,[_0x6c06('0x21'),_0x6c06('0x22')]));logger['info'](_0x6c06('0x23'),_0x4222b2[_0x6c06('0x1a')],this[_0x6c06('0x9')][_0x4222b2[_0x6c06('0x1a')]][_0x6c06('0x24')],this['channels'][_0x4222b2[_0x6c06('0x1a')]][_0x6c06('0x25')]);logger[_0x6c06('0x18')](_0x6c06('0x26'),_0x4222b2[_0x6c06('0x1a')],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x4222b2[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));if(this[_0x6c06('0xc')][_0x4222b2[_0x6c06('0x1a')]])_[_0x6c06('0x1b')](this['channels'][_0x4222b2[_0x6c06('0x1a')]],this[_0x6c06('0xc')][_0x4222b2['uniqueid']]);this[_0x6c06('0x17')]('voice:outbound',_0x6c06('0x28'),this[_0x6c06('0x9')][_0x4222b2[_0x6c06('0x1a')]]);logger[_0x6c06('0x18')]('[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:',_0x4222b2[_0x6c06('0x1a')],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x4222b2[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));ami['emit'](_0x6c06('0x29'),this['channels'][_0x4222b2[_0x6c06('0x1a')]]);}}}catch(_0x103a6b){logger[_0x6c06('0x2a')](_0x6c06('0x2b'),_0x4222b2[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x103a6b,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x6c06('0x16')][_0x6c06('0x10')]=function(_0x496271){try{if(this[_0x6c06('0x2c')](_0x496271)){logger[_0x6c06('0x18')](_0x6c06('0x2d'),_0x496271[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x496271,{'showHidden':![],'depth':null}));if(this[_0x6c06('0x9')][_0x496271[_0x6c06('0x1a')]]){this['channels'][_0x496271['uniqueid']][_0x6c06('0x2e')]=_0x496271[_0x6c06('0x2e')];if(_0x496271[_0x6c06('0x2e')]===_0x6c06('0x2f')){this[_0x6c06('0x9')][_0x496271[_0x6c06('0x1a')]]['connectedlinenum']=_0x496271[_0x6c06('0x30')];this[_0x6c06('0x9')][_0x496271[_0x6c06('0x1a')]]['connectedlinename']=_0x496271[_0x6c06('0x31')];this['channels'][_0x496271['uniqueid']][_0x6c06('0x32')]=moment()[_0x6c06('0x1c')](_0x6c06('0x1d'));this[_0x6c06('0x9')][_0x496271[_0x6c06('0x1a')]][_0x6c06('0x33')]=_0x6c06('0x34');logger[_0x6c06('0x35')](_0x6c06('0x36'),_0x496271['uniqueid'],_0x496271[_0x6c06('0x1e')][_0x6c06('0x1f')](_0x496271[_0x6c06('0x1e')][_0x6c06('0x20')]('/')+0x1,_0x496271[_0x6c06('0x1e')][_0x6c06('0x20')]('-')));logger[_0x6c06('0x18')](_0x6c06('0x37'),_0x496271[_0x6c06('0x1a')],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x496271[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x6c06('0x17')]('custom:dialconnect',this[_0x6c06('0x9')][_0x496271['uniqueid']]);}logger[_0x6c06('0x18')](_0x6c06('0x38'),_0x496271[_0x6c06('0x1a')],util[_0x6c06('0x27')](this['channels'][_0x496271[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));this[_0x6c06('0x17')]('voice:outbound',_0x6c06('0x28'),this['channels'][_0x496271['uniqueid']]);}}}catch(_0x5bb6b6){logger[_0x6c06('0x2a')](_0x6c06('0x39'),_0x496271[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x5bb6b6,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x6c06('0x16')]['syncVarSet']=function(_0x5eecd4){try{if(this[_0x6c06('0x2c')](_0x5eecd4)){logger['debug'](_0x6c06('0x3a'),_0x5eecd4[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x5eecd4,{'showHidden':![],'depth':null}));this['addVariable'](_0x5eecd4[_0x6c06('0x1a')],_[_0x6c06('0x3b')](_0x5eecd4[_0x6c06('0x3c')])[0x0],_0x5eecd4['value']);if(this[_0x6c06('0x2c')](_0x5eecd4[_0x6c06('0x3c')])&&this[_0x6c06('0x2c')](_0x5eecd4[_0x6c06('0x3c')]['outboundrouteid'])){if(_[_0x6c06('0x15')](this[_0x6c06('0x9')][_0x5eecd4[_0x6c06('0x1a')]])){this['channels'][_0x5eecd4[_0x6c06('0x1a')]]={'routeId':_0x5eecd4[_0x6c06('0x3d')],'variables':this[_0x6c06('0x3e')][_0x5eecd4[_0x6c06('0x1a')]],'motionChannel':_0x6c06('0x3f')};logger['info'](_0x6c06('0x40'),_0x5eecd4[_0x6c06('0x1a')],_0x5eecd4[_0x6c06('0x3c')][_0x6c06('0x41')],_[_0x6c06('0x3b')](_0x5eecd4[_0x6c06('0x3c')])[0x0],_0x5eecd4[_0x6c06('0x3d')]);logger['debug'](_0x6c06('0x42'),_0x5eecd4[_0x6c06('0x1a')],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x5eecd4['uniqueid']],{'showHidden':![],'depth':null}));this[_0x6c06('0x17')](_0x6c06('0x43'),_0x6c06('0x28'),this['channels'][_0x5eecd4[_0x6c06('0x1a')]]);}}}}catch(_0x437ee2){logger[_0x6c06('0x2a')](_0x6c06('0x44'),_0x5eecd4[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x437ee2,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x6c06('0x45')]=function(_0x92dfb4,_0x493a69,_0x1004fa){var _0x5cddb3=[_0x6c06('0x46'),'rtpaudioqosbridged',_0x6c06('0x47'),_0x6c06('0x48'),_0x6c06('0x49'),_0x6c06('0x4a'),_0x6c06('0x4b'),_0x6c06('0x4c'),_0x6c06('0x4d'),_0x6c06('0x4e'),'bridgepeer',_0x6c06('0x4f'),_0x6c06('0x50'),_0x6c06('0x51'),'memberinterface',_0x6c06('0x52'),_0x6c06('0x24'),'memberpenalty',_0x6c06('0x53')];if(!_[_0x6c06('0x54')](_0x493a69)&&!_[_0x6c06('0x55')](_0x5cddb3,_0x493a69)){if(_[_0x6c06('0x15')](this[_0x6c06('0x3e')][_0x92dfb4])){this['variables'][_0x92dfb4]={};}this['variables'][_0x92dfb4][_0x493a69]=_0x1004fa;}};VoiceDialReport['prototype'][_0x6c06('0x56')]=function(_0x58c7ea){try{if(this['isNotNull'](_0x58c7ea)){logger[_0x6c06('0x18')](_0x6c06('0x57'),_0x58c7ea[_0x6c06('0x1a')],util['inspect'](_0x58c7ea,{'showHidden':![],'depth':null}));if(this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]]){logger[_0x6c06('0x35')]('[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete',_0x58c7ea[_0x6c06('0x1a')],_0x58c7ea[_0x6c06('0x58')]);this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x59')]=moment()[_0x6c06('0x1c')](_0x6c06('0x1d'));this[_0x6c06('0x9')][_0x58c7ea['uniqueid']][_0x6c06('0x5a')]=moment(this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x59')])[_0x6c06('0x5b')](this['channels'][_0x58c7ea[_0x6c06('0x1a')]]['starttime'],_0x6c06('0x5c'));this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]]['lastevent']=_0x6c06('0x5d');this[_0x6c06('0xb')][_0x6c06('0x5e')]+=0x1;if(this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]]['answertime']){this['outbound'][_0x6c06('0x5f')]+=0x1;this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x60')]=moment(this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x32')])[_0x6c06('0x5b')](this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x61')],_0x6c06('0x5c'));this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]]['billableseconds']=moment(this['channels'][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x59')])[_0x6c06('0x5b')](this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x32')],'seconds');this[_0x6c06('0xb')][_0x6c06('0x62')]+=this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x60')]||0x0;this[_0x6c06('0xb')]['sumBillable']+=this['channels'][_0x58c7ea['uniqueid']][_0x6c06('0x63')];}this[_0x6c06('0xb')][_0x6c06('0x64')]+=this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]][_0x6c06('0x5a')];logger[_0x6c06('0x18')](_0x6c06('0x65'),_0x58c7ea[_0x6c06('0x1a')],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x6c06('0x17')](_0x6c06('0x66'),this['channels'][_0x58c7ea[_0x6c06('0x1a')]]);logger[_0x6c06('0x18')](_0x6c06('0x67'),_0x58c7ea['uniqueid'],util[_0x6c06('0x27')](this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x6c06('0x17')](_0x6c06('0x68'),this[_0x6c06('0x9')][_0x58c7ea['uniqueid']]);logger[_0x6c06('0x18')](_0x6c06('0x69'),_0x58c7ea[_0x6c06('0x1a')],util['inspect'](this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]],{'showHidden':![],'depth':null}));this[_0x6c06('0x17')](_0x6c06('0x43'),_0x6c06('0x6a'),this['outbound']);logger[_0x6c06('0x35')](_0x6c06('0x6b'),JSON[_0x6c06('0x6c')](this['channels'][_0x58c7ea[_0x6c06('0x1a')]]));logger['debug'](_0x6c06('0x6d'),_0x58c7ea[_0x6c06('0x1a')],util[_0x6c06('0x27')](this['channels'][_0x58c7ea['uniqueid']],{'showHidden':![],'depth':null}));this[_0x6c06('0x17')](_0x6c06('0x43'),_0x6c06('0x6e'),this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x1a')]]);this[_0x6c06('0x6f')](_0x58c7ea[_0x6c06('0x1a')]);}else if(this['channels'][_0x58c7ea[_0x6c06('0x70')]]){this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x70')]][_0x6c06('0x1a')]=this[_0x6c06('0x9')][_0x58c7ea[_0x6c06('0x70')]][_0x6c06('0x71')];}if(this[_0x6c06('0x3e')][_0x58c7ea[_0x6c06('0x1a')]]){delete this[_0x6c06('0x3e')][_0x58c7ea[_0x6c06('0x1a')]];}}}catch(_0x4dcd87){logger['error'](_0x6c06('0x72'),_0x58c7ea['uniqueid'],util[_0x6c06('0x27')](_0x4dcd87,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x6c06('0x16')][_0x6c06('0x73')]=function(_0x10d59d){try{if(this[_0x6c06('0x2c')](_0x10d59d)){logger['debug'](_0x6c06('0x74'),_0x10d59d[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x10d59d,{'showHidden':![],'depth':null}));if(_0x10d59d[_0x6c06('0x75')]['toLowerCase']()===_0x6c06('0x76')){_0x10d59d[_0x6c06('0x77')]=(_0x10d59d['appdata']||_0x10d59d[_0x6c06('0x77')])[_0x6c06('0x78')]();if(_[_0x6c06('0x79')](_0x10d59d[_0x6c06('0x77')],_0x6c06('0x7a'))){if(_[_0x6c06('0x15')](this[_0x6c06('0xc')][_0x10d59d[_0x6c06('0x1a')]]))this[_0x6c06('0xc')][_0x10d59d[_0x6c06('0x1a')]]={};logger[_0x6c06('0x35')]('[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s',_0x10d59d[_0x6c06('0x1a')],_0x10d59d[_0x6c06('0x75')],_0x10d59d[_0x6c06('0x77')]);var _0x162511=_0x10d59d[_0x6c06('0x77')][_0x6c06('0x7b')]('=');var _0x4a57e6=_0x162511[0x0][_0x6c06('0x7c')](/cdr\((.*)\)/);if(_0x4a57e6)this[_0x6c06('0xc')][_0x10d59d[_0x6c06('0x1a')]][_0x4a57e6[0x1]]=_0x162511[0x1];}}}}catch(_0x5f222e){logger['error'](_0x6c06('0x7d'),_0x10d59d[_0x6c06('0x1a')],util[_0x6c06('0x27')](_0x5f222e,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x6c06('0x16')][_0x6c06('0x6f')]=function(_0x3845f2,_0x5580d2=0x2710){if(this['channels'][_0x3845f2]){setTimeout(()=>{delete this[_0x6c06('0x9')][_0x3845f2];},_0x5580d2);}};module[_0x6c06('0x7e')]=VoiceDialReport;
\ No newline at end of file