Built motion from commit 3770a7bd.|2.6.29
[motion2.git] / server / services / ami / report / voiceDialReport.js
index 8b289d2..0711052 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2bd8=['connect','[%s][voiceDialReport][dialend]\x20agent:%s\x20lastevent:connect','custom:dialconnect','[%s][voiceDialReport][dialend]\x20sending\x20voice_outbound_channel:save\x20event:','voice_outbound_channel:save','error','[%s][voiceDialReport][dialend]','syncVarSet','[%s][voiceDialReport][varset]\x20event:','addVariable','keys','value','variable','outboundrouteid','variables','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','[%s][voiceDialReport][varset]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','sipcallid','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','isNil','syncHangup','[%s][voiceDialReport][hangup]\x20event:','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt','endtime','diff','starttime','seconds','complete','total','answered','holdtime','billableseconds','sumHoldTime','sumBillable','sumDuration','custom:voiceDialReport','[%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','[%s][voiceDialReport][hangup]','[%s][voiceDialReport][newexten]\x20event:','application','toLowerCase','set','applicationdata','appdata','startsWith','cdr(','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','split','exports','lodash','util','ioredis','../../../config/environment','../../../config/logger','ami','../ami','redis','localhost','socket.io-emitter','channels','outboundChannels','outbound','applications','bind','hangup','isNotNull','isUndefined','prototype','emit','syncDialBegin','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','format','YYYY-MM-DD\x20HH:mm:ss','called','channel','lastIndexOf','substring','omit','event','privilege','info','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','custom:dialbegin','[%s][voiceDialReport][dialbegin]','syncDialEnd','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','connectedlinename','answertime','lastevent'];(function(_0x53b972,_0x288c5c){var _0x502d0a=function(_0x29f3e8){while(--_0x29f3e8){_0x53b972['push'](_0x53b972['shift']());}};_0x502d0a(++_0x288c5c);}(_0x2bd8,0x130));var _0x82bd=function(_0x547be8,_0x51b80e){_0x547be8=_0x547be8-0x0;var _0x26dd5f=_0x2bd8[_0x547be8];return _0x26dd5f;};'use strict';var _=require(_0x82bd('0x0'));var moment=require('moment');var util=require(_0x82bd('0x1'));var Redis=require(_0x82bd('0x2'));var config=require(_0x82bd('0x3'));var logger=require(_0x82bd('0x4'))(_0x82bd('0x5'));var ami=require(_0x82bd('0x6'));config[_0x82bd('0x7')]=_['defaults'](config[_0x82bd('0x7')],{'host':_0x82bd('0x8'),'port':0x18eb});var io=require(_0x82bd('0x9'))(new Redis(config['redis']));function VoiceDialReport(_0x19dbb1){this[_0x82bd('0xa')]=_0x19dbb1[_0x82bd('0xb')];this[_0x82bd('0xc')]=_0x19dbb1['outbound'];this[_0x82bd('0xd')]={};this['variables']={};ami['on']('dialbegin',this['syncDialBegin'][_0x82bd('0xe')](this));ami['on']('dialend',this['syncDialEnd'][_0x82bd('0xe')](this));ami['on']('varset',this['syncVarSet'][_0x82bd('0xe')](this));ami['on'](_0x82bd('0xf'),this['syncHangup'][_0x82bd('0xe')](this));}VoiceDialReport['prototype'][_0x82bd('0x10')]=function(_0x51e17e){return _0x51e17e!==null&&!_[_0x82bd('0x11')](_0x51e17e);};VoiceDialReport[_0x82bd('0x12')][_0x82bd('0x13')]=function(_0x2ca530,_0x58d82b,_0x446ffc){io['to'](_0x2ca530)[_0x82bd('0x13')](_0x58d82b,_0x446ffc);};VoiceDialReport['prototype'][_0x82bd('0x14')]=function(_0x4db39d){try{if(this[_0x82bd('0x10')](_0x4db39d)){logger[_0x82bd('0x15')](_0x82bd('0x16'),_0x4db39d[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x4db39d,{'showHidden':![],'depth':null}));if(this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]]){_[_0x82bd('0x19')](this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]],{'starttime':moment()[_0x82bd('0x1a')](_0x82bd('0x1b')),'lastevent':_0x82bd('0x1c'),'interface':_0x4db39d[_0x82bd('0x1d')]['substring'](0x0,_0x4db39d['channel'][_0x82bd('0x1e')]('-')),'membername':_0x4db39d[_0x82bd('0x1d')][_0x82bd('0x1f')](_0x4db39d[_0x82bd('0x1d')][_0x82bd('0x1e')]('/')+0x1,_0x4db39d[_0x82bd('0x1d')][_0x82bd('0x1e')]('-'))},_[_0x82bd('0x20')](_0x4db39d,[_0x82bd('0x21'),_0x82bd('0x22')]));logger[_0x82bd('0x23')](_0x82bd('0x24'),_0x4db39d[_0x82bd('0x17')],this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]][_0x82bd('0x25')],this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]][_0x82bd('0x26')]);logger['debug']('[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:',_0x4db39d[_0x82bd('0x17')],util[_0x82bd('0x18')](this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));if(this[_0x82bd('0xd')][_0x4db39d[_0x82bd('0x17')]])_[_0x82bd('0x19')](this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]],this[_0x82bd('0xd')][_0x4db39d['uniqueid']]);this['emit']('voice:outbound','voice_outbound_channel:save',this[_0x82bd('0xa')][_0x4db39d[_0x82bd('0x17')]]);logger[_0x82bd('0x15')](_0x82bd('0x27'),_0x4db39d[_0x82bd('0x17')],util['inspect'](this['channels'][_0x4db39d['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x82bd('0x13')](_0x82bd('0x28'),this[_0x82bd('0xa')][_0x4db39d['uniqueid']]);}}}catch(_0x166c46){logger['error'](_0x82bd('0x29'),_0x4db39d[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x166c46,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x82bd('0x12')][_0x82bd('0x2a')]=function(_0x25e36e){try{if(this['isNotNull'](_0x25e36e)){logger[_0x82bd('0x15')](_0x82bd('0x2b'),_0x25e36e[_0x82bd('0x17')],util['inspect'](_0x25e36e,{'showHidden':![],'depth':null}));if(this[_0x82bd('0xa')][_0x25e36e['uniqueid']]){this['channels'][_0x25e36e[_0x82bd('0x17')]][_0x82bd('0x2c')]=_0x25e36e[_0x82bd('0x2c')];if(_0x25e36e[_0x82bd('0x2c')]===_0x82bd('0x2d')){this[_0x82bd('0xa')][_0x25e36e[_0x82bd('0x17')]][_0x82bd('0x2e')]=_0x25e36e[_0x82bd('0x2e')];this[_0x82bd('0xa')][_0x25e36e[_0x82bd('0x17')]][_0x82bd('0x2f')]=_0x25e36e[_0x82bd('0x2f')];this[_0x82bd('0xa')][_0x25e36e[_0x82bd('0x17')]][_0x82bd('0x30')]=moment()[_0x82bd('0x1a')]('YYYY-MM-DD\x20HH:mm:ss');this['channels'][_0x25e36e['uniqueid']][_0x82bd('0x31')]=_0x82bd('0x32');logger['info'](_0x82bd('0x33'),_0x25e36e['uniqueid'],_0x25e36e['channel']['substring'](_0x25e36e[_0x82bd('0x1d')][_0x82bd('0x1e')]('/')+0x1,_0x25e36e[_0x82bd('0x1d')][_0x82bd('0x1e')]('-')));logger[_0x82bd('0x15')]('[%s][voiceDialReport][dialend]\x20sending\x20dialconnect\x20event:',_0x25e36e['uniqueid'],util['inspect'](this[_0x82bd('0xa')][_0x25e36e['uniqueid']],{'showHidden':![],'depth':null}));ami['emit'](_0x82bd('0x34'),this[_0x82bd('0xa')][_0x25e36e[_0x82bd('0x17')]]);}logger[_0x82bd('0x15')](_0x82bd('0x35'),_0x25e36e[_0x82bd('0x17')],util[_0x82bd('0x18')](this[_0x82bd('0xa')][_0x25e36e[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));this['emit']('voice:outbound',_0x82bd('0x36'),this[_0x82bd('0xa')][_0x25e36e['uniqueid']]);}}}catch(_0x4f066b){logger[_0x82bd('0x37')](_0x82bd('0x38'),_0x25e36e['uniqueid'],util[_0x82bd('0x18')](_0x4f066b,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x82bd('0x12')][_0x82bd('0x39')]=function(_0x2976f2){try{if(this[_0x82bd('0x10')](_0x2976f2)){logger[_0x82bd('0x15')](_0x82bd('0x3a'),_0x2976f2[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x2976f2,{'showHidden':![],'depth':null}));this[_0x82bd('0x3b')](_0x2976f2[_0x82bd('0x17')],_[_0x82bd('0x3c')](_0x2976f2['variable'])[0x0],_0x2976f2[_0x82bd('0x3d')]);if(this[_0x82bd('0x10')](_0x2976f2['variable'])&&this['isNotNull'](_0x2976f2[_0x82bd('0x3e')][_0x82bd('0x3f')])){if(_[_0x82bd('0x11')](this[_0x82bd('0xa')][_0x2976f2[_0x82bd('0x17')]])){this['channels'][_0x2976f2['uniqueid']]={'routeId':_0x2976f2[_0x82bd('0x3d')],'variables':this[_0x82bd('0x40')][_0x2976f2['uniqueid']],'motionChannel':_0x82bd('0x41')};logger['info'](_0x82bd('0x42'),_0x2976f2[_0x82bd('0x17')],_0x2976f2['variable'][_0x82bd('0x3f')],_[_0x82bd('0x3c')](_0x2976f2['variable'])[0x0],_0x2976f2['value']);logger[_0x82bd('0x15')]('[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:',_0x2976f2[_0x82bd('0x17')],util[_0x82bd('0x18')](this[_0x82bd('0xa')][_0x2976f2[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));this['emit']('voice:outbound',_0x82bd('0x36'),this[_0x82bd('0xa')][_0x2976f2['uniqueid']]);}}}}catch(_0x2cf686){logger[_0x82bd('0x37')](_0x82bd('0x43'),_0x2976f2['uniqueid'],util[_0x82bd('0x18')](_0x2cf686,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x82bd('0x12')][_0x82bd('0x3b')]=function(_0x122856,_0x42314b,_0x2c2cb9){var _0x2e97c3=[_0x82bd('0x44'),_0x82bd('0x45'),_0x82bd('0x46'),_0x82bd('0x47'),_0x82bd('0x48'),_0x82bd('0x49'),'rtpaudioqosrtt',_0x82bd('0x4a'),_0x82bd('0x4b'),'sipuri',_0x82bd('0x4c'),_0x82bd('0x4d'),_0x82bd('0x4e'),_0x82bd('0x4f'),'memberinterface','memberlastcall',_0x82bd('0x25'),'memberpenalty','memberrealtime'];if(!_[_0x82bd('0x50')](_0x42314b)&&!_['includes'](_0x2e97c3,_0x42314b)){if(_['isUndefined'](this[_0x82bd('0x40')][_0x122856])){this[_0x82bd('0x40')][_0x122856]={};}this[_0x82bd('0x40')][_0x122856][_0x42314b]=_0x2c2cb9;}};VoiceDialReport[_0x82bd('0x12')][_0x82bd('0x51')]=function(_0x1a7402){try{if(this[_0x82bd('0x10')](_0x1a7402)){logger[_0x82bd('0x15')](_0x82bd('0x52'),_0x1a7402[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x1a7402,{'showHidden':![],'depth':null}));if(this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]]){logger[_0x82bd('0x23')](_0x82bd('0x53'),_0x1a7402['uniqueid'],_0x1a7402[_0x82bd('0x54')]);this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x55')]=moment()[_0x82bd('0x1a')]('YYYY-MM-DD\x20HH:mm:ss');this['channels'][_0x1a7402['uniqueid']]['duration']=moment(this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x55')])[_0x82bd('0x56')](this['channels'][_0x1a7402['uniqueid']][_0x82bd('0x57')],_0x82bd('0x58'));this[_0x82bd('0xa')][_0x1a7402['uniqueid']][_0x82bd('0x31')]=_0x82bd('0x59');this[_0x82bd('0xc')][_0x82bd('0x5a')]+=0x1;if(this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x30')]){this[_0x82bd('0xc')][_0x82bd('0x5b')]+=0x1;this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x5c')]=moment(this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x30')])[_0x82bd('0x56')](this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]]['starttime'],_0x82bd('0x58'));this['channels'][_0x1a7402['uniqueid']][_0x82bd('0x5d')]=moment(this['channels'][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x55')])[_0x82bd('0x56')](this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]][_0x82bd('0x30')],_0x82bd('0x58'));this[_0x82bd('0xc')][_0x82bd('0x5e')]+=this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]]['holdtime']||0x0;this['outbound'][_0x82bd('0x5f')]+=this[_0x82bd('0xa')][_0x1a7402['uniqueid']]['billableseconds'];}this[_0x82bd('0xc')][_0x82bd('0x60')]+=this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]]['duration'];logger[_0x82bd('0x15')]('[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:',_0x1a7402[_0x82bd('0x17')],util[_0x82bd('0x18')](this['channels'][_0x1a7402[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));ami[_0x82bd('0x13')](_0x82bd('0x61'),this[_0x82bd('0xa')][_0x1a7402['uniqueid']]);logger[_0x82bd('0x15')](_0x82bd('0x62'),_0x1a7402[_0x82bd('0x17')],util[_0x82bd('0x18')](this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));ami[_0x82bd('0x13')](_0x82bd('0x63'),this[_0x82bd('0xa')][_0x1a7402['uniqueid']]);logger[_0x82bd('0x15')]('[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound:save\x20event:',_0x1a7402['uniqueid'],util[_0x82bd('0x18')](this[_0x82bd('0xa')][_0x1a7402['uniqueid']],{'showHidden':![],'depth':null}));this[_0x82bd('0x13')]('voice:outbound',_0x82bd('0x64'),this[_0x82bd('0xc')]);logger['info'](_0x82bd('0x65'),JSON[_0x82bd('0x66')](this['channels'][_0x1a7402['uniqueid']]));logger['debug'](_0x82bd('0x67'),_0x1a7402[_0x82bd('0x17')],util['inspect'](this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]],{'showHidden':![],'depth':null}));this['emit']('voice:outbound',_0x82bd('0x68'),this['channels'][_0x1a7402['uniqueid']]);delete this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x17')]];}else if(this[_0x82bd('0xa')][_0x1a7402[_0x82bd('0x69')]]){this[_0x82bd('0xa')][_0x1a7402['linkedid']][_0x82bd('0x17')]=this['channels'][_0x1a7402[_0x82bd('0x69')]]['destuniqueid'];}if(this[_0x82bd('0x40')][_0x1a7402['uniqueid']]){delete this['variables'][_0x1a7402[_0x82bd('0x17')]];}}}catch(_0x26e2a6){logger['error'](_0x82bd('0x6a'),_0x1a7402[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x26e2a6,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype']['syncNewExten']=function(_0x197368){try{if(this[_0x82bd('0x10')](_0x197368)){logger['debug'](_0x82bd('0x6b'),_0x197368[_0x82bd('0x17')],util['inspect'](_0x197368,{'showHidden':![],'depth':null}));if(_0x197368[_0x82bd('0x6c')][_0x82bd('0x6d')]()===_0x82bd('0x6e')){_0x197368[_0x82bd('0x6f')]=(_0x197368[_0x82bd('0x70')]||_0x197368[_0x82bd('0x6f')])['toLowerCase']();if(_[_0x82bd('0x71')](_0x197368[_0x82bd('0x6f')],_0x82bd('0x72'))){if(_['isUndefined'](this[_0x82bd('0xd')][_0x197368['uniqueid']]))this[_0x82bd('0xd')][_0x197368[_0x82bd('0x17')]]={};logger[_0x82bd('0x23')](_0x82bd('0x73'),_0x197368[_0x82bd('0x17')],_0x197368['application'],_0x197368[_0x82bd('0x6f')]);var _0x39b9d5=_0x197368['applicationdata'][_0x82bd('0x74')]('=');var _0x12dbeb=_0x39b9d5[0x0]['match'](/cdr\((.*)\)/);if(_0x12dbeb)this[_0x82bd('0xd')][_0x197368[_0x82bd('0x17')]][_0x12dbeb[0x1]]=_0x39b9d5[0x1];}}}}catch(_0x42d4c9){logger['error']('[%s][voiceDialReport][newexten]',_0x197368[_0x82bd('0x17')],util[_0x82bd('0x18')](_0x42d4c9,{'showHidden':![],'depth':null}));}};module[_0x82bd('0x75')]=VoiceDialReport;
\ No newline at end of file
+var _0x2eb2=['rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrttbridged','sipcallid','bridgepeer','bridgepvtcallid','membercalls','memberdynamic','memberlastcall','memberpenalty','memberrealtime','isNil','includes','syncHangup','[%s][voiceDialReport][hangup]\x20event:','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt','endtime','duration','diff','starttime','seconds','lastevent','complete','total','answered','holdtime','billableseconds','sumHoldTime','[%s][voiceDialReport][hangup]\x20sending\x20voiceDialReport\x20event:','[%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','linkedid','destuniqueid','[%s][voiceDialReport][newexten]\x20event:','toLowerCase','set','applicationdata','cdr(','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','application','split','match','exports','moment','util','ioredis','../../../config/environment','../../../config/logger','ami','redis','localhost','socket.io-emitter','channels','outboundChannels','outbound','applications','variables','dialbegin','syncDialBegin','dialend','varset','bind','hangup','prototype','isNotNull','isUndefined','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','format','YYYY-MM-DD\x20HH:mm:ss','called','substring','channel','lastIndexOf','privilege','info','[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called','membername','interface','debug','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','merge','emit','voice:outbound','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','inspect','custom:dialbegin','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]','syncVarSet','[%s][voiceDialReport][varset]\x20event:','addVariable','keys','variable','value','outboundrouteid','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','rtpaudioqos','rtpaudioqosbridged'];(function(_0x36d182,_0x5358c5){var _0x37e7fb=function(_0x46da30){while(--_0x46da30){_0x36d182['push'](_0x36d182['shift']());}};_0x37e7fb(++_0x5358c5);}(_0x2eb2,0x19f));var _0x22eb=function(_0x397cfb,_0xb8f317){_0x397cfb=_0x397cfb-0x0;var _0x15fed9=_0x2eb2[_0x397cfb];return _0x15fed9;};'use strict';var _=require('lodash');var moment=require(_0x22eb('0x0'));var util=require(_0x22eb('0x1'));var Redis=require(_0x22eb('0x2'));var config=require(_0x22eb('0x3'));var logger=require(_0x22eb('0x4'))(_0x22eb('0x5'));var ami=require('../ami');config[_0x22eb('0x6')]=_['defaults'](config['redis'],{'host':_0x22eb('0x7'),'port':0x18eb});var io=require(_0x22eb('0x8'))(new Redis(config[_0x22eb('0x6')]));function VoiceDialReport(_0x2a9850){this[_0x22eb('0x9')]=_0x2a9850[_0x22eb('0xa')];this[_0x22eb('0xb')]=_0x2a9850[_0x22eb('0xb')];this[_0x22eb('0xc')]={};this[_0x22eb('0xd')]={};ami['on'](_0x22eb('0xe'),this[_0x22eb('0xf')]['bind'](this));ami['on'](_0x22eb('0x10'),this['syncDialEnd']['bind'](this));ami['on'](_0x22eb('0x11'),this['syncVarSet'][_0x22eb('0x12')](this));ami['on'](_0x22eb('0x13'),this['syncHangup']['bind'](this));}VoiceDialReport[_0x22eb('0x14')][_0x22eb('0x15')]=function(_0x128d43){return _0x128d43!==null&&!_[_0x22eb('0x16')](_0x128d43);};VoiceDialReport[_0x22eb('0x14')]['emit']=function(_0x350ade,_0x53f14e,_0x1f5089){io['to'](_0x350ade)['emit'](_0x53f14e,_0x1f5089);};VoiceDialReport[_0x22eb('0x14')][_0x22eb('0xf')]=function(_0x53abbf){try{if(this['isNotNull'](_0x53abbf)){logger['debug'](_0x22eb('0x17'),_0x53abbf['uniqueid'],util['inspect'](_0x53abbf,{'showHidden':![],'depth':null}));if(this[_0x22eb('0x9')][_0x53abbf['uniqueid']]){_['merge'](this[_0x22eb('0x9')][_0x53abbf[_0x22eb('0x18')]],{'starttime':moment()[_0x22eb('0x19')](_0x22eb('0x1a')),'lastevent':_0x22eb('0x1b'),'interface':_0x53abbf['channel'][_0x22eb('0x1c')](0x0,_0x53abbf[_0x22eb('0x1d')][_0x22eb('0x1e')]('-')),'membername':_0x53abbf[_0x22eb('0x1d')][_0x22eb('0x1c')](_0x53abbf['channel'][_0x22eb('0x1e')]('/')+0x1,_0x53abbf[_0x22eb('0x1d')][_0x22eb('0x1e')]('-'))},_['omit'](_0x53abbf,['event',_0x22eb('0x1f')]));logger[_0x22eb('0x20')](_0x22eb('0x21'),_0x53abbf[_0x22eb('0x18')],this[_0x22eb('0x9')][_0x53abbf[_0x22eb('0x18')]][_0x22eb('0x22')],this['channels'][_0x53abbf[_0x22eb('0x18')]][_0x22eb('0x23')]);logger[_0x22eb('0x24')](_0x22eb('0x25'),_0x53abbf[_0x22eb('0x18')],util['inspect'](this[_0x22eb('0x9')][_0x53abbf[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));if(this[_0x22eb('0xc')][_0x53abbf['uniqueid']])_[_0x22eb('0x26')](this[_0x22eb('0x9')][_0x53abbf['uniqueid']],this[_0x22eb('0xc')][_0x53abbf[_0x22eb('0x18')]]);this[_0x22eb('0x27')](_0x22eb('0x28'),_0x22eb('0x29'),this['channels'][_0x53abbf['uniqueid']]);logger[_0x22eb('0x24')](_0x22eb('0x2a'),_0x53abbf[_0x22eb('0x18')],util[_0x22eb('0x2b')](this[_0x22eb('0x9')][_0x53abbf[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));ami[_0x22eb('0x27')](_0x22eb('0x2c'),this[_0x22eb('0x9')][_0x53abbf[_0x22eb('0x18')]]);}}}catch(_0x24e9dc){logger[_0x22eb('0x2d')]('[%s][voiceDialReport][dialbegin]',_0x53abbf[_0x22eb('0x18')],util['inspect'](_0x24e9dc,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x22eb('0x14')][_0x22eb('0x2e')]=function(_0xd564a9){try{if(this[_0x22eb('0x15')](_0xd564a9)){logger[_0x22eb('0x24')](_0x22eb('0x2f'),_0xd564a9[_0x22eb('0x18')],util[_0x22eb('0x2b')](_0xd564a9,{'showHidden':![],'depth':null}));if(this[_0x22eb('0x9')][_0xd564a9[_0x22eb('0x18')]]){this['channels'][_0xd564a9['uniqueid']][_0x22eb('0x30')]=_0xd564a9['dialstatus'];if(_0xd564a9['dialstatus']===_0x22eb('0x31')){this[_0x22eb('0x9')][_0xd564a9[_0x22eb('0x18')]][_0x22eb('0x32')]=_0xd564a9[_0x22eb('0x32')];this[_0x22eb('0x9')][_0xd564a9[_0x22eb('0x18')]][_0x22eb('0x33')]=_0xd564a9[_0x22eb('0x33')];this[_0x22eb('0x9')][_0xd564a9['uniqueid']][_0x22eb('0x34')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');this[_0x22eb('0x9')][_0xd564a9[_0x22eb('0x18')]]['lastevent']=_0x22eb('0x35');logger[_0x22eb('0x20')](_0x22eb('0x36'),_0xd564a9[_0x22eb('0x18')],_0xd564a9[_0x22eb('0x1d')]['substring'](_0xd564a9[_0x22eb('0x1d')][_0x22eb('0x1e')]('/')+0x1,_0xd564a9['channel'][_0x22eb('0x1e')]('-')));logger[_0x22eb('0x24')](_0x22eb('0x37'),_0xd564a9[_0x22eb('0x18')],util[_0x22eb('0x2b')](this['channels'][_0xd564a9['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x22eb('0x27')](_0x22eb('0x38'),this['channels'][_0xd564a9[_0x22eb('0x18')]]);}logger[_0x22eb('0x24')](_0x22eb('0x39'),_0xd564a9['uniqueid'],util[_0x22eb('0x2b')](this[_0x22eb('0x9')][_0xd564a9[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));this[_0x22eb('0x27')](_0x22eb('0x28'),_0x22eb('0x29'),this['channels'][_0xd564a9[_0x22eb('0x18')]]);}}}catch(_0x3d2d1d){logger['error'](_0x22eb('0x3a'),_0xd564a9[_0x22eb('0x18')],util[_0x22eb('0x2b')](_0x3d2d1d,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x22eb('0x14')][_0x22eb('0x3b')]=function(_0x3e8974){try{if(this[_0x22eb('0x15')](_0x3e8974)){logger[_0x22eb('0x24')](_0x22eb('0x3c'),_0x3e8974[_0x22eb('0x18')],util[_0x22eb('0x2b')](_0x3e8974,{'showHidden':![],'depth':null}));this[_0x22eb('0x3d')](_0x3e8974[_0x22eb('0x18')],_[_0x22eb('0x3e')](_0x3e8974[_0x22eb('0x3f')])[0x0],_0x3e8974[_0x22eb('0x40')]);if(this[_0x22eb('0x15')](_0x3e8974[_0x22eb('0x3f')])&&this['isNotNull'](_0x3e8974[_0x22eb('0x3f')][_0x22eb('0x41')])){if(_['isUndefined'](this[_0x22eb('0x9')][_0x3e8974[_0x22eb('0x18')]])){this['channels'][_0x3e8974['uniqueid']]={'routeId':_0x3e8974['value'],'variables':this[_0x22eb('0xd')][_0x3e8974[_0x22eb('0x18')]],'motionChannel':'voice'};logger['info'](_0x22eb('0x42'),_0x3e8974[_0x22eb('0x18')],_0x3e8974[_0x22eb('0x3f')][_0x22eb('0x41')],_[_0x22eb('0x3e')](_0x3e8974[_0x22eb('0x3f')])[0x0],_0x3e8974[_0x22eb('0x40')]);logger[_0x22eb('0x24')]('[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:',_0x3e8974['uniqueid'],util[_0x22eb('0x2b')](this['channels'][_0x3e8974[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));this['emit'](_0x22eb('0x28'),'voice_outbound_channel:save',this['channels'][_0x3e8974['uniqueid']]);}}}}catch(_0x517784){logger[_0x22eb('0x2d')]('[%s][voiceDialReport][varset]',_0x3e8974[_0x22eb('0x18')],util[_0x22eb('0x2b')](_0x517784,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x22eb('0x3d')]=function(_0x5df756,_0x109fc7,_0x9c490b){var _0x1df219=[_0x22eb('0x43'),_0x22eb('0x44'),_0x22eb('0x45'),_0x22eb('0x46'),_0x22eb('0x47'),_0x22eb('0x48'),'rtpaudioqosrtt',_0x22eb('0x49'),_0x22eb('0x4a'),'sipuri',_0x22eb('0x4b'),_0x22eb('0x4c'),_0x22eb('0x4d'),_0x22eb('0x4e'),'memberinterface',_0x22eb('0x4f'),_0x22eb('0x22'),_0x22eb('0x50'),_0x22eb('0x51')];if(!_[_0x22eb('0x52')](_0x109fc7)&&!_[_0x22eb('0x53')](_0x1df219,_0x109fc7)){if(_['isUndefined'](this[_0x22eb('0xd')][_0x5df756])){this['variables'][_0x5df756]={};}this[_0x22eb('0xd')][_0x5df756][_0x109fc7]=_0x9c490b;}};VoiceDialReport['prototype'][_0x22eb('0x54')]=function(_0x254b53){try{if(this[_0x22eb('0x15')](_0x254b53)){logger[_0x22eb('0x24')](_0x22eb('0x55'),_0x254b53['uniqueid'],util['inspect'](_0x254b53,{'showHidden':![],'depth':null}));if(this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]]){logger['info'](_0x22eb('0x56'),_0x254b53[_0x22eb('0x18')],_0x254b53[_0x22eb('0x57')]);this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x58')]=moment()[_0x22eb('0x19')](_0x22eb('0x1a'));this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x59')]=moment(this['channels'][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x58')])[_0x22eb('0x5a')](this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x5b')],_0x22eb('0x5c'));this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x5d')]=_0x22eb('0x5e');this[_0x22eb('0xb')][_0x22eb('0x5f')]+=0x1;if(this[_0x22eb('0x9')][_0x254b53['uniqueid']]['answertime']){this[_0x22eb('0xb')][_0x22eb('0x60')]+=0x1;this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x61')]=moment(this['channels'][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x34')])['diff'](this['channels'][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x5b')],_0x22eb('0x5c'));this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x62')]=moment(this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x58')])[_0x22eb('0x5a')](this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]][_0x22eb('0x34')],_0x22eb('0x5c'));this['outbound'][_0x22eb('0x63')]+=this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]]['holdtime']||0x0;this[_0x22eb('0xb')]['sumBillable']+=this[_0x22eb('0x9')][_0x254b53['uniqueid']][_0x22eb('0x62')];}this[_0x22eb('0xb')]['sumDuration']+=this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]]['duration'];logger['debug'](_0x22eb('0x64'),_0x254b53[_0x22eb('0x18')],util[_0x22eb('0x2b')](this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));ami[_0x22eb('0x27')]('custom:voiceDialReport',this[_0x22eb('0x9')][_0x254b53['uniqueid']]);logger['debug'](_0x22eb('0x65'),_0x254b53[_0x22eb('0x18')],util[_0x22eb('0x2b')](this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));ami[_0x22eb('0x27')](_0x22eb('0x66'),this[_0x22eb('0x9')][_0x254b53['uniqueid']]);logger['debug'](_0x22eb('0x67'),_0x254b53[_0x22eb('0x18')],util['inspect'](this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));this[_0x22eb('0x27')](_0x22eb('0x28'),_0x22eb('0x68'),this[_0x22eb('0xb')]);logger['info'](_0x22eb('0x69'),JSON[_0x22eb('0x6a')](this[_0x22eb('0x9')][_0x254b53['uniqueid']]));logger['debug'](_0x22eb('0x6b'),_0x254b53[_0x22eb('0x18')],util[_0x22eb('0x2b')](this['channels'][_0x254b53[_0x22eb('0x18')]],{'showHidden':![],'depth':null}));this['emit'](_0x22eb('0x28'),_0x22eb('0x6c'),this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x18')]]);delete this['channels'][_0x254b53[_0x22eb('0x18')]];}else if(this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x6d')]]){this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x6d')]][_0x22eb('0x18')]=this[_0x22eb('0x9')][_0x254b53[_0x22eb('0x6d')]][_0x22eb('0x6e')];}if(this[_0x22eb('0xd')][_0x254b53[_0x22eb('0x18')]]){delete this['variables'][_0x254b53[_0x22eb('0x18')]];}}}catch(_0x3d8abf){logger['error']('[%s][voiceDialReport][hangup]',_0x254b53['uniqueid'],util[_0x22eb('0x2b')](_0x3d8abf,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x22eb('0x14')]['syncNewExten']=function(_0x10726f){try{if(this[_0x22eb('0x15')](_0x10726f)){logger[_0x22eb('0x24')](_0x22eb('0x6f'),_0x10726f[_0x22eb('0x18')],util['inspect'](_0x10726f,{'showHidden':![],'depth':null}));if(_0x10726f['application'][_0x22eb('0x70')]()===_0x22eb('0x71')){_0x10726f[_0x22eb('0x72')]=(_0x10726f['appdata']||_0x10726f['applicationdata'])[_0x22eb('0x70')]();if(_['startsWith'](_0x10726f['applicationdata'],_0x22eb('0x73'))){if(_[_0x22eb('0x16')](this['applications'][_0x10726f['uniqueid']]))this[_0x22eb('0xc')][_0x10726f[_0x22eb('0x18')]]={};logger['info'](_0x22eb('0x74'),_0x10726f[_0x22eb('0x18')],_0x10726f[_0x22eb('0x75')],_0x10726f['applicationdata']);var _0x464f4f=_0x10726f[_0x22eb('0x72')][_0x22eb('0x76')]('=');var _0x2a0c73=_0x464f4f[0x0][_0x22eb('0x77')](/cdr\((.*)\)/);if(_0x2a0c73)this['applications'][_0x10726f[_0x22eb('0x18')]][_0x2a0c73[0x1]]=_0x464f4f[0x1];}}}}catch(_0x2ecc24){logger[_0x22eb('0x2d')]('[%s][voiceDialReport][newexten]',_0x10726f['uniqueid'],util[_0x22eb('0x2b')](_0x2ecc24,{'showHidden':![],'depth':null}));}};module[_0x22eb('0x78')]=VoiceDialReport;
\ No newline at end of file