Built motion from commit e6806ed6.|2.6.0
[motion2.git] / server / services / ami / report / voiceDialReport.js
index 3c61cbd..252de4b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xba34=['endtime','duration','diff','starttime','seconds','complete','total','answertime','holdtime','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','[%s][voiceDialReport][hangup]\x20sending\x20voice_outbound_channel:remove\x20event:','voice_outbound_channel:remove','linkedid','destuniqueid','[%s][voiceDialReport][hangup]','syncNewExten','[%s][voiceDialReport][newexten]\x20event:','application','set','appdata','applicationdata','toLowerCase','startsWith','cdr(','split','[%s][voiceDialReport][newexten]','lodash','moment','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','outboundChannels','outbound','applications','variables','dialbegin','syncDialBegin','bind','dialend','syncDialEnd','syncVarSet','syncHangup','prototype','isUndefined','emit','isNotNull','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','inspect','merge','channels','YYYY-MM-DD\x20HH:mm:ss','called','channel','substring','lastIndexOf','omit','event','privilege','info','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','voice:outbound','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','custom:dialbegin','[%s][voiceDialReport][dialbegin]','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','connectedlinename','format','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:','error','[%s][voiceDialReport][dialend]','[%s][voiceDialReport][varset]\x20event:','value','variable','outboundrouteid','voice','[%s][voiceDialReport][varset]\x20outboundrouteid:%s\x20variable:%s\x20value:%s','keys','[%s][voiceDialReport][varset]\x20sending\x20voice_outbound_channel:save\x20event:','addVariable','rtpaudioqos','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqoslossbridged','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','sipuri','bridgepvtcallid','membercalls','memberinterface','memberlastcall','memberpenalty','memberrealtime','isNil','includes','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt'];(function(_0x2ec461,_0x5f588a){var _0x28603d=function(_0x21114b){while(--_0x21114b){_0x2ec461['push'](_0x2ec461['shift']());}};_0x28603d(++_0x5f588a);}(_0xba34,0x119));var _0x4ba3=function(_0x4b924f,_0x3ea40f){_0x4b924f=_0x4b924f-0x0;var _0x26167b=_0xba34[_0x4b924f];return _0x26167b;};'use strict';var _=require(_0x4ba3('0x0'));var moment=require(_0x4ba3('0x1'));var util=require(_0x4ba3('0x2'));var Redis=require(_0x4ba3('0x3'));var config=require(_0x4ba3('0x4'));var logger=require('../../../config/logger')('ami');var ami=require('../ami');config[_0x4ba3('0x5')]=_[_0x4ba3('0x6')](config[_0x4ba3('0x5')],{'host':_0x4ba3('0x7'),'port':0x18eb});var io=require(_0x4ba3('0x8'))(new Redis(config[_0x4ba3('0x5')]));function VoiceDialReport(_0xe5f99a){this['channels']=_0xe5f99a[_0x4ba3('0x9')];this[_0x4ba3('0xa')]=_0xe5f99a[_0x4ba3('0xa')];this[_0x4ba3('0xb')]={};this[_0x4ba3('0xc')]={};ami['on'](_0x4ba3('0xd'),this[_0x4ba3('0xe')][_0x4ba3('0xf')](this));ami['on'](_0x4ba3('0x10'),this[_0x4ba3('0x11')][_0x4ba3('0xf')](this));ami['on']('varset',this[_0x4ba3('0x12')][_0x4ba3('0xf')](this));ami['on']('hangup',this[_0x4ba3('0x13')]['bind'](this));}VoiceDialReport[_0x4ba3('0x14')]['isNotNull']=function(_0x256f02){return _0x256f02!==null&&!_[_0x4ba3('0x15')](_0x256f02);};VoiceDialReport[_0x4ba3('0x14')][_0x4ba3('0x16')]=function(_0x2bc796,_0x3d2ace,_0x3a74f7){io['to'](_0x2bc796)[_0x4ba3('0x16')](_0x3d2ace,_0x3a74f7);};VoiceDialReport[_0x4ba3('0x14')][_0x4ba3('0xe')]=function(_0x36638b){try{if(this[_0x4ba3('0x17')](_0x36638b)){logger[_0x4ba3('0x18')](_0x4ba3('0x19'),_0x36638b[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](_0x36638b,{'showHidden':![],'depth':null}));if(this['channels'][_0x36638b[_0x4ba3('0x1a')]]){_[_0x4ba3('0x1c')](this[_0x4ba3('0x1d')][_0x36638b[_0x4ba3('0x1a')]],{'starttime':moment()['format'](_0x4ba3('0x1e')),'lastevent':_0x4ba3('0x1f'),'interface':_0x36638b[_0x4ba3('0x20')][_0x4ba3('0x21')](0x0,_0x36638b[_0x4ba3('0x20')][_0x4ba3('0x22')]('-')),'membername':_0x36638b['channel']['substring'](_0x36638b[_0x4ba3('0x20')]['lastIndexOf']('/')+0x1,_0x36638b[_0x4ba3('0x20')][_0x4ba3('0x22')]('-'))},_[_0x4ba3('0x23')](_0x36638b,[_0x4ba3('0x24'),_0x4ba3('0x25')]));logger[_0x4ba3('0x26')]('[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called',_0x36638b[_0x4ba3('0x1a')],this[_0x4ba3('0x1d')][_0x36638b['uniqueid']][_0x4ba3('0x27')],this['channels'][_0x36638b[_0x4ba3('0x1a')]][_0x4ba3('0x28')]);logger[_0x4ba3('0x18')](_0x4ba3('0x29'),_0x36638b[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x36638b[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));if(this[_0x4ba3('0xb')][_0x36638b[_0x4ba3('0x1a')]])_['merge'](this[_0x4ba3('0x1d')][_0x36638b[_0x4ba3('0x1a')]],this[_0x4ba3('0xb')][_0x36638b['uniqueid']]);this[_0x4ba3('0x16')](_0x4ba3('0x2a'),_0x4ba3('0x2b'),this['channels'][_0x36638b[_0x4ba3('0x1a')]]);logger[_0x4ba3('0x18')](_0x4ba3('0x2c'),_0x36638b[_0x4ba3('0x1a')],util['inspect'](this['channels'][_0x36638b[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x4ba3('0x16')](_0x4ba3('0x2d'),this[_0x4ba3('0x1d')][_0x36638b[_0x4ba3('0x1a')]]);}}}catch(_0x11f88f){logger['error'](_0x4ba3('0x2e'),_0x36638b[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](_0x11f88f,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x4ba3('0x14')][_0x4ba3('0x11')]=function(_0x1a7a2c){try{if(this[_0x4ba3('0x17')](_0x1a7a2c)){logger[_0x4ba3('0x18')](_0x4ba3('0x2f'),_0x1a7a2c[_0x4ba3('0x1a')],util['inspect'](_0x1a7a2c,{'showHidden':![],'depth':null}));if(this['channels'][_0x1a7a2c['uniqueid']]){this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]][_0x4ba3('0x30')]=_0x1a7a2c[_0x4ba3('0x30')];if(_0x1a7a2c[_0x4ba3('0x30')]===_0x4ba3('0x31')){this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]][_0x4ba3('0x32')]=_0x1a7a2c[_0x4ba3('0x32')];this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]]['connectedlinename']=_0x1a7a2c[_0x4ba3('0x33')];this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]]['answertime']=moment()[_0x4ba3('0x34')]('YYYY-MM-DD\x20HH:mm:ss');this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]][_0x4ba3('0x35')]=_0x4ba3('0x36');logger[_0x4ba3('0x26')](_0x4ba3('0x37'),_0x1a7a2c['uniqueid'],_0x1a7a2c[_0x4ba3('0x20')][_0x4ba3('0x21')](_0x1a7a2c[_0x4ba3('0x20')]['lastIndexOf']('/')+0x1,_0x1a7a2c[_0x4ba3('0x20')][_0x4ba3('0x22')]('-')));logger['debug'](_0x4ba3('0x38'),_0x1a7a2c['uniqueid'],util['inspect'](this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x4ba3('0x16')](_0x4ba3('0x39'),this[_0x4ba3('0x1d')][_0x1a7a2c['uniqueid']]);}logger[_0x4ba3('0x18')](_0x4ba3('0x3a'),_0x1a7a2c[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));this[_0x4ba3('0x16')](_0x4ba3('0x2a'),'voice_outbound_channel:save',this[_0x4ba3('0x1d')][_0x1a7a2c[_0x4ba3('0x1a')]]);}}}catch(_0x3cb07f){logger[_0x4ba3('0x3b')](_0x4ba3('0x3c'),_0x1a7a2c[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](_0x3cb07f,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x4ba3('0x14')][_0x4ba3('0x12')]=function(_0xa692c6){try{if(this[_0x4ba3('0x17')](_0xa692c6)){logger[_0x4ba3('0x18')](_0x4ba3('0x3d'),_0xa692c6[_0x4ba3('0x1a')],util['inspect'](_0xa692c6,{'showHidden':![],'depth':null}));this['addVariable'](_0xa692c6['uniqueid'],_['keys'](_0xa692c6['variable'])[0x0],_0xa692c6[_0x4ba3('0x3e')]);if(this['isNotNull'](_0xa692c6[_0x4ba3('0x3f')])&&this['isNotNull'](_0xa692c6[_0x4ba3('0x3f')][_0x4ba3('0x40')])){if(_[_0x4ba3('0x15')](this[_0x4ba3('0x1d')][_0xa692c6[_0x4ba3('0x1a')]])){this['channels'][_0xa692c6[_0x4ba3('0x1a')]]={'routeId':_0xa692c6['value'],'variables':this[_0x4ba3('0xc')][_0xa692c6['uniqueid']],'motionChannel':_0x4ba3('0x41')};logger[_0x4ba3('0x26')](_0x4ba3('0x42'),_0xa692c6[_0x4ba3('0x1a')],_0xa692c6[_0x4ba3('0x3f')][_0x4ba3('0x40')],_[_0x4ba3('0x43')](_0xa692c6['variable'])[0x0],_0xa692c6[_0x4ba3('0x3e')]);logger[_0x4ba3('0x18')](_0x4ba3('0x44'),_0xa692c6[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this['channels'][_0xa692c6['uniqueid']],{'showHidden':![],'depth':null}));this[_0x4ba3('0x16')](_0x4ba3('0x2a'),_0x4ba3('0x2b'),this['channels'][_0xa692c6[_0x4ba3('0x1a')]]);}}}}catch(_0xfd30a0){logger[_0x4ba3('0x3b')]('[%s][voiceDialReport][varset]',_0xa692c6['uniqueid'],util[_0x4ba3('0x1b')](_0xfd30a0,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x4ba3('0x45')]=function(_0x1b9f76,_0x1aab37,_0x30eb6e){var _0x3d7b9d=[_0x4ba3('0x46'),'rtpaudioqosbridged',_0x4ba3('0x47'),_0x4ba3('0x48'),'rtpaudioqosloss',_0x4ba3('0x49'),_0x4ba3('0x4a'),_0x4ba3('0x4b'),_0x4ba3('0x4c'),_0x4ba3('0x4d'),'bridgepeer',_0x4ba3('0x4e'),_0x4ba3('0x4f'),'memberdynamic',_0x4ba3('0x50'),_0x4ba3('0x51'),_0x4ba3('0x27'),_0x4ba3('0x52'),_0x4ba3('0x53')];if(!_[_0x4ba3('0x54')](_0x1aab37)&&!_[_0x4ba3('0x55')](_0x3d7b9d,_0x1aab37)){if(_[_0x4ba3('0x15')](this[_0x4ba3('0xc')][_0x1b9f76])){this[_0x4ba3('0xc')][_0x1b9f76]={};}this[_0x4ba3('0xc')][_0x1b9f76][_0x1aab37]=_0x30eb6e;}};VoiceDialReport[_0x4ba3('0x14')][_0x4ba3('0x13')]=function(_0x22890a){try{if(this[_0x4ba3('0x17')](_0x22890a)){logger['debug']('[%s][voiceDialReport][hangup]\x20event:',_0x22890a['uniqueid'],util[_0x4ba3('0x1b')](_0x22890a,{'showHidden':![],'depth':null}));if(this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]]){logger[_0x4ba3('0x26')](_0x4ba3('0x56'),_0x22890a['uniqueid'],_0x22890a[_0x4ba3('0x57')]);this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x58')]=moment()[_0x4ba3('0x34')](_0x4ba3('0x1e'));this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x59')]=moment(this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x58')])[_0x4ba3('0x5a')](this[_0x4ba3('0x1d')][_0x22890a['uniqueid']][_0x4ba3('0x5b')],_0x4ba3('0x5c'));this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x35')]=_0x4ba3('0x5d');this[_0x4ba3('0xa')][_0x4ba3('0x5e')]+=0x1;if(this['channels'][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x5f')]){this[_0x4ba3('0xa')]['answered']+=0x1;this[_0x4ba3('0x1d')][_0x22890a['uniqueid']][_0x4ba3('0x60')]=moment(this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x5f')])[_0x4ba3('0x5a')](this['channels'][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x5b')],_0x4ba3('0x5c'));this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]]['billableseconds']=moment(this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x58')])[_0x4ba3('0x5a')](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x5f')],_0x4ba3('0x5c'));this[_0x4ba3('0xa')][_0x4ba3('0x61')]+=this[_0x4ba3('0x1d')][_0x22890a['uniqueid']][_0x4ba3('0x60')]||0x0;this[_0x4ba3('0xa')]['sumBillable']+=this['channels'][_0x22890a[_0x4ba3('0x1a')]][_0x4ba3('0x62')];}this['outbound'][_0x4ba3('0x63')]+=this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]]['duration'];logger[_0x4ba3('0x18')](_0x4ba3('0x64'),_0x22890a[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));ami['emit'](_0x4ba3('0x65'),this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]]);logger['debug'](_0x4ba3('0x66'),_0x22890a[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));ami[_0x4ba3('0x16')](_0x4ba3('0x67'),this[_0x4ba3('0x1d')][_0x22890a['uniqueid']]);logger['debug'](_0x4ba3('0x68'),_0x22890a['uniqueid'],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));this['emit'](_0x4ba3('0x2a'),_0x4ba3('0x69'),this[_0x4ba3('0xa')]);logger['info'](_0x4ba3('0x6a'),JSON['stringify'](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]]));logger['debug'](_0x4ba3('0x6b'),_0x22890a[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]],{'showHidden':![],'depth':null}));this[_0x4ba3('0x16')](_0x4ba3('0x2a'),_0x4ba3('0x6c'),this[_0x4ba3('0x1d')][_0x22890a['uniqueid']]);delete this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x1a')]];}else if(this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x6d')]]){this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x6d')]][_0x4ba3('0x1a')]=this[_0x4ba3('0x1d')][_0x22890a[_0x4ba3('0x6d')]][_0x4ba3('0x6e')];}if(this[_0x4ba3('0xc')][_0x22890a[_0x4ba3('0x1a')]]){delete this['variables'][_0x22890a[_0x4ba3('0x1a')]];}}}catch(_0x135068){logger['error'](_0x4ba3('0x6f'),_0x22890a[_0x4ba3('0x1a')],util['inspect'](_0x135068,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x4ba3('0x70')]=function(_0x14a6d9){try{if(this[_0x4ba3('0x17')](_0x14a6d9)){logger[_0x4ba3('0x18')](_0x4ba3('0x71'),_0x14a6d9[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](_0x14a6d9,{'showHidden':![],'depth':null}));if(_0x14a6d9[_0x4ba3('0x72')]['toLowerCase']()===_0x4ba3('0x73')){_0x14a6d9['applicationdata']=(_0x14a6d9[_0x4ba3('0x74')]||_0x14a6d9[_0x4ba3('0x75')])[_0x4ba3('0x76')]();if(_[_0x4ba3('0x77')](_0x14a6d9[_0x4ba3('0x75')],_0x4ba3('0x78'))){if(_[_0x4ba3('0x15')](this[_0x4ba3('0xb')][_0x14a6d9['uniqueid']]))this[_0x4ba3('0xb')][_0x14a6d9[_0x4ba3('0x1a')]]={};logger[_0x4ba3('0x26')]('[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s',_0x14a6d9[_0x4ba3('0x1a')],_0x14a6d9[_0x4ba3('0x72')],_0x14a6d9[_0x4ba3('0x75')]);var _0x39d428=_0x14a6d9[_0x4ba3('0x75')][_0x4ba3('0x79')]('=');var _0x3ea460=_0x39d428[0x0]['match'](/cdr\((.*)\)/);if(_0x3ea460)this['applications'][_0x14a6d9[_0x4ba3('0x1a')]][_0x3ea460[0x1]]=_0x39d428[0x1];}}}}catch(_0x5106a8){logger[_0x4ba3('0x3b')](_0x4ba3('0x7a'),_0x14a6d9[_0x4ba3('0x1a')],util[_0x4ba3('0x1b')](_0x5106a8,{'showHidden':![],'depth':null}));}};module['exports']=VoiceDialReport;
\ No newline at end of file
+var _0x8ef6=['error','[%s][voiceDialReport][hangup]','application','toLowerCase','appdata','applicationdata','[%s][voiceDialReport][newexten]\x20application:%s\x20appdata:%s','split','lodash','moment','util','ioredis','../../../config/environment','../../../config/logger','ami','redis','defaults','localhost','channels','outboundChannels','outbound','applications','variables','dialbegin','syncDialBegin','bind','dialend','syncDialEnd','varset','syncVarSet','syncHangup','prototype','isNotNull','isUndefined','emit','debug','[%s][voiceDialReport][dialbegin]\x20event:','uniqueid','called','channel','substring','lastIndexOf','omit','event','privilege','membername','interface','[%s][voiceDialReport][dialbegin]\x20sending\x20voice_outbound_channel:save\x20event:','inspect','voice_outbound_channel:save','[%s][voiceDialReport][dialbegin]\x20sending\x20dialbegin\x20event:','custom:dialbegin','[%s][voiceDialReport][dialbegin]','[%s][voiceDialReport][dialend]\x20event:','dialstatus','ANSWER','connectedlinenum','connectedlinename','format','lastevent','connect','info','[%s][voiceDialReport][dialend]\x20agent:%s\x20lastevent:connect','custom:dialconnect','[%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]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosloss','rtpaudioqosrtt','rtpaudioqosrttbridged','sipcallid','bridgepeer','bridgepvtcallid','membercalls','memberinterface','memberpenalty','isNil','includes','[%s][voiceDialReport][hangup]\x20reason:%s\x20lasteevent:complete','cause-txt','duration','endtime','starttime','seconds','complete','total','answertime','answered','holdtime','diff','billableseconds','sumBillable','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:','linkedid','destuniqueid'];(function(_0x345b6d,_0x538227){var _0x219dc7=function(_0x2d6629){while(--_0x2d6629){_0x345b6d['push'](_0x345b6d['shift']());}};_0x219dc7(++_0x538227);}(_0x8ef6,0xf2));var _0x68ef=function(_0x33314e,_0x303a23){_0x33314e=_0x33314e-0x0;var _0x568f55=_0x8ef6[_0x33314e];return _0x568f55;};'use strict';var _=require(_0x68ef('0x0'));var moment=require(_0x68ef('0x1'));var util=require(_0x68ef('0x2'));var Redis=require(_0x68ef('0x3'));var config=require(_0x68ef('0x4'));var logger=require(_0x68ef('0x5'))(_0x68ef('0x6'));var ami=require('../ami');config[_0x68ef('0x7')]=_[_0x68ef('0x8')](config[_0x68ef('0x7')],{'host':_0x68ef('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function VoiceDialReport(_0x3c2ff3){this[_0x68ef('0xa')]=_0x3c2ff3[_0x68ef('0xb')];this['outbound']=_0x3c2ff3[_0x68ef('0xc')];this[_0x68ef('0xd')]={};this[_0x68ef('0xe')]={};ami['on'](_0x68ef('0xf'),this[_0x68ef('0x10')][_0x68ef('0x11')](this));ami['on'](_0x68ef('0x12'),this[_0x68ef('0x13')][_0x68ef('0x11')](this));ami['on'](_0x68ef('0x14'),this[_0x68ef('0x15')][_0x68ef('0x11')](this));ami['on']('hangup',this[_0x68ef('0x16')][_0x68ef('0x11')](this));}VoiceDialReport[_0x68ef('0x17')][_0x68ef('0x18')]=function(_0x40f253){return _0x40f253!==null&&!_[_0x68ef('0x19')](_0x40f253);};VoiceDialReport['prototype'][_0x68ef('0x1a')]=function(_0xc50cce,_0x2657c5,_0x47fbb5){io['to'](_0xc50cce)[_0x68ef('0x1a')](_0x2657c5,_0x47fbb5);};VoiceDialReport[_0x68ef('0x17')][_0x68ef('0x10')]=function(_0x5005ba){try{if(this[_0x68ef('0x18')](_0x5005ba)){logger[_0x68ef('0x1b')](_0x68ef('0x1c'),_0x5005ba[_0x68ef('0x1d')],util['inspect'](_0x5005ba,{'showHidden':![],'depth':null}));if(this[_0x68ef('0xa')][_0x5005ba['uniqueid']]){_['merge'](this[_0x68ef('0xa')][_0x5005ba[_0x68ef('0x1d')]],{'starttime':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastevent':_0x68ef('0x1e'),'interface':_0x5005ba[_0x68ef('0x1f')][_0x68ef('0x20')](0x0,_0x5005ba['channel'][_0x68ef('0x21')]('-')),'membername':_0x5005ba[_0x68ef('0x1f')][_0x68ef('0x20')](_0x5005ba['channel'][_0x68ef('0x21')]('/')+0x1,_0x5005ba[_0x68ef('0x1f')]['lastIndexOf']('-'))},_[_0x68ef('0x22')](_0x5005ba,[_0x68ef('0x23'),_0x68ef('0x24')]));logger['info']('[%s][voiceDialReport][dialbegin]\x20agent:%s\x20interface:%s\x20lastevent:called',_0x5005ba['uniqueid'],this[_0x68ef('0xa')][_0x5005ba[_0x68ef('0x1d')]][_0x68ef('0x25')],this[_0x68ef('0xa')][_0x5005ba[_0x68ef('0x1d')]][_0x68ef('0x26')]);logger[_0x68ef('0x1b')](_0x68ef('0x27'),_0x5005ba[_0x68ef('0x1d')],util[_0x68ef('0x28')](this['channels'][_0x5005ba[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));if(this['applications'][_0x5005ba['uniqueid']])_['merge'](this[_0x68ef('0xa')][_0x5005ba[_0x68ef('0x1d')]],this[_0x68ef('0xd')][_0x5005ba[_0x68ef('0x1d')]]);this['emit']('voice:outbound',_0x68ef('0x29'),this[_0x68ef('0xa')][_0x5005ba[_0x68ef('0x1d')]]);logger[_0x68ef('0x1b')](_0x68ef('0x2a'),_0x5005ba[_0x68ef('0x1d')],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x5005ba['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x68ef('0x1a')](_0x68ef('0x2b'),this[_0x68ef('0xa')][_0x5005ba['uniqueid']]);}}}catch(_0x370a8f){logger['error'](_0x68ef('0x2c'),_0x5005ba[_0x68ef('0x1d')],util['inspect'](_0x370a8f,{'showHidden':![],'depth':null}));}};VoiceDialReport['prototype'][_0x68ef('0x13')]=function(_0x5fa72a){try{if(this['isNotNull'](_0x5fa72a)){logger[_0x68ef('0x1b')](_0x68ef('0x2d'),_0x5fa72a[_0x68ef('0x1d')],util[_0x68ef('0x28')](_0x5fa72a,{'showHidden':![],'depth':null}));if(this['channels'][_0x5fa72a[_0x68ef('0x1d')]]){this[_0x68ef('0xa')][_0x5fa72a['uniqueid']][_0x68ef('0x2e')]=_0x5fa72a['dialstatus'];if(_0x5fa72a[_0x68ef('0x2e')]===_0x68ef('0x2f')){this['channels'][_0x5fa72a[_0x68ef('0x1d')]]['connectedlinenum']=_0x5fa72a[_0x68ef('0x30')];this['channels'][_0x5fa72a[_0x68ef('0x1d')]][_0x68ef('0x31')]=_0x5fa72a[_0x68ef('0x31')];this['channels'][_0x5fa72a[_0x68ef('0x1d')]]['answertime']=moment()[_0x68ef('0x32')]('YYYY-MM-DD\x20HH:mm:ss');this[_0x68ef('0xa')][_0x5fa72a[_0x68ef('0x1d')]][_0x68ef('0x33')]=_0x68ef('0x34');logger[_0x68ef('0x35')](_0x68ef('0x36'),_0x5fa72a['uniqueid'],_0x5fa72a[_0x68ef('0x1f')][_0x68ef('0x20')](_0x5fa72a[_0x68ef('0x1f')]['lastIndexOf']('/')+0x1,_0x5fa72a[_0x68ef('0x1f')][_0x68ef('0x21')]('-')));logger[_0x68ef('0x1b')]('[%s][voiceDialReport][dialend]\x20sending\x20dialconnect\x20event:',_0x5fa72a['uniqueid'],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x5fa72a[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));ami[_0x68ef('0x1a')](_0x68ef('0x37'),this[_0x68ef('0xa')][_0x5fa72a[_0x68ef('0x1d')]]);}logger['debug'](_0x68ef('0x38'),_0x5fa72a[_0x68ef('0x1d')],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x5fa72a['uniqueid']],{'showHidden':![],'depth':null}));this[_0x68ef('0x1a')](_0x68ef('0x39'),_0x68ef('0x29'),this[_0x68ef('0xa')][_0x5fa72a[_0x68ef('0x1d')]]);}}}catch(_0x3b00ea){logger['error'](_0x68ef('0x3a'),_0x5fa72a[_0x68ef('0x1d')],util[_0x68ef('0x28')](_0x3b00ea,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x68ef('0x17')][_0x68ef('0x15')]=function(_0x32d5c3){try{if(this[_0x68ef('0x18')](_0x32d5c3)){logger[_0x68ef('0x1b')](_0x68ef('0x3b'),_0x32d5c3['uniqueid'],util[_0x68ef('0x28')](_0x32d5c3,{'showHidden':![],'depth':null}));this[_0x68ef('0x3c')](_0x32d5c3[_0x68ef('0x1d')],_[_0x68ef('0x3d')](_0x32d5c3[_0x68ef('0x3e')])[0x0],_0x32d5c3[_0x68ef('0x3f')]);if(this[_0x68ef('0x18')](_0x32d5c3['variable'])&&this[_0x68ef('0x18')](_0x32d5c3['variable'][_0x68ef('0x40')])){if(_[_0x68ef('0x19')](this[_0x68ef('0xa')][_0x32d5c3[_0x68ef('0x1d')]])){this['channels'][_0x32d5c3[_0x68ef('0x1d')]]={'routeId':_0x32d5c3['value'],'variables':this[_0x68ef('0xe')][_0x32d5c3['uniqueid']],'motionChannel':_0x68ef('0x41')};logger[_0x68ef('0x35')](_0x68ef('0x42'),_0x32d5c3['uniqueid'],_0x32d5c3['variable'][_0x68ef('0x40')],_[_0x68ef('0x3d')](_0x32d5c3['variable'])[0x0],_0x32d5c3['value']);logger['debug'](_0x68ef('0x43'),_0x32d5c3[_0x68ef('0x1d')],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x32d5c3[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));this['emit']('voice:outbound',_0x68ef('0x29'),this[_0x68ef('0xa')][_0x32d5c3[_0x68ef('0x1d')]]);}}}}catch(_0x34324a){logger['error'](_0x68ef('0x44'),_0x32d5c3[_0x68ef('0x1d')],util[_0x68ef('0x28')](_0x34324a,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x68ef('0x17')]['addVariable']=function(_0x5705f7,_0x16e247,_0x3c3074){var _0x566e7c=[_0x68ef('0x45'),_0x68ef('0x46'),_0x68ef('0x47'),_0x68ef('0x48'),_0x68ef('0x49'),'rtpaudioqoslossbridged',_0x68ef('0x4a'),_0x68ef('0x4b'),_0x68ef('0x4c'),'sipuri',_0x68ef('0x4d'),_0x68ef('0x4e'),_0x68ef('0x4f'),'memberdynamic',_0x68ef('0x50'),'memberlastcall','membername',_0x68ef('0x51'),'memberrealtime'];if(!_[_0x68ef('0x52')](_0x16e247)&&!_[_0x68ef('0x53')](_0x566e7c,_0x16e247)){if(_[_0x68ef('0x19')](this[_0x68ef('0xe')][_0x5705f7])){this[_0x68ef('0xe')][_0x5705f7]={};}this[_0x68ef('0xe')][_0x5705f7][_0x16e247]=_0x3c3074;}};VoiceDialReport[_0x68ef('0x17')][_0x68ef('0x16')]=function(_0x2b35f4){try{if(this[_0x68ef('0x18')](_0x2b35f4)){logger['debug']('[%s][voiceDialReport][hangup]\x20event:',_0x2b35f4[_0x68ef('0x1d')],util[_0x68ef('0x28')](_0x2b35f4,{'showHidden':![],'depth':null}));if(this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]){logger[_0x68ef('0x35')](_0x68ef('0x54'),_0x2b35f4[_0x68ef('0x1d')],_0x2b35f4[_0x68ef('0x55')]);this[_0x68ef('0xa')][_0x2b35f4['uniqueid']]['endtime']=moment()[_0x68ef('0x32')]('YYYY-MM-DD\x20HH:mm:ss');this[_0x68ef('0xa')][_0x2b35f4['uniqueid']][_0x68ef('0x56')]=moment(this[_0x68ef('0xa')][_0x2b35f4['uniqueid']][_0x68ef('0x57')])['diff'](this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]][_0x68ef('0x58')],_0x68ef('0x59'));this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]['lastevent']=_0x68ef('0x5a');this[_0x68ef('0xc')][_0x68ef('0x5b')]+=0x1;if(this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]][_0x68ef('0x5c')]){this['outbound'][_0x68ef('0x5d')]+=0x1;this[_0x68ef('0xa')][_0x2b35f4['uniqueid']][_0x68ef('0x5e')]=moment(this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]['answertime'])[_0x68ef('0x5f')](this['channels'][_0x2b35f4['uniqueid']][_0x68ef('0x58')],'seconds');this[_0x68ef('0xa')][_0x2b35f4['uniqueid']][_0x68ef('0x60')]=moment(this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]][_0x68ef('0x57')])[_0x68ef('0x5f')](this[_0x68ef('0xa')][_0x2b35f4['uniqueid']][_0x68ef('0x5c')],'seconds');this[_0x68ef('0xc')]['sumHoldTime']+=this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]][_0x68ef('0x5e')]||0x0;this[_0x68ef('0xc')][_0x68ef('0x61')]+=this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]['billableseconds'];}this[_0x68ef('0xc')][_0x68ef('0x62')]+=this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]][_0x68ef('0x56')];logger['debug'](_0x68ef('0x63'),_0x2b35f4['uniqueid'],util[_0x68ef('0x28')](this['channels'][_0x2b35f4['uniqueid']],{'showHidden':![],'depth':null}));ami[_0x68ef('0x1a')](_0x68ef('0x64'),this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]);logger['debug'](_0x68ef('0x65'),_0x2b35f4['uniqueid'],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));ami['emit']('custom:dialend',this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]);logger[_0x68ef('0x1b')](_0x68ef('0x66'),_0x2b35f4['uniqueid'],util[_0x68ef('0x28')](this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));this[_0x68ef('0x1a')]('voice:outbound',_0x68ef('0x67'),this['outbound']);logger[_0x68ef('0x35')](_0x68ef('0x68'),JSON[_0x68ef('0x69')](this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]]));logger['debug'](_0x68ef('0x6a'),_0x2b35f4[_0x68ef('0x1d')],util[_0x68ef('0x28')](this['channels'][_0x2b35f4[_0x68ef('0x1d')]],{'showHidden':![],'depth':null}));this['emit'](_0x68ef('0x39'),'voice_outbound_channel:remove',this['channels'][_0x2b35f4[_0x68ef('0x1d')]]);delete this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x1d')]];}else if(this[_0x68ef('0xa')][_0x2b35f4['linkedid']]){this[_0x68ef('0xa')][_0x2b35f4[_0x68ef('0x6b')]][_0x68ef('0x1d')]=this['channels'][_0x2b35f4[_0x68ef('0x6b')]][_0x68ef('0x6c')];}if(this[_0x68ef('0xe')][_0x2b35f4[_0x68ef('0x1d')]]){delete this[_0x68ef('0xe')][_0x2b35f4[_0x68ef('0x1d')]];}}}catch(_0x139557){logger[_0x68ef('0x6d')](_0x68ef('0x6e'),_0x2b35f4[_0x68ef('0x1d')],util[_0x68ef('0x28')](_0x139557,{'showHidden':![],'depth':null}));}};VoiceDialReport[_0x68ef('0x17')]['syncNewExten']=function(_0x15378c){try{if(this[_0x68ef('0x18')](_0x15378c)){logger['debug']('[%s][voiceDialReport][newexten]\x20event:',_0x15378c[_0x68ef('0x1d')],util['inspect'](_0x15378c,{'showHidden':![],'depth':null}));if(_0x15378c[_0x68ef('0x6f')][_0x68ef('0x70')]()==='set'){_0x15378c['applicationdata']=(_0x15378c[_0x68ef('0x71')]||_0x15378c['applicationdata'])[_0x68ef('0x70')]();if(_['startsWith'](_0x15378c[_0x68ef('0x72')],'cdr(')){if(_[_0x68ef('0x19')](this[_0x68ef('0xd')][_0x15378c['uniqueid']]))this[_0x68ef('0xd')][_0x15378c[_0x68ef('0x1d')]]={};logger[_0x68ef('0x35')](_0x68ef('0x73'),_0x15378c['uniqueid'],_0x15378c[_0x68ef('0x6f')],_0x15378c[_0x68ef('0x72')]);var _0x5b2e89=_0x15378c[_0x68ef('0x72')][_0x68ef('0x74')]('=');var _0x21f32b=_0x5b2e89[0x0]['match'](/cdr\((.*)\)/);if(_0x21f32b)this[_0x68ef('0xd')][_0x15378c['uniqueid']][_0x21f32b[0x1]]=_0x5b2e89[0x1];}}}}catch(_0xe6bf05){logger[_0x68ef('0x6d')]('[%s][voiceDialReport][newexten]',_0x15378c['uniqueid'],util['inspect'](_0xe6bf05,{'showHidden':![],'depth':null}));}};module['exports']=VoiceDialReport;
\ No newline at end of file