Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / services / ami / report / voiceDialReport.js
index 8a3dae4..fd464d3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbedd=['startsWith','cdr(','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','application','split','match','exports','lodash','util','ioredis','../../../config/environment','../../../config/logger','redis','defaults','localhost','socket.io-emitter','channels','outboundChannels','outbound','applications','variables','bind','dialend','varset','syncVarSet','syncHangup','isUndefined','prototype','emit','syncDialBegin','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','channel','substring','lastIndexOf','omit','event','privilege','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','custom:dialbegin','[%s][voiceDialReport][dialbegin]','syncDialEnd','isNotNull','dialstatus','ANSWER','connectedlinenum','connectedlinename','answertime','connect','info','[%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][varset]\x20event:','addVariable','keys','variable','value','voice','outboundrouteid','voice:outbound','error','[%s][voiceDialReport][varset]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','bridgepvtcallid','membercalls','memberpenalty','[%s][voiceDialReport][hangup]\x20event:','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt','endtime','duration','diff','starttime','seconds','lastevent','complete','total','answered','billableseconds','sumHoldTime','holdtime','sumBillable','sumDuration','custom:voiceDialReport','custom:dialend','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:','[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][newexten]\x20event:','applicationdata','toLowerCase'];(function(_0x3cb86b,_0x3c75f6){var _0x3c10a0=function(_0x71331f){while(--_0x71331f){_0x3cb86b['push'](_0x3cb86b['shift']());}};_0x3c10a0(++_0x3c75f6);}(_0xbedd,0xf3));var _0xdbed=function(_0x415470,_0x8c567){_0x415470=_0x415470-0x0;var _0x5618c8=_0xbedd[_0x415470];return _0x5618c8;};'use strict';var _=require(_0xdbed('0x0'));var moment=require('moment');var util=require(_0xdbed('0x1'));var Redis=require(_0xdbed('0x2'));var config=require(_0xdbed('0x3'));var logger=require(_0xdbed('0x4'))('ami');var ami=require('../ami');config[_0xdbed('0x5')]=_[_0xdbed('0x6')](config[_0xdbed('0x5')],{'host':_0xdbed('0x7'),'port':0x18eb});var io=require(_0xdbed('0x8'))(new Redis(config[_0xdbed('0x5')]));function VoiceDialReport(_0x26ef93){this[_0xdbed('0x9')]=_0x26ef93[_0xdbed('0xa')];this[_0xdbed('0xb')]=_0x26ef93[_0xdbed('0xb')];this[_0xdbed('0xc')]={};this[_0xdbed('0xd')]={};ami['on']('dialbegin',this['syncDialBegin'][_0xdbed('0xe')](this));ami['on'](_0xdbed('0xf'),this['syncDialEnd'][_0xdbed('0xe')](this));ami['on'](_0xdbed('0x10'),this[_0xdbed('0x11')]['bind'](this));ami['on']('hangup',this[_0xdbed('0x12')][_0xdbed('0xe')](this));}VoiceDialReport['prototype']['isNotNull']=function(_0x2a45d3){return _0x2a45d3!==null&&!_[_0xdbed('0x13')](_0x2a45d3);};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x15')]=function(_0xa64a3b,_0x54bc95,_0x233207){io['to'](_0xa64a3b)[_0xdbed('0x15')](_0x54bc95,_0x233207);};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x16')]=function(_0x1a4ffc){try{if(this['isNotNull'](_0x1a4ffc)){logger[_0xdbed('0x17')](_0xdbed('0x18'),_0x1a4ffc[_0xdbed('0x19')],util[_0xdbed('0x1a')](_0x1a4ffc,{'showHidden':![],'depth':null}));if(this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]]){_[_0xdbed('0x1b')](this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]],{'starttime':moment()[_0xdbed('0x1c')](_0xdbed('0x1d')),'lastevent':_0xdbed('0x1e'),'interface':_0x1a4ffc[_0xdbed('0x1f')][_0xdbed('0x20')](0x0,_0x1a4ffc['channel'][_0xdbed('0x21')]('-')),'membername':_0x1a4ffc[_0xdbed('0x1f')][_0xdbed('0x20')](_0x1a4ffc[_0xdbed('0x1f')]['lastIndexOf']('/')+0x1,_0x1a4ffc[_0xdbed('0x1f')][_0xdbed('0x21')]('-'))},_[_0xdbed('0x22')](_0x1a4ffc,[_0xdbed('0x23'),_0xdbed('0x24')]));logger['info'](_0xdbed('0x25'),_0x1a4ffc['uniqueid'],this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]][_0xdbed('0x26')],this['channels'][_0x1a4ffc[_0xdbed('0x19')]][_0xdbed('0x27')]);logger[_0xdbed('0x17')](_0xdbed('0x28'),_0x1a4ffc[_0xdbed('0x19')],util['inspect'](this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));if(this['applications'][_0x1a4ffc[_0xdbed('0x19')]])_['merge'](this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]],this[_0xdbed('0xc')][_0x1a4ffc[_0xdbed('0x19')]]);this['emit']('voice:outbound',_0xdbed('0x29'),this[_0xdbed('0x9')][_0x1a4ffc[_0xdbed('0x19')]]);logger[_0xdbed('0x17')](_0xdbed('0x2a'),_0x1a4ffc[_0xdbed('0x19')],util[_0xdbed('0x1a')](this[_0xdbed('0x9')][_0x1a4ffc['uniqueid']],{'showHidden':![],'depth':null}));ami['emit'](_0xdbed('0x2b'),this['channels'][_0x1a4ffc[_0xdbed('0x19')]]);}}}catch(_0x4b9773){logger['error'](_0xdbed('0x2c'),_0x1a4ffc[_0xdbed('0x19')],util[_0xdbed('0x1a')](_0x4b9773,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x2d')]=function(_0x3db025){try{if(this[_0xdbed('0x2e')](_0x3db025)){logger[_0xdbed('0x17')]('[%s][voiceDialReport][dialend]\x20event:',_0x3db025[_0xdbed('0x19')],util['inspect'](_0x3db025,{'showHidden':![],'depth':null}));if(this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]]){this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]][_0xdbed('0x2f')]=_0x3db025[_0xdbed('0x2f')];if(_0x3db025['dialstatus']===_0xdbed('0x30')){this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]][_0xdbed('0x31')]=_0x3db025[_0xdbed('0x31')];this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]][_0xdbed('0x32')]=_0x3db025[_0xdbed('0x32')];this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]][_0xdbed('0x33')]=moment()[_0xdbed('0x1c')](_0xdbed('0x1d'));this[_0xdbed('0x9')][_0x3db025['uniqueid']]['lastevent']=_0xdbed('0x34');logger[_0xdbed('0x35')](_0xdbed('0x36'),_0x3db025['uniqueid'],_0x3db025[_0xdbed('0x1f')]['substring'](_0x3db025[_0xdbed('0x1f')][_0xdbed('0x21')]('/')+0x1,_0x3db025[_0xdbed('0x1f')][_0xdbed('0x21')]('-')));logger['debug'](_0xdbed('0x37'),_0x3db025['uniqueid'],util[_0xdbed('0x1a')](this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));ami[_0xdbed('0x15')](_0xdbed('0x38'),this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]]);}logger[_0xdbed('0x17')](_0xdbed('0x39'),_0x3db025[_0xdbed('0x19')],util['inspect'](this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));this['emit']('voice:outbound',_0xdbed('0x29'),this[_0xdbed('0x9')][_0x3db025[_0xdbed('0x19')]]);}}}catch(_0x3775ce){logger['error']('[%s][voiceDialReport][dialend]',_0x3db025['uniqueid'],util[_0xdbed('0x1a')](_0x3775ce,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x11')]=function(_0x27991c){try{if(this[_0xdbed('0x2e')](_0x27991c)){logger['debug'](_0xdbed('0x3a'),_0x27991c[_0xdbed('0x19')],util[_0xdbed('0x1a')](_0x27991c,{'showHidden':![],'depth':null}));this[_0xdbed('0x3b')](_0x27991c['uniqueid'],_[_0xdbed('0x3c')](_0x27991c[_0xdbed('0x3d')])[0x0],_0x27991c[_0xdbed('0x3e')]);if(this[_0xdbed('0x2e')](_0x27991c[_0xdbed('0x3d')])&&this[_0xdbed('0x2e')](_0x27991c[_0xdbed('0x3d')]['outboundrouteid'])){if(_['isUndefined'](this['channels'][_0x27991c[_0xdbed('0x19')]])){this[_0xdbed('0x9')][_0x27991c[_0xdbed('0x19')]]={'routeId':_0x27991c[_0xdbed('0x3e')],'variables':this['variables'][_0x27991c[_0xdbed('0x19')]],'motionChannel':_0xdbed('0x3f')};logger[_0xdbed('0x35')]('[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s',_0x27991c['uniqueid'],_0x27991c[_0xdbed('0x3d')][_0xdbed('0x40')],_[_0xdbed('0x3c')](_0x27991c[_0xdbed('0x3d')])[0x0],_0x27991c[_0xdbed('0x3e')]);logger['debug']('[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:',_0x27991c[_0xdbed('0x19')],util[_0xdbed('0x1a')](this[_0xdbed('0x9')][_0x27991c[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));this[_0xdbed('0x15')](_0xdbed('0x41'),_0xdbed('0x29'),this['channels'][_0x27991c[_0xdbed('0x19')]]);}}}}catch(_0x329efc){logger[_0xdbed('0x42')](_0xdbed('0x43'),_0x27991c[_0xdbed('0x19')],util['inspect'](_0x329efc,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x3b')]=function(_0x376c80,_0x1deafc,_0x572142){var _0x805235=[_0xdbed('0x44'),_0xdbed('0x45'),'rtpaudioqosjitter',_0xdbed('0x46'),_0xdbed('0x47'),_0xdbed('0x48'),_0xdbed('0x49'),_0xdbed('0x4a'),_0xdbed('0x4b'),_0xdbed('0x4c'),_0xdbed('0x4d'),_0xdbed('0x4e'),_0xdbed('0x4f'),'memberdynamic','memberinterface','memberlastcall',_0xdbed('0x26'),_0xdbed('0x50'),'memberrealtime'];if(!_['isNil'](_0x1deafc)&&!_['includes'](_0x805235,_0x1deafc)){if(_[_0xdbed('0x13')](this[_0xdbed('0xd')][_0x376c80])){this[_0xdbed('0xd')][_0x376c80]={};}this[_0xdbed('0xd')][_0x376c80][_0x1deafc]=_0x572142;}};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x12')]=function(_0x46381b){try{if(this[_0xdbed('0x2e')](_0x46381b)){logger['debug'](_0xdbed('0x51'),_0x46381b[_0xdbed('0x19')],util[_0xdbed('0x1a')](_0x46381b,{'showHidden':![],'depth':null}));if(this['channels'][_0x46381b[_0xdbed('0x19')]]){logger[_0xdbed('0x35')](_0xdbed('0x52'),_0x46381b[_0xdbed('0x19')],_0x46381b[_0xdbed('0x53')]);this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x54')]=moment()[_0xdbed('0x1c')](_0xdbed('0x1d'));this['channels'][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x55')]=moment(this['channels'][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x54')])[_0xdbed('0x56')](this[_0xdbed('0x9')][_0x46381b['uniqueid']][_0xdbed('0x57')],_0xdbed('0x58'));this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x59')]=_0xdbed('0x5a');this['outbound'][_0xdbed('0x5b')]+=0x1;if(this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x33')]){this['outbound'][_0xdbed('0x5c')]+=0x1;this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]]['holdtime']=moment(this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x33')])[_0xdbed('0x56')](this[_0xdbed('0x9')][_0x46381b['uniqueid']]['starttime'],_0xdbed('0x58'));this[_0xdbed('0x9')][_0x46381b['uniqueid']][_0xdbed('0x5d')]=moment(this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]]['endtime'])[_0xdbed('0x56')](this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x33')],_0xdbed('0x58'));this[_0xdbed('0xb')][_0xdbed('0x5e')]+=this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x5f')]||0x0;this[_0xdbed('0xb')][_0xdbed('0x60')]+=this['channels'][_0x46381b[_0xdbed('0x19')]][_0xdbed('0x5d')];}this['outbound'][_0xdbed('0x61')]+=this[_0xdbed('0x9')][_0x46381b['uniqueid']][_0xdbed('0x55')];logger['debug']('[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:',_0x46381b['uniqueid'],util['inspect'](this['channels'][_0x46381b[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));ami[_0xdbed('0x15')](_0xdbed('0x62'),this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]]);logger[_0xdbed('0x17')]('[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:',_0x46381b[_0xdbed('0x19')],util['inspect'](this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));ami['emit'](_0xdbed('0x63'),this['channels'][_0x46381b['uniqueid']]);logger['debug'](_0xdbed('0x64'),_0x46381b['uniqueid'],util['inspect'](this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));this[_0xdbed('0x15')](_0xdbed('0x41'),'voice_outbound:save',this[_0xdbed('0xb')]);logger[_0xdbed('0x35')](_0xdbed('0x65'),JSON[_0xdbed('0x66')](this[_0xdbed('0x9')][_0x46381b['uniqueid']]));logger[_0xdbed('0x17')](_0xdbed('0x67'),_0x46381b['uniqueid'],util[_0xdbed('0x1a')](this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]],{'showHidden':![],'depth':null}));this[_0xdbed('0x15')]('voice:outbound',_0xdbed('0x68'),this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x19')]]);this[_0xdbed('0x69')](_0x46381b[_0xdbed('0x19')]);}else if(this[_0xdbed('0x9')][_0x46381b['linkedid']]){this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x6a')]]['uniqueid']=this[_0xdbed('0x9')][_0x46381b[_0xdbed('0x6a')]][_0xdbed('0x6b')];}if(this[_0xdbed('0xd')][_0x46381b[_0xdbed('0x19')]]){delete this[_0xdbed('0xd')][_0x46381b['uniqueid']];}}}catch(_0x20344f){logger['error']('[%s][voiceDialReport][hangup]',_0x46381b[_0xdbed('0x19')],util['inspect'](_0x20344f,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype']['syncNewExten']=function(_0x28d1c2){try{if(this[_0xdbed('0x2e')](_0x28d1c2)){logger[_0xdbed('0x17')](_0xdbed('0x6c'),_0x28d1c2[_0xdbed('0x19')],util[_0xdbed('0x1a')](_0x28d1c2,{'showHidden':![],'depth':null}));if(_0x28d1c2['application']['toLowerCase']()==='set'){_0x28d1c2[_0xdbed('0x6d')]=(_0x28d1c2['appdata']||_0x28d1c2[_0xdbed('0x6d')])[_0xdbed('0x6e')]();if(_[_0xdbed('0x6f')](_0x28d1c2[_0xdbed('0x6d')],_0xdbed('0x70'))){if(_[_0xdbed('0x13')](this['applications'][_0x28d1c2[_0xdbed('0x19')]]))this[_0xdbed('0xc')][_0x28d1c2[_0xdbed('0x19')]]={};logger['info'](_0xdbed('0x71'),_0x28d1c2[_0xdbed('0x19')],_0x28d1c2[_0xdbed('0x72')],_0x28d1c2[_0xdbed('0x6d')]);var _0x12deec=_0x28d1c2[_0xdbed('0x6d')][_0xdbed('0x73')]('=');var _0x48f085=_0x12deec[0x0][_0xdbed('0x74')](/cdr\((.*)\)/);if(_0x48f085)this[_0xdbed('0xc')][_0x28d1c2[_0xdbed('0x19')]][_0x48f085[0x1]]=_0x12deec[0x1];}}}}catch(_0x5688df){logger[_0xdbed('0x42')]('[%s][voiceDialReport][newexten]',_0x28d1c2['uniqueid'],util[_0xdbed('0x1a')](_0x5688df,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xdbed('0x14')][_0xdbed('0x69')]=function(_0x529a02,_0x3b28d3=0x2710){if(this[_0xdbed('0x9')][_0x529a02]){setTimeout(()=>{delete this[_0xdbed('0x9')][_0x529a02];},_0x3b28d3);}};module[_0xdbed('0x75')]=VoiceDialReport;
\ No newline at end of file
+var _0xf2cc=['[%s][voiceDialReport][hangup]\x20event:','cause-txt','endtime','duration','diff','starttime','seconds','complete','total','answered','holdtime','answertime','sumHoldTime','sumBillable','billableseconds','sumDuration','custom:voiceDialReport','[%s][voiceDialReport][hangup]\x20sending\x20dialend\x20event:','custom:dialend','voice_outbound:save','[DEBUG]\x20Emit\x20voice_outbound_channel:remove\x20event','voice_outbound_channel:remove','deleteChannelAfterTimeout','linkedid','destuniqueid','[%s][voiceDialReport][hangup]','syncNewExten','[%s][voiceDialReport][newexten]\x20event:','application','toLowerCase','set','applicationdata','appdata','startsWith','cdr(','match','[%s][voiceDialReport][newexten]','exports','lodash','util','../../../config/logger','ami','../ami','redis','localhost','channels','outboundChannels','outbound','variables','dialend','bind','varset','syncVarSet','hangup','prototype','isUndefined','syncDialBegin','isNotNull','debug','[%s][voiceDialReport][dialbegin]\x20event:','inspect','uniqueid','merge','format','called','channel','substring','lastIndexOf','event','privilege','info','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','applications','emit','voice:outbound','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','custom:dialbegin','error','[%s][voiceDialReport][dialbegin]','syncDialEnd','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','YYYY-MM-DD\x20HH:mm:ss','lastevent','[%s][voiceDialReport][dialend]\x20sending\x20dialconnect\x20event:','[%s][voiceDialReport][dialend]\x20sending\x20voice_outbound_channel:save\x20event:','[%s][voiceDialReport][dialend]','[%s][voiceDialReport][varset]\x20event:','addVariable','keys','value','variable','outboundrouteid','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','[%s][voiceDialReport][varset]','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepeer','membercalls','memberdynamic','memberlastcall','memberpenalty','memberrealtime','isNil','includes','syncHangup'];(function(_0x4f4d4a,_0x21bdaa){var _0x20b807=function(_0x496ef9){while(--_0x496ef9){_0x4f4d4a['push'](_0x4f4d4a['shift']());}};_0x20b807(++_0x21bdaa);}(_0xf2cc,0x112));var _0xcf2c=function(_0x4709c0,_0x3396c7){_0x4709c0=_0x4709c0-0x0;var _0x13348b=_0xf2cc[_0x4709c0];return _0x13348b;};'use strict';var _=require(_0xcf2c('0x0'));var moment=require('moment');var util=require(_0xcf2c('0x1'));var Redis=require('ioredis');var config=require('../../../config/environment');var logger=require(_0xcf2c('0x2'))(_0xcf2c('0x3'));var ami=require(_0xcf2c('0x4'));config[_0xcf2c('0x5')]=_['defaults'](config[_0xcf2c('0x5')],{'host':_0xcf2c('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xcf2c('0x5')]));function VoiceDialReport(_0x35c5c7){this[_0xcf2c('0x7')]=_0x35c5c7[_0xcf2c('0x8')];this[_0xcf2c('0x9')]=_0x35c5c7[_0xcf2c('0x9')];this['applications']={};this[_0xcf2c('0xa')]={};ami['on']('dialbegin',this['syncDialBegin']['bind'](this));ami['on'](_0xcf2c('0xb'),this['syncDialEnd'][_0xcf2c('0xc')](this));ami['on'](_0xcf2c('0xd'),this[_0xcf2c('0xe')]['bind'](this));ami['on'](_0xcf2c('0xf'),this['syncHangup'][_0xcf2c('0xc')](this));}VoiceDialReport[_0xcf2c('0x10')]['isNotNull']=function(_0x2abcce){return _0x2abcce!==null&&!_[_0xcf2c('0x11')](_0x2abcce);};VoiceDialReport[_0xcf2c('0x10')]['emit']=function(_0x4f3a85,_0x1dea8f,_0x31a2a8){io['to'](_0x4f3a85)['emit'](_0x1dea8f,_0x31a2a8);};VoiceDialReport[_0xcf2c('0x10')][_0xcf2c('0x12')]=function(_0x55edf1){try{if(this[_0xcf2c('0x13')](_0x55edf1)){logger[_0xcf2c('0x14')](_0xcf2c('0x15'),_0x55edf1['uniqueid'],util[_0xcf2c('0x16')](_0x55edf1,{'showHidden':![],'depth':null}));if(this['channels'][_0x55edf1[_0xcf2c('0x17')]]){_[_0xcf2c('0x18')](this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]],{'starttime':moment()[_0xcf2c('0x19')]('YYYY-MM-DD\x20HH:mm:ss'),'lastevent':_0xcf2c('0x1a'),'interface':_0x55edf1[_0xcf2c('0x1b')][_0xcf2c('0x1c')](0x0,_0x55edf1[_0xcf2c('0x1b')]['lastIndexOf']('-')),'membername':_0x55edf1[_0xcf2c('0x1b')][_0xcf2c('0x1c')](_0x55edf1['channel'][_0xcf2c('0x1d')]('/')+0x1,_0x55edf1['channel'][_0xcf2c('0x1d')]('-'))},_['omit'](_0x55edf1,[_0xcf2c('0x1e'),_0xcf2c('0x1f')]));logger[_0xcf2c('0x20')](_0xcf2c('0x21'),_0x55edf1['uniqueid'],this['channels'][_0x55edf1[_0xcf2c('0x17')]][_0xcf2c('0x22')],this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]]['interface']);logger['debug'](_0xcf2c('0x23'),_0x55edf1[_0xcf2c('0x17')],util['inspect'](this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));if(this[_0xcf2c('0x24')][_0x55edf1['uniqueid']])_[_0xcf2c('0x18')](this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]],this['applications'][_0x55edf1[_0xcf2c('0x17')]]);this[_0xcf2c('0x25')](_0xcf2c('0x26'),_0xcf2c('0x27'),this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]]);logger[_0xcf2c('0x14')](_0xcf2c('0x28'),_0x55edf1[_0xcf2c('0x17')],util['inspect'](this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));ami[_0xcf2c('0x25')](_0xcf2c('0x29'),this[_0xcf2c('0x7')][_0x55edf1[_0xcf2c('0x17')]]);}}}catch(_0x463cc6){logger[_0xcf2c('0x2a')](_0xcf2c('0x2b'),_0x55edf1[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x463cc6,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xcf2c('0x10')][_0xcf2c('0x2c')]=function(_0x2024b0){try{if(this['isNotNull'](_0x2024b0)){logger[_0xcf2c('0x14')](_0xcf2c('0x2d'),_0x2024b0[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x2024b0,{'showHidden':![],'depth':null}));if(this['channels'][_0x2024b0[_0xcf2c('0x17')]]){this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]]['dialstatus']=_0x2024b0[_0xcf2c('0x2e')];if(_0x2024b0[_0xcf2c('0x2e')]===_0xcf2c('0x2f')){this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]][_0xcf2c('0x30')]=_0x2024b0['connectedlinenum'];this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]]['connectedlinename']=_0x2024b0['connectedlinename'];this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]]['answertime']=moment()[_0xcf2c('0x19')](_0xcf2c('0x31'));this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]][_0xcf2c('0x32')]='connect';logger[_0xcf2c('0x20')]('[%s][voiceDialReport][dialend]\x20agent:%s\x20lastevent:connect',_0x2024b0['uniqueid'],_0x2024b0[_0xcf2c('0x1b')][_0xcf2c('0x1c')](_0x2024b0[_0xcf2c('0x1b')]['lastIndexOf']('/')+0x1,_0x2024b0[_0xcf2c('0x1b')]['lastIndexOf']('-')));logger['debug'](_0xcf2c('0x33'),_0x2024b0['uniqueid'],util['inspect'](this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));ami[_0xcf2c('0x25')]('custom:dialconnect',this[_0xcf2c('0x7')][_0x2024b0[_0xcf2c('0x17')]]);}logger['debug'](_0xcf2c('0x34'),_0x2024b0[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this['channels'][_0x2024b0['uniqueid']],{'showHidden':![],'depth':null}));this[_0xcf2c('0x25')]('voice:outbound',_0xcf2c('0x27'),this[_0xcf2c('0x7')][_0x2024b0['uniqueid']]);}}}catch(_0x4fd638){logger[_0xcf2c('0x2a')](_0xcf2c('0x35'),_0x2024b0[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x4fd638,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xcf2c('0x10')][_0xcf2c('0xe')]=function(_0x31476e){try{if(this[_0xcf2c('0x13')](_0x31476e)){logger[_0xcf2c('0x14')](_0xcf2c('0x36'),_0x31476e[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x31476e,{'showHidden':![],'depth':null}));this[_0xcf2c('0x37')](_0x31476e[_0xcf2c('0x17')],_[_0xcf2c('0x38')](_0x31476e['variable'])[0x0],_0x31476e[_0xcf2c('0x39')]);if(this['isNotNull'](_0x31476e[_0xcf2c('0x3a')])&&this[_0xcf2c('0x13')](_0x31476e['variable'][_0xcf2c('0x3b')])){if(_['isUndefined'](this[_0xcf2c('0x7')][_0x31476e['uniqueid']])){this['channels'][_0x31476e[_0xcf2c('0x17')]]={'routeId':_0x31476e['value'],'variables':this[_0xcf2c('0xa')][_0x31476e[_0xcf2c('0x17')]],'motionChannel':_0xcf2c('0x3c')};logger[_0xcf2c('0x20')](_0xcf2c('0x3d'),_0x31476e['uniqueid'],_0x31476e['variable'][_0xcf2c('0x3b')],_[_0xcf2c('0x38')](_0x31476e[_0xcf2c('0x3a')])[0x0],_0x31476e[_0xcf2c('0x39')]);logger[_0xcf2c('0x14')](_0xcf2c('0x3e'),_0x31476e[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this[_0xcf2c('0x7')][_0x31476e[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));this[_0xcf2c('0x25')]('voice:outbound',_0xcf2c('0x27'),this[_0xcf2c('0x7')][_0x31476e[_0xcf2c('0x17')]]);}}}}catch(_0x568917){logger[_0xcf2c('0x2a')](_0xcf2c('0x3f'),_0x31476e[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x568917,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xcf2c('0x10')]['addVariable']=function(_0x3dc450,_0x27f97e,_0x207744){var _0x400317=['rtpaudioqos',_0xcf2c('0x40'),_0xcf2c('0x41'),'rtpaudioqosjitterbridged',_0xcf2c('0x42'),_0xcf2c('0x43'),'rtpaudioqosrtt',_0xcf2c('0x44'),_0xcf2c('0x45'),_0xcf2c('0x46'),_0xcf2c('0x47'),'bridgepvtcallid',_0xcf2c('0x48'),_0xcf2c('0x49'),'memberinterface',_0xcf2c('0x4a'),'membername',_0xcf2c('0x4b'),_0xcf2c('0x4c')];if(!_[_0xcf2c('0x4d')](_0x27f97e)&&!_[_0xcf2c('0x4e')](_0x400317,_0x27f97e)){if(_[_0xcf2c('0x11')](this[_0xcf2c('0xa')][_0x3dc450])){this['variables'][_0x3dc450]={};}this[_0xcf2c('0xa')][_0x3dc450][_0x27f97e]=_0x207744;}};VoiceDialReport['prototype'][_0xcf2c('0x4f')]=function(_0xafe30f){try{if(this[_0xcf2c('0x13')](_0xafe30f)){logger['debug'](_0xcf2c('0x50'),_0xafe30f['uniqueid'],util[_0xcf2c('0x16')](_0xafe30f,{'showHidden':![],'depth':null}));if(this['channels'][_0xafe30f[_0xcf2c('0x17')]]){logger[_0xcf2c('0x20')]('[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete',_0xafe30f[_0xcf2c('0x17')],_0xafe30f[_0xcf2c('0x51')]);this[_0xcf2c('0x7')][_0xafe30f['uniqueid']][_0xcf2c('0x52')]=moment()[_0xcf2c('0x19')]('YYYY-MM-DD\x20HH:mm:ss');this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x53')]=moment(this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x52')])[_0xcf2c('0x54')](this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x55')],_0xcf2c('0x56'));this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x32')]=_0xcf2c('0x57');this[_0xcf2c('0x9')][_0xcf2c('0x58')]+=0x1;if(this['channels'][_0xafe30f[_0xcf2c('0x17')]]['answertime']){this[_0xcf2c('0x9')][_0xcf2c('0x59')]+=0x1;this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x5a')]=moment(this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x5b')])[_0xcf2c('0x54')](this['channels'][_0xafe30f['uniqueid']]['starttime'],'seconds');this['channels'][_0xafe30f[_0xcf2c('0x17')]]['billableseconds']=moment(this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x52')])[_0xcf2c('0x54')](this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x5b')],'seconds');this[_0xcf2c('0x9')][_0xcf2c('0x5c')]+=this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x5a')]||0x0;this[_0xcf2c('0x9')][_0xcf2c('0x5d')]+=this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x5e')];}this[_0xcf2c('0x9')][_0xcf2c('0x5f')]+=this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]][_0xcf2c('0x53')];logger[_0xcf2c('0x14')]('[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:',_0xafe30f[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));ami[_0xcf2c('0x25')](_0xcf2c('0x60'),this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]]);logger[_0xcf2c('0x14')](_0xcf2c('0x61'),_0xafe30f[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this[_0xcf2c('0x7')][_0xafe30f['uniqueid']],{'showHidden':![],'depth':null}));ami[_0xcf2c('0x25')](_0xcf2c('0x62'),this['channels'][_0xafe30f[_0xcf2c('0x17')]]);logger[_0xcf2c('0x14')]('[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:',_0xafe30f[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this['channels'][_0xafe30f[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));this['emit'](_0xcf2c('0x26'),_0xcf2c('0x63'),this[_0xcf2c('0x9')]);logger[_0xcf2c('0x20')](_0xcf2c('0x64'),JSON['stringify'](this[_0xcf2c('0x7')][_0xafe30f['uniqueid']]));logger['debug']('[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:',_0xafe30f[_0xcf2c('0x17')],util[_0xcf2c('0x16')](this['channels'][_0xafe30f[_0xcf2c('0x17')]],{'showHidden':![],'depth':null}));this[_0xcf2c('0x25')]('voice:outbound',_0xcf2c('0x65'),this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x17')]]);this[_0xcf2c('0x66')](_0xafe30f[_0xcf2c('0x17')]);}else if(this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x67')]]){this['channels'][_0xafe30f[_0xcf2c('0x67')]][_0xcf2c('0x17')]=this[_0xcf2c('0x7')][_0xafe30f[_0xcf2c('0x67')]][_0xcf2c('0x68')];}if(this[_0xcf2c('0xa')][_0xafe30f['uniqueid']]){delete this['variables'][_0xafe30f[_0xcf2c('0x17')]];}}}catch(_0x22e165){logger[_0xcf2c('0x2a')](_0xcf2c('0x69'),_0xafe30f[_0xcf2c('0x17')],util['inspect'](_0x22e165,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0xcf2c('0x10')][_0xcf2c('0x6a')]=function(_0x5ef0bb){try{if(this['isNotNull'](_0x5ef0bb)){logger[_0xcf2c('0x14')](_0xcf2c('0x6b'),_0x5ef0bb[_0xcf2c('0x17')],util['inspect'](_0x5ef0bb,{'showHidden':![],'depth':null}));if(_0x5ef0bb[_0xcf2c('0x6c')][_0xcf2c('0x6d')]()===_0xcf2c('0x6e')){_0x5ef0bb[_0xcf2c('0x6f')]=(_0x5ef0bb[_0xcf2c('0x70')]||_0x5ef0bb[_0xcf2c('0x6f')])[_0xcf2c('0x6d')]();if(_[_0xcf2c('0x71')](_0x5ef0bb[_0xcf2c('0x6f')],_0xcf2c('0x72'))){if(_[_0xcf2c('0x11')](this[_0xcf2c('0x24')][_0x5ef0bb[_0xcf2c('0x17')]]))this[_0xcf2c('0x24')][_0x5ef0bb[_0xcf2c('0x17')]]={};logger[_0xcf2c('0x20')]('[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s',_0x5ef0bb['uniqueid'],_0x5ef0bb[_0xcf2c('0x6c')],_0x5ef0bb[_0xcf2c('0x6f')]);var _0x27650f=_0x5ef0bb['applicationdata']['split']('=');var _0x5af3b7=_0x27650f[0x0][_0xcf2c('0x73')](/cdr\((.*)\)/);if(_0x5af3b7)this['applications'][_0x5ef0bb['uniqueid']][_0x5af3b7[0x1]]=_0x27650f[0x1];}}}}catch(_0x429d49){logger[_0xcf2c('0x2a')](_0xcf2c('0x74'),_0x5ef0bb[_0xcf2c('0x17')],util[_0xcf2c('0x16')](_0x429d49,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0xcf2c('0x66')]=function(_0x5b3bb7,_0x243261=0x2710){if(this[_0xcf2c('0x7')][_0x5b3bb7]){setTimeout(()=>{delete this[_0xcf2c('0x7')][_0x5b3bb7];},_0x243261);}};module[_0xcf2c('0x75')]=VoiceDialReport;
\ No newline at end of file