Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / ami / report / voiceDialReport.js
index d6424d0..812a14e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x71ab=['syncDialBegin','dialend','bind','varset','syncVarSet','hangup','isUndefined','prototype','emit','isNotNull','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','channel','substring','lastIndexOf','omit','privilege','info','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','voice:outbound','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','error','syncDialEnd','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','connectedlinename','answertime','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:','[%s][voiceDialReport][dialend]','addVariable','keys','variable','value','outboundrouteid','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','sipuri','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberlastcall','memberpenalty','memberrealtime','syncHangup','[%s][voiceDialReport][hangup]\x20event:','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt','endtime','diff','starttime','seconds','total','sumHoldTime','holdtime','billableseconds','sumDuration','[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:','[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:','custom:dialend','voice_outbound:save','[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event','stringify','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:','voice_outbound_channel:remove','linkedid','destuniqueid','syncNewExten','application','toLowerCase','applicationdata','startsWith','cdr(','split','match','[%s][voiceDialReport][newexten]','exports','moment','ioredis','../../../config/logger','ami','../ami','redis','defaults','localhost','socket.io-emitter','channels','outboundChannels','outbound','applications','variables','dialbegin'];(function(_0x27ab28,_0x4f5c86){var _0x1e5c11=function(_0x496840){while(--_0x496840){_0x27ab28['push'](_0x27ab28['shift']());}};_0x1e5c11(++_0x4f5c86);}(_0x71ab,0x64));var _0xb71a=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x71ab[_0x14add3];return _0x4a174f;};'use strict';var _=require('lodash');var moment=require(_0xb71a('0x0'));var util=require('util');var Redis=require(_0xb71a('0x1'));var config=require('../../../config/environment');var logger=require(_0xb71a('0x2'))(_0xb71a('0x3'));var ami=require(_0xb71a('0x4'));config[_0xb71a('0x5')]=_[_0xb71a('0x6')](config[_0xb71a('0x5')],{'host':_0xb71a('0x7'),'port':0x18eb});var io=require(_0xb71a('0x8'))(new Redis(config[_0xb71a('0x5')]));function VoiceDialReport(_0x35a84e){this[_0xb71a('0x9')]=_0x35a84e[_0xb71a('0xa')];this[_0xb71a('0xb')]=_0x35a84e[_0xb71a('0xb')];this[_0xb71a('0xc')]={};this[_0xb71a('0xd')]={};ami['on'](_0xb71a('0xe'),this[_0xb71a('0xf')]['bind'](this));ami['on'](_0xb71a('0x10'),this['syncDialEnd'][_0xb71a('0x11')](this));ami['on'](_0xb71a('0x12'),this[_0xb71a('0x13')]['bind'](this));ami['on'](_0xb71a('0x14'),this['syncHangup'][_0xb71a('0x11')](this));}VoiceDialReport['prototype']['isNotNull']=function(_0x3346a5){return _0x3346a5!==null&&!_[_0xb71a('0x15')](_0x3346a5);};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0x17')]=function(_0x483d77,_0x47ee48,_0x5364e3){io['to'](_0x483d77)[_0xb71a('0x17')](_0x47ee48,_0x5364e3);};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0xf')]=function(_0x42fc55){try{if(this[_0xb71a('0x18')](_0x42fc55)){logger[_0xb71a('0x19')](_0xb71a('0x1a'),_0x42fc55[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x42fc55,{'showHidden':![],'depth':null}));if(this['channels'][_0x42fc55[_0xb71a('0x1b')]]){_[_0xb71a('0x1d')](this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]],{'starttime':moment()[_0xb71a('0x1e')](_0xb71a('0x1f')),'lastevent':_0xb71a('0x20'),'interface':_0x42fc55[_0xb71a('0x21')][_0xb71a('0x22')](0x0,_0x42fc55[_0xb71a('0x21')][_0xb71a('0x23')]('-')),'membername':_0x42fc55['channel']['substring'](_0x42fc55[_0xb71a('0x21')][_0xb71a('0x23')]('/')+0x1,_0x42fc55['channel']['lastIndexOf']('-'))},_[_0xb71a('0x24')](_0x42fc55,['event',_0xb71a('0x25')]));logger[_0xb71a('0x26')](_0xb71a('0x27'),_0x42fc55[_0xb71a('0x1b')],this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]][_0xb71a('0x28')],this[_0xb71a('0x9')][_0x42fc55['uniqueid']][_0xb71a('0x29')]);logger[_0xb71a('0x19')](_0xb71a('0x2a'),_0x42fc55[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));if(this[_0xb71a('0xc')][_0x42fc55[_0xb71a('0x1b')]])_[_0xb71a('0x1d')](this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]],this[_0xb71a('0xc')][_0x42fc55['uniqueid']]);this[_0xb71a('0x17')](_0xb71a('0x2b'),_0xb71a('0x2c'),this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]]);logger[_0xb71a('0x19')](_0xb71a('0x2d'),_0x42fc55[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this[_0xb71a('0x9')][_0x42fc55[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));ami['emit']('custom:dialbegin',this[_0xb71a('0x9')][_0x42fc55['uniqueid']]);}}}catch(_0x70299a){logger[_0xb71a('0x2e')]('[%s][voiceDialReport][dialbegin]',_0x42fc55[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x70299a,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0x2f')]=function(_0x3d3d81){try{if(this[_0xb71a('0x18')](_0x3d3d81)){logger['debug'](_0xb71a('0x30'),_0x3d3d81[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x3d3d81,{'showHidden':![],'depth':null}));if(this[_0xb71a('0x9')][_0x3d3d81['uniqueid']]){this[_0xb71a('0x9')][_0x3d3d81[_0xb71a('0x1b')]][_0xb71a('0x31')]=_0x3d3d81[_0xb71a('0x31')];if(_0x3d3d81[_0xb71a('0x31')]===_0xb71a('0x32')){this[_0xb71a('0x9')][_0x3d3d81[_0xb71a('0x1b')]][_0xb71a('0x33')]=_0x3d3d81[_0xb71a('0x33')];this['channels'][_0x3d3d81['uniqueid']][_0xb71a('0x34')]=_0x3d3d81[_0xb71a('0x34')];this[_0xb71a('0x9')][_0x3d3d81[_0xb71a('0x1b')]][_0xb71a('0x35')]=moment()[_0xb71a('0x1e')](_0xb71a('0x1f'));this['channels'][_0x3d3d81[_0xb71a('0x1b')]]['lastevent']=_0xb71a('0x36');logger[_0xb71a('0x26')](_0xb71a('0x37'),_0x3d3d81[_0xb71a('0x1b')],_0x3d3d81['channel'][_0xb71a('0x22')](_0x3d3d81[_0xb71a('0x21')][_0xb71a('0x23')]('/')+0x1,_0x3d3d81[_0xb71a('0x21')][_0xb71a('0x23')]('-')));logger[_0xb71a('0x19')](_0xb71a('0x38'),_0x3d3d81[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this['channels'][_0x3d3d81[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));ami['emit'](_0xb71a('0x39'),this[_0xb71a('0x9')][_0x3d3d81[_0xb71a('0x1b')]]);}logger[_0xb71a('0x19')](_0xb71a('0x3a'),_0x3d3d81[_0xb71a('0x1b')],util['inspect'](this['channels'][_0x3d3d81['uniqueid']],{'showHidden':![],'depth':null}));this[_0xb71a('0x17')]('voice:outbound',_0xb71a('0x2c'),this[_0xb71a('0x9')][_0x3d3d81[_0xb71a('0x1b')]]);}}}catch(_0x396d36){logger[_0xb71a('0x2e')](_0xb71a('0x3b'),_0x3d3d81['uniqueid'],util[_0xb71a('0x1c')](_0x396d36,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0x13')]=function(_0x8bf582){try{if(this[_0xb71a('0x18')](_0x8bf582)){logger[_0xb71a('0x19')]('[%s][voiceDialReport][varset]\x20event:',_0x8bf582[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x8bf582,{'showHidden':![],'depth':null}));this[_0xb71a('0x3c')](_0x8bf582[_0xb71a('0x1b')],_[_0xb71a('0x3d')](_0x8bf582[_0xb71a('0x3e')])[0x0],_0x8bf582[_0xb71a('0x3f')]);if(this['isNotNull'](_0x8bf582['variable'])&&this[_0xb71a('0x18')](_0x8bf582[_0xb71a('0x3e')][_0xb71a('0x40')])){if(_[_0xb71a('0x15')](this['channels'][_0x8bf582[_0xb71a('0x1b')]])){this['channels'][_0x8bf582[_0xb71a('0x1b')]]={'routeId':_0x8bf582[_0xb71a('0x3f')],'variables':this['variables'][_0x8bf582[_0xb71a('0x1b')]],'motionChannel':_0xb71a('0x41')};logger[_0xb71a('0x26')](_0xb71a('0x42'),_0x8bf582['uniqueid'],_0x8bf582[_0xb71a('0x3e')][_0xb71a('0x40')],_[_0xb71a('0x3d')](_0x8bf582['variable'])[0x0],_0x8bf582[_0xb71a('0x3f')]);logger[_0xb71a('0x19')](_0xb71a('0x43'),_0x8bf582['uniqueid'],util[_0xb71a('0x1c')](this[_0xb71a('0x9')][_0x8bf582[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));this[_0xb71a('0x17')](_0xb71a('0x2b'),'voice_outbound_channel:save',this[_0xb71a('0x9')][_0x8bf582[_0xb71a('0x1b')]]);}}}}catch(_0x45e961){logger[_0xb71a('0x2e')]('[%s][voiceDialReport][varset]',_0x8bf582['uniqueid'],util[_0xb71a('0x1c')](_0x45e961,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0x3c')]=function(_0x170978,_0x174f30,_0x2f2187){var _0x2a7804=[_0xb71a('0x44'),_0xb71a('0x45'),_0xb71a('0x46'),'rtpaudioqosjitterbridged',_0xb71a('0x47'),_0xb71a('0x48'),'rtpaudioqosrtt',_0xb71a('0x49'),'sipcallid',_0xb71a('0x4a'),_0xb71a('0x4b'),_0xb71a('0x4c'),_0xb71a('0x4d'),_0xb71a('0x4e'),'memberinterface',_0xb71a('0x4f'),'membername',_0xb71a('0x50'),_0xb71a('0x51')];if(!_['isNil'](_0x174f30)&&!_['includes'](_0x2a7804,_0x174f30)){if(_[_0xb71a('0x15')](this[_0xb71a('0xd')][_0x170978])){this['variables'][_0x170978]={};}this['variables'][_0x170978][_0x174f30]=_0x2f2187;}};VoiceDialReport['prototype'][_0xb71a('0x52')]=function(_0x57ef8f){try{if(this['isNotNull'](_0x57ef8f)){logger[_0xb71a('0x19')](_0xb71a('0x53'),_0x57ef8f[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x57ef8f,{'showHidden':![],'depth':null}));if(this['channels'][_0x57ef8f[_0xb71a('0x1b')]]){logger[_0xb71a('0x26')](_0xb71a('0x54'),_0x57ef8f['uniqueid'],_0x57ef8f[_0xb71a('0x55')]);this[_0xb71a('0x9')][_0x57ef8f['uniqueid']][_0xb71a('0x56')]=moment()[_0xb71a('0x1e')](_0xb71a('0x1f'));this['channels'][_0x57ef8f[_0xb71a('0x1b')]]['duration']=moment(this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]['endtime'])[_0xb71a('0x57')](this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x58')],_0xb71a('0x59'));this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]['lastevent']='complete';this[_0xb71a('0xb')][_0xb71a('0x5a')]+=0x1;if(this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x35')]){this['outbound']['answered']+=0x1;this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]['holdtime']=moment(this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]['answertime'])[_0xb71a('0x57')](this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x58')],'seconds');this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]['billableseconds']=moment(this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x56')])[_0xb71a('0x57')](this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x35')],_0xb71a('0x59'));this['outbound'][_0xb71a('0x5b')]+=this[_0xb71a('0x9')][_0x57ef8f['uniqueid']][_0xb71a('0x5c')]||0x0;this[_0xb71a('0xb')]['sumBillable']+=this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]][_0xb71a('0x5d')];}this[_0xb71a('0xb')][_0xb71a('0x5e')]+=this[_0xb71a('0x9')][_0x57ef8f['uniqueid']]['duration'];logger[_0xb71a('0x19')](_0xb71a('0x5f'),_0x57ef8f[_0xb71a('0x1b')],util['inspect'](this[_0xb71a('0x9')][_0x57ef8f['uniqueid']],{'showHidden':![],'depth':null}));ami[_0xb71a('0x17')]('custom:voiceDialReport',this['channels'][_0x57ef8f[_0xb71a('0x1b')]]);logger[_0xb71a('0x19')](_0xb71a('0x60'),_0x57ef8f[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this['channels'][_0x57ef8f[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));ami['emit'](_0xb71a('0x61'),this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]]);logger['debug']('[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:',_0x57ef8f[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));this[_0xb71a('0x17')]('voice:outbound',_0xb71a('0x62'),this[_0xb71a('0xb')]);logger[_0xb71a('0x26')](_0xb71a('0x63'),JSON[_0xb71a('0x64')](this['channels'][_0x57ef8f['uniqueid']]));logger[_0xb71a('0x19')](_0xb71a('0x65'),_0x57ef8f[_0xb71a('0x1b')],util[_0xb71a('0x1c')](this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]],{'showHidden':![],'depth':null}));this[_0xb71a('0x17')]('voice:outbound',_0xb71a('0x66'),this[_0xb71a('0x9')][_0x57ef8f['uniqueid']]);delete this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x1b')]];}else if(this[_0xb71a('0x9')][_0x57ef8f['linkedid']]){this[_0xb71a('0x9')][_0x57ef8f[_0xb71a('0x67')]][_0xb71a('0x1b')]=this['channels'][_0x57ef8f[_0xb71a('0x67')]][_0xb71a('0x68')];}if(this[_0xb71a('0xd')][_0x57ef8f[_0xb71a('0x1b')]]){delete this[_0xb71a('0xd')][_0x57ef8f[_0xb71a('0x1b')]];}}}catch(_0x2cdaf9){logger[_0xb71a('0x2e')]('[%s][voiceDialReport][hangup]',_0x57ef8f[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x2cdaf9,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xb71a('0x16')][_0xb71a('0x69')]=function(_0x43e4b8){try{if(this[_0xb71a('0x18')](_0x43e4b8)){logger[_0xb71a('0x19')]('[%s][voiceDialReport][newexten]\x20event:',_0x43e4b8[_0xb71a('0x1b')],util['inspect'](_0x43e4b8,{'showHidden':![],'depth':null}));if(_0x43e4b8[_0xb71a('0x6a')][_0xb71a('0x6b')]()==='set'){_0x43e4b8[_0xb71a('0x6c')]=(_0x43e4b8['appdata']||_0x43e4b8[_0xb71a('0x6c')])['toLowerCase']();if(_[_0xb71a('0x6d')](_0x43e4b8[_0xb71a('0x6c')],_0xb71a('0x6e'))){if(_[_0xb71a('0x15')](this['applications'][_0x43e4b8[_0xb71a('0x1b')]]))this[_0xb71a('0xc')][_0x43e4b8['uniqueid']]={};logger[_0xb71a('0x26')]('[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s',_0x43e4b8['uniqueid'],_0x43e4b8['application'],_0x43e4b8['applicationdata']);var _0x37a38f=_0x43e4b8[_0xb71a('0x6c')][_0xb71a('0x6f')]('=');var _0x5554e8=_0x37a38f[0x0][_0xb71a('0x70')](/cdr\((.*)\)/);if(_0x5554e8)this[_0xb71a('0xc')][_0x43e4b8['uniqueid']][_0x5554e8[0x1]]=_0x37a38f[0x1];}}}}catch(_0x299349){logger[_0xb71a('0x2e')](_0xb71a('0x71'),_0x43e4b8[_0xb71a('0x1b')],util[_0xb71a('0x1c')](_0x299349,{'showHidden':![],'depth':null}));}};module[_0xb71a('0x72')]=VoiceDialReport;
\ No newline at end of file
+var _0x6f47=['debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','channel','substring','lastIndexOf','omit','event','membername','interface','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','error','[%s][voiceDialReport][dialbegin]','[%s][voiceDialReport][dialend]\x20event:','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:','voice:outbound','[%s][voiceDialReport][dialend]','[%s][voiceDialReport][varset]\x20event:','addVariable','keys','variable','value','outboundrouteid','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','[%s][voiceDialReport][varset]','rtpaudioqosbridged','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','sipcallid','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberinterface','memberrealtime','isNil','includes','[%s][voiceDialReport][hangup]\x20event:','cause-txt','starttime','seconds','complete','answered','billableseconds','endtime','diff','sumHoldTime','holdtime','duration','custom:voiceDialReport','custom:dialend','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:','voice_outbound:save','stringify','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:','voice_outbound_channel:remove','linkedid','destuniqueid','[%s][voiceDialReport][newexten]\x20event:','application','set','applicationdata','appdata','toLowerCase','startsWith','cdr(','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','split','[%s][voiceDialReport][newexten]','exports','moment','util','../../../config/environment','ami','redis','defaults','localhost','channels','outbound','applications','variables','dialbegin','dialend','syncDialEnd','syncVarSet','bind','hangup','syncHangup','prototype','isNotNull','isUndefined','emit','syncDialBegin'];(function(_0x32ae47,_0xb4d351){var _0x105150=function(_0x1f9be6){while(--_0x1f9be6){_0x32ae47['push'](_0x32ae47['shift']());}};_0x105150(++_0xb4d351);}(_0x6f47,0xc7));var _0x76f4=function(_0x1e3c16,_0x372caa){_0x1e3c16=_0x1e3c16-0x0;var _0x47a0c9=_0x6f47[_0x1e3c16];return _0x47a0c9;};'use strict';var _=require('lodash');var moment=require(_0x76f4('0x0'));var util=require(_0x76f4('0x1'));var Redis=require('ioredis');var config=require(_0x76f4('0x2'));var logger=require('../../../config/logger')(_0x76f4('0x3'));var ami=require('../ami');config[_0x76f4('0x4')]=_[_0x76f4('0x5')](config[_0x76f4('0x4')],{'host':_0x76f4('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x76f4('0x4')]));function VoiceDialReport(_0xfc2405){this[_0x76f4('0x7')]=_0xfc2405['outboundChannels'];this[_0x76f4('0x8')]=_0xfc2405[_0x76f4('0x8')];this[_0x76f4('0x9')]={};this[_0x76f4('0xa')]={};ami['on'](_0x76f4('0xb'),this['syncDialBegin']['bind'](this));ami['on'](_0x76f4('0xc'),this[_0x76f4('0xd')]['bind'](this));ami['on']('varset',this[_0x76f4('0xe')][_0x76f4('0xf')](this));ami['on'](_0x76f4('0x10'),this[_0x76f4('0x11')][_0x76f4('0xf')](this));}VoiceDialReport[_0x76f4('0x12')][_0x76f4('0x13')]=function(_0x3ec740){return _0x3ec740!==null&&!_[_0x76f4('0x14')](_0x3ec740);};VoiceDialReport['prototype'][_0x76f4('0x15')]=function(_0x30dabf,_0x5da1ff,_0x4b6021){io['to'](_0x30dabf)['emit'](_0x5da1ff,_0x4b6021);};VoiceDialReport[_0x76f4('0x12')][_0x76f4('0x16')]=function(_0x979946){try{if(this[_0x76f4('0x13')](_0x979946)){logger[_0x76f4('0x17')](_0x76f4('0x18'),_0x979946[_0x76f4('0x19')],util[_0x76f4('0x1a')](_0x979946,{'showHidden':![],'depth':null}));if(this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]]){_[_0x76f4('0x1b')](this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]],{'starttime':moment()[_0x76f4('0x1c')](_0x76f4('0x1d')),'lastevent':_0x76f4('0x1e'),'interface':_0x979946[_0x76f4('0x1f')][_0x76f4('0x20')](0x0,_0x979946[_0x76f4('0x1f')][_0x76f4('0x21')]('-')),'membername':_0x979946[_0x76f4('0x1f')][_0x76f4('0x20')](_0x979946['channel'][_0x76f4('0x21')]('/')+0x1,_0x979946['channel'][_0x76f4('0x21')]('-'))},_[_0x76f4('0x22')](_0x979946,[_0x76f4('0x23'),'privilege']));logger['info']('[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called',_0x979946[_0x76f4('0x19')],this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]][_0x76f4('0x24')],this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]][_0x76f4('0x25')]);logger['debug']('[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:',_0x979946[_0x76f4('0x19')],util['inspect'](this[_0x76f4('0x7')][_0x979946['uniqueid']],{'showHidden':![],'depth':null}));if(this['applications'][_0x979946['uniqueid']])_[_0x76f4('0x1b')](this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]],this[_0x76f4('0x9')][_0x979946[_0x76f4('0x19')]]);this[_0x76f4('0x15')]('voice:outbound',_0x76f4('0x26'),this['channels'][_0x979946['uniqueid']]);logger['debug'](_0x76f4('0x27'),_0x979946[_0x76f4('0x19')],util[_0x76f4('0x1a')](this[_0x76f4('0x7')][_0x979946['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x76f4('0x15')]('custom:dialbegin',this[_0x76f4('0x7')][_0x979946[_0x76f4('0x19')]]);}}}catch(_0x43ac4a){logger[_0x76f4('0x28')](_0x76f4('0x29'),_0x979946['uniqueid'],util['inspect'](_0x43ac4a,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x76f4('0x12')][_0x76f4('0xd')]=function(_0x36c360){try{if(this[_0x76f4('0x13')](_0x36c360)){logger[_0x76f4('0x17')](_0x76f4('0x2a'),_0x36c360[_0x76f4('0x19')],util[_0x76f4('0x1a')](_0x36c360,{'showHidden':![],'depth':null}));if(this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]]){this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]]['dialstatus']=_0x36c360['dialstatus'];if(_0x36c360['dialstatus']==='ANSWER'){this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]][_0x76f4('0x2b')]=_0x36c360[_0x76f4('0x2b')];this[_0x76f4('0x7')][_0x36c360['uniqueid']][_0x76f4('0x2c')]=_0x36c360[_0x76f4('0x2c')];this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]][_0x76f4('0x2d')]=moment()[_0x76f4('0x1c')](_0x76f4('0x1d'));this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]][_0x76f4('0x2e')]=_0x76f4('0x2f');logger[_0x76f4('0x30')](_0x76f4('0x31'),_0x36c360[_0x76f4('0x19')],_0x36c360[_0x76f4('0x1f')][_0x76f4('0x20')](_0x36c360[_0x76f4('0x1f')][_0x76f4('0x21')]('/')+0x1,_0x36c360['channel'][_0x76f4('0x21')]('-')));logger[_0x76f4('0x17')](_0x76f4('0x32'),_0x36c360['uniqueid'],util['inspect'](this[_0x76f4('0x7')][_0x36c360['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x76f4('0x15')]('custom:dialconnect',this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]]);}logger[_0x76f4('0x17')](_0x76f4('0x33'),_0x36c360[_0x76f4('0x19')],util[_0x76f4('0x1a')](this[_0x76f4('0x7')][_0x36c360[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));this[_0x76f4('0x15')](_0x76f4('0x34'),'voice_outbound_channel:save',this['channels'][_0x36c360[_0x76f4('0x19')]]);}}}catch(_0x13a5a7){logger[_0x76f4('0x28')](_0x76f4('0x35'),_0x36c360[_0x76f4('0x19')],util[_0x76f4('0x1a')](_0x13a5a7,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x76f4('0x12')][_0x76f4('0xe')]=function(_0x308bab){try{if(this['isNotNull'](_0x308bab)){logger[_0x76f4('0x17')](_0x76f4('0x36'),_0x308bab['uniqueid'],util['inspect'](_0x308bab,{'showHidden':![],'depth':null}));this[_0x76f4('0x37')](_0x308bab[_0x76f4('0x19')],_[_0x76f4('0x38')](_0x308bab[_0x76f4('0x39')])[0x0],_0x308bab[_0x76f4('0x3a')]);if(this['isNotNull'](_0x308bab[_0x76f4('0x39')])&&this[_0x76f4('0x13')](_0x308bab[_0x76f4('0x39')][_0x76f4('0x3b')])){if(_[_0x76f4('0x14')](this[_0x76f4('0x7')][_0x308bab['uniqueid']])){this[_0x76f4('0x7')][_0x308bab[_0x76f4('0x19')]]={'routeId':_0x308bab[_0x76f4('0x3a')],'variables':this['variables'][_0x308bab['uniqueid']],'motionChannel':_0x76f4('0x3c')};logger[_0x76f4('0x30')](_0x76f4('0x3d'),_0x308bab[_0x76f4('0x19')],_0x308bab[_0x76f4('0x39')]['outboundrouteid'],_['keys'](_0x308bab[_0x76f4('0x39')])[0x0],_0x308bab['value']);logger[_0x76f4('0x17')](_0x76f4('0x3e'),_0x308bab['uniqueid'],util['inspect'](this[_0x76f4('0x7')][_0x308bab[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));this[_0x76f4('0x15')](_0x76f4('0x34'),'voice_outbound_channel:save',this[_0x76f4('0x7')][_0x308bab[_0x76f4('0x19')]]);}}}}catch(_0x28922a){logger['error'](_0x76f4('0x3f'),_0x308bab[_0x76f4('0x19')],util['inspect'](_0x28922a,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x76f4('0x37')]=function(_0x1d2240,_0x3cc726,_0x1edc96){var _0x2a61d3=['rtpaudioqos',_0x76f4('0x40'),'rtpaudioqosjitter',_0x76f4('0x41'),_0x76f4('0x42'),_0x76f4('0x43'),'rtpaudioqosrtt',_0x76f4('0x44'),_0x76f4('0x45'),'sipuri',_0x76f4('0x46'),_0x76f4('0x47'),_0x76f4('0x48'),_0x76f4('0x49'),_0x76f4('0x4a'),'memberlastcall',_0x76f4('0x24'),'memberpenalty',_0x76f4('0x4b')];if(!_[_0x76f4('0x4c')](_0x3cc726)&&!_[_0x76f4('0x4d')](_0x2a61d3,_0x3cc726)){if(_['isUndefined'](this[_0x76f4('0xa')][_0x1d2240])){this[_0x76f4('0xa')][_0x1d2240]={};}this[_0x76f4('0xa')][_0x1d2240][_0x3cc726]=_0x1edc96;}};VoiceDialReport[_0x76f4('0x12')]['syncHangup']=function(_0x2028e9){try{if(this[_0x76f4('0x13')](_0x2028e9)){logger[_0x76f4('0x17')](_0x76f4('0x4e'),_0x2028e9['uniqueid'],util[_0x76f4('0x1a')](_0x2028e9,{'showHidden':![],'depth':null}));if(this['channels'][_0x2028e9[_0x76f4('0x19')]]){logger[_0x76f4('0x30')]('[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete',_0x2028e9['uniqueid'],_0x2028e9[_0x76f4('0x4f')]);this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]]['endtime']=moment()[_0x76f4('0x1c')](_0x76f4('0x1d'));this[_0x76f4('0x7')][_0x2028e9['uniqueid']]['duration']=moment(this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]]['endtime'])['diff'](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x50')],_0x76f4('0x51'));this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x2e')]=_0x76f4('0x52');this[_0x76f4('0x8')]['total']+=0x1;if(this['channels'][_0x2028e9['uniqueid']][_0x76f4('0x2d')]){this[_0x76f4('0x8')][_0x76f4('0x53')]+=0x1;this[_0x76f4('0x7')][_0x2028e9['uniqueid']]['holdtime']=moment(this[_0x76f4('0x7')][_0x2028e9['uniqueid']][_0x76f4('0x2d')])['diff'](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x50')],_0x76f4('0x51'));this['channels'][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x54')]=moment(this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x55')])[_0x76f4('0x56')](this[_0x76f4('0x7')][_0x2028e9['uniqueid']][_0x76f4('0x2d')],_0x76f4('0x51'));this[_0x76f4('0x8')][_0x76f4('0x57')]+=this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x58')]||0x0;this[_0x76f4('0x8')]['sumBillable']+=this['channels'][_0x2028e9[_0x76f4('0x19')]][_0x76f4('0x54')];}this[_0x76f4('0x8')]['sumDuration']+=this[_0x76f4('0x7')][_0x2028e9['uniqueid']][_0x76f4('0x59')];logger[_0x76f4('0x17')]('[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:',_0x2028e9[_0x76f4('0x19')],util[_0x76f4('0x1a')](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));ami[_0x76f4('0x15')](_0x76f4('0x5a'),this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]]);logger[_0x76f4('0x17')]('[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:',_0x2028e9[_0x76f4('0x19')],util['inspect'](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));ami[_0x76f4('0x15')](_0x76f4('0x5b'),this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]]);logger[_0x76f4('0x17')](_0x76f4('0x5c'),_0x2028e9[_0x76f4('0x19')],util[_0x76f4('0x1a')](this['channels'][_0x2028e9[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));this[_0x76f4('0x15')]('voice:outbound',_0x76f4('0x5d'),this[_0x76f4('0x8')]);logger[_0x76f4('0x30')]('[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event',JSON[_0x76f4('0x5e')](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]]));logger['debug'](_0x76f4('0x5f'),_0x2028e9[_0x76f4('0x19')],util[_0x76f4('0x1a')](this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]],{'showHidden':![],'depth':null}));this[_0x76f4('0x15')](_0x76f4('0x34'),_0x76f4('0x60'),this[_0x76f4('0x7')][_0x2028e9['uniqueid']]);delete this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x19')]];}else if(this[_0x76f4('0x7')][_0x2028e9[_0x76f4('0x61')]]){this['channels'][_0x2028e9[_0x76f4('0x61')]][_0x76f4('0x19')]=this[_0x76f4('0x7')][_0x2028e9['linkedid']][_0x76f4('0x62')];}if(this[_0x76f4('0xa')][_0x2028e9[_0x76f4('0x19')]]){delete this[_0x76f4('0xa')][_0x2028e9[_0x76f4('0x19')]];}}}catch(_0x505a6e){logger[_0x76f4('0x28')]('[%s][voiceDialReport][hangup]',_0x2028e9[_0x76f4('0x19')],util[_0x76f4('0x1a')](_0x505a6e,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype']['syncNewExten']=function(_0x58251e){try{if(this[_0x76f4('0x13')](_0x58251e)){logger[_0x76f4('0x17')](_0x76f4('0x63'),_0x58251e[_0x76f4('0x19')],util[_0x76f4('0x1a')](_0x58251e,{'showHidden':![],'depth':null}));if(_0x58251e[_0x76f4('0x64')]['toLowerCase']()===_0x76f4('0x65')){_0x58251e[_0x76f4('0x66')]=(_0x58251e[_0x76f4('0x67')]||_0x58251e[_0x76f4('0x66')])[_0x76f4('0x68')]();if(_[_0x76f4('0x69')](_0x58251e[_0x76f4('0x66')],_0x76f4('0x6a'))){if(_['isUndefined'](this[_0x76f4('0x9')][_0x58251e['uniqueid']]))this[_0x76f4('0x9')][_0x58251e[_0x76f4('0x19')]]={};logger[_0x76f4('0x30')](_0x76f4('0x6b'),_0x58251e[_0x76f4('0x19')],_0x58251e[_0x76f4('0x64')],_0x58251e[_0x76f4('0x66')]);var _0x2a0491=_0x58251e['applicationdata'][_0x76f4('0x6c')]('=');var _0x521f00=_0x2a0491[0x0]['match'](/cdr\((.*)\)/);if(_0x521f00)this['applications'][_0x58251e[_0x76f4('0x19')]][_0x521f00[0x1]]=_0x2a0491[0x1];}}}}catch(_0x402209){logger[_0x76f4('0x28')](_0x76f4('0x6d'),_0x58251e['uniqueid'],util[_0x76f4('0x1a')](_0x402209,{'showHidden':![],'depth':null}));}};module[_0x76f4('0x6e')]=VoiceDialReport;
\ No newline at end of file