Built motion from commit 97153652.|2.6.26
[motion2.git] / server / services / xdr / calls.controller.js
index 915dff3..c479d09 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd4be=['[%s][calls][newexten]','lodash','./utils','NO\x20ANSWER','FAILED','ANSWERED','BUSY','info','format','uniqueid','channel','queue','interface','calleridnum','connectedlinenum','lastevent','accountcode','then','CreateVoiceCallReport','request','newchannel','debug','[%s][calls][newchannel]','[%s][calls][newchannel]\x20context:%s\x20exten:%s','context','exten','now','DOCUMENTATION','error','newstate','[%s][calls][newstate]','isNil','transfer','linkedid','destinationchannel','answertime','disposition','channelstate','callerid','calleridname','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','cause-txt','endtime','duration','diffTime','billableseconds','attendedtransfer','localtwolinkedid','[%s][calls][attendedtransfer]','origtransfereruniqueid','transfereechannel','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','secondtransfererchannel','_attended','transfertargetchannel','origtransfererchannel','userfield','musiconholdstart','musiconholdstartAt','[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s','[%s][calls][musiconholdstart]','musiconholdstop','[%s][calls][musiconholdstop]','[%s][calls][musiconholdstop]\x20mohtime:%s','mohtime','varset','[%s][calls][varset]','variable','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','source','value','xmd-phone','[%s][calls][varset]\x20variable:xmd-phone\x20value:%s','destination','\x22\x20<','xmd-callerid-preview','xmd-callerid','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-queue','xmcs-queue','lastapplication','lastdata','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','ContactId','xmd-cdrtype','[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s','outboundrouteid','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','routeid','sipcallid','[%s][calls][varset]\x20variable:sipcallid\x20value:%s','[%s][calls][newexten]\x20application:%s\x20appdata:%s','application','appdata','toLowerCase','cdr','split','lastIndexOf','includes','hangup','noop','execif','gotoif'];(function(_0x18e152,_0x54d5e9){var _0x243f3c=function(_0x24221e){while(--_0x24221e){_0x18e152['push'](_0x18e152['shift']());}};_0x243f3c(++_0x54d5e9);}(_0xd4be,0x68));var _0xed4b=function(_0x51867c,_0x1800e5){_0x51867c=_0x51867c-0x0;var _0x1f4ac4=_0xd4be[_0x51867c];return _0x1f4ac4;};'use strict';var _=require(_0xed4b('0x0'));var util=require('util');var utils=require(_0xed4b('0x1'));var dispositions=[_0xed4b('0x2'),_0xed4b('0x3'),_0xed4b('0x3'),_0xed4b('0x2'),_0xed4b('0x2'),_0xed4b('0x2'),_0xed4b('0x4'),_0xed4b('0x5'),_0xed4b('0x3'),'FAILED',_0xed4b('0x3')];var channels={};function writeDB(_0x198299){utils[_0xed4b('0x6')](util[_0xed4b('0x7')]('[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s',_0x198299[_0xed4b('0x8')],_0x198299[_0xed4b('0x9')],_0x198299[_0xed4b('0xa')],_0x198299['membername'],_0x198299[_0xed4b('0xb')],_0x198299[_0xed4b('0xc')],_0x198299[_0xed4b('0xd')],_0x198299[_0xed4b('0xe')]));if(_0x198299['accountcode']){utils['getUserByInternal'](_0x198299[_0xed4b('0xf')])[_0xed4b('0x10')](function(_0x3269f2){if(_0x3269f2){_0x198299['UserId']=_0x3269f2['id'];}utils['request'](_0xed4b('0x11'),_0x198299);});}else{utils[_0xed4b('0x12')](_0xed4b('0x11'),_0x198299);}if(channels[_0x198299[_0xed4b('0x8')]]){delete channels[_0x198299['uniqueid']];}}exports[_0xed4b('0x13')]=function(_0x5f3e20){try{utils[_0xed4b('0x14')](util[_0xed4b('0x7')](_0xed4b('0x15'),_0x5f3e20[_0xed4b('0x8')]),_0x5f3e20);if(_0x5f3e20[_0xed4b('0x8')]==_0x5f3e20['linkedid']&&_0x5f3e20['channel']!='OutgoingSpoolFailed'){utils['info'](util[_0xed4b('0x7')](_0xed4b('0x16'),_0x5f3e20['uniqueid'],_0x5f3e20[_0xed4b('0x17')],_0x5f3e20[_0xed4b('0x18')]));channels[_0x5f3e20['uniqueid']]={'uniqueid':_0x5f3e20[_0xed4b('0x8')],'accountcode':_0x5f3e20['accountcode'],'source':_0x5f3e20['calleridnum'],'destination':_0x5f3e20[_0xed4b('0x18')],'destinationcontext':_0x5f3e20[_0xed4b('0x17')],'channel':_0x5f3e20[_0xed4b('0x9')],'starttime':utils[_0xed4b('0x19')](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':_0xed4b('0x2'),'amaflags':_0xed4b('0x1a')};}}catch(_0x13d8b7){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')](_0xed4b('0x15'),_0x5f3e20[_0xed4b('0x8')]),_0x13d8b7);}};exports[_0xed4b('0x1c')]=function(_0x3b2932){try{utils[_0xed4b('0x14')](util['format'](_0xed4b('0x1d'),_0x3b2932[_0xed4b('0x8')]),_0x3b2932);if(!_['isNil'](channels[_0x3b2932[_0xed4b('0x8')]])&&_0x3b2932['channelstate']==0x6){utils['info'](util[_0xed4b('0x7')]('[%s][calls][newstate]\x20context:%s\x20channel:%s',_0x3b2932[_0xed4b('0x8')],_0x3b2932[_0xed4b('0x17')],_0x3b2932[_0xed4b('0x9')]));if(_[_0xed4b('0x1e')](channels[_0x3b2932[_0xed4b('0x8')]]['systemanswertime'])){channels[_0x3b2932[_0xed4b('0x8')]]['systemanswertime']=utils[_0xed4b('0x19')]();}}else if(!_[_0xed4b('0x1e')](channels[_0x3b2932['linkedid']])&&_0x3b2932['channelstate']==0x6&&_0x3b2932[_0xed4b('0x17')]!=_0xed4b('0x1f')){utils['info'](util[_0xed4b('0x7')]('[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s',_0x3b2932[_0xed4b('0x8')],_0x3b2932[_0xed4b('0x20')],_0x3b2932[_0xed4b('0x17')],_0x3b2932[_0xed4b('0x9')]));channels[_0x3b2932[_0xed4b('0x20')]][_0xed4b('0xf')]=_0x3b2932['accountcode'];channels[_0x3b2932[_0xed4b('0x20')]][_0xed4b('0x21')]=_0x3b2932[_0xed4b('0x9')];if(_[_0xed4b('0x1e')](channels[_0x3b2932['linkedid']][_0xed4b('0x22')])){channels[_0x3b2932[_0xed4b('0x20')]][_0xed4b('0x22')]=utils['now']();}channels[_0x3b2932[_0xed4b('0x20')]][_0xed4b('0x23')]=dispositions[_['toNumber'](_0x3b2932[_0xed4b('0x24')])]||_0xed4b('0x4');}}catch(_0x22c722){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')](_0xed4b('0x1d'),_0x3b2932[_0xed4b('0x8')]),_0x22c722);}};exports['hangup']=function(_0x239aa){try{if(!_[_0xed4b('0x1e')](channels[_0x239aa[_0xed4b('0x8')]])){utils[_0xed4b('0x14')](util[_0xed4b('0x7')]('[%s][calls][hangup]',_0x239aa[_0xed4b('0x8')]),_0x239aa);if(_[_0xed4b('0x1e')](channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x25')])){channels[_0x239aa['uniqueid']][_0xed4b('0x25')]=_0x239aa[_0xed4b('0x26')]+'\x20<'+_0x239aa[_0xed4b('0xc')]+'>';}utils[_0xed4b('0x6')](util['format'](_0xed4b('0x27'),_0x239aa[_0xed4b('0x8')],channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x25')],_0x239aa[_0xed4b('0x28')]));channels[_0x239aa['uniqueid']][_0xed4b('0x29')]=utils[_0xed4b('0x19')]();channels[_0x239aa['uniqueid']][_0xed4b('0x2a')]=utils[_0xed4b('0x2b')](channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x29')],channels[_0x239aa['uniqueid']]['starttime']);channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x2c')]=channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x22')]?utils['diffTime'](channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x29')],channels[_0x239aa[_0xed4b('0x8')]][_0xed4b('0x22')]):0x0;writeDB(channels[_0x239aa[_0xed4b('0x8')]]);}}catch(_0x52f287){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')]('[%s][calls][hangup]',_0x239aa[_0xed4b('0x8')]),_0x52f287);}};exports[_0xed4b('0x2d')]=function(_0x31b80e){try{if(!_['isNil'](channels[_0x31b80e[_0xed4b('0x2e')]])){utils[_0xed4b('0x14')](util[_0xed4b('0x7')](_0xed4b('0x2f'),_0x31b80e[_0xed4b('0x30')]),_0x31b80e);if(channels[_0x31b80e[_0xed4b('0x2e')]]['channel']==_0x31b80e[_0xed4b('0x31')]){utils['info'](util[_0xed4b('0x7')](_0xed4b('0x32'),_0x31b80e[_0xed4b('0x30')],_0x31b80e[_0xed4b('0x2e')],_0x31b80e[_0xed4b('0x33')]));channels[_0x31b80e[_0xed4b('0x2e')]][_0xed4b('0x21')]=_0x31b80e[_0xed4b('0x33')];channels[_0x31b80e[_0xed4b('0x2e')]]['userfield']=_0xed4b('0x34');}else if(channels[_0x31b80e['localtwolinkedid']][_0xed4b('0x9')]=_0x31b80e[_0xed4b('0x35')]){utils[_0xed4b('0x6')](util[_0xed4b('0x7')]('[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s',_0x31b80e['origtransfereruniqueid'],_0x31b80e['localtwolinkedid'],_0x31b80e[_0xed4b('0x36')]));channels[_0x31b80e['localtwolinkedid']][_0xed4b('0x21')]=_0x31b80e['origtransfererchannel'];channels[_0x31b80e[_0xed4b('0x2e')]][_0xed4b('0x37')]=_0xed4b('0x34');}}}catch(_0x5df1b8){utils['error'](util[_0xed4b('0x7')](_0xed4b('0x2f'),_0x31b80e[_0xed4b('0x30')]),_0x5df1b8);}};exports[_0xed4b('0x38')]=function(_0x229c43){try{if(!_[_0xed4b('0x1e')](channels[_0x229c43[_0xed4b('0x8')]])){utils['debug'](util[_0xed4b('0x7')]('[%s][calls][musiconholdstart]',_0x229c43[_0xed4b('0x8')]),_0x229c43);channels[_0x229c43[_0xed4b('0x8')]][_0xed4b('0x39')]=utils[_0xed4b('0x19')]();utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x3a'),_0x229c43[_0xed4b('0x8')],channels[_0x229c43[_0xed4b('0x8')]][_0xed4b('0x39')]));}}catch(_0x206d9e){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')](_0xed4b('0x3b'),_0x229c43[_0xed4b('0x8')]),_0x206d9e);}};exports[_0xed4b('0x3c')]=function(_0x1f4f66){try{if(!_['isNil'](channels[_0x1f4f66['uniqueid']])){utils['debug'](util[_0xed4b('0x7')](_0xed4b('0x3d'),_0x1f4f66[_0xed4b('0x8')]),_0x1f4f66);if(!_[_0xed4b('0x1e')](channels[_0x1f4f66[_0xed4b('0x8')]]['musiconholdstartAt'])){channels[_0x1f4f66[_0xed4b('0x8')]]['mohtime']+=utils[_0xed4b('0x2b')](utils[_0xed4b('0x19')](),channels[_0x1f4f66[_0xed4b('0x8')]][_0xed4b('0x39')]);utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x3e'),_0x1f4f66[_0xed4b('0x8')],channels[_0x1f4f66[_0xed4b('0x8')]][_0xed4b('0x3f')]));delete channels[_0x1f4f66[_0xed4b('0x8')]][_0xed4b('0x39')];}}}catch(_0xb02f13){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')](_0xed4b('0x3d'),_0x1f4f66['uniqueid']),_0xb02f13);}};exports[_0xed4b('0x40')]=function(_0x5a46bf){try{if(!_['isNil'](channels[_0x5a46bf['uniqueid']])){utils[_0xed4b('0x14')](util[_0xed4b('0x7')](_0xed4b('0x41'),_0x5a46bf[_0xed4b('0x8')]),_0x5a46bf);if(!_['isNil'](_0x5a46bf[_0xed4b('0x42')]['xmd-originatecalleridnum'])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x43'),_0x5a46bf[_0xed4b('0x8')],_0x5a46bf['value']));channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x44')]=_0x5a46bf[_0xed4b('0x45')];}if(!_['isNil'](_0x5a46bf['variable'][_0xed4b('0x46')])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x47'),_0x5a46bf['uniqueid'],_0x5a46bf[_0xed4b('0x45')]));channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x48')]=_0x5a46bf['value'];channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x25')]='\x22'+_0x5a46bf[_0xed4b('0x45')]+_0xed4b('0x49')+_0x5a46bf[_0xed4b('0x45')]+'>';}if(!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')][_0xed4b('0x4a')])||!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')][_0xed4b('0x4b')])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x4c'),_0x5a46bf[_0xed4b('0x8')],!_[_0xed4b('0x1e')](_0x5a46bf['variable']['xmd-callerid-preview'])?_0xed4b('0x4a'):_0xed4b('0x4b'),_0x5a46bf['value']));channels[_0x5a46bf[_0xed4b('0x8')]]['callerid']=_0x5a46bf[_0xed4b('0x45')];}if(!_[_0xed4b('0x1e')](_0x5a46bf['variable'][_0xed4b('0x4d')])||!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')][_0xed4b('0x4e')])){utils[_0xed4b('0x6')](util['format'](_0xed4b('0x4c'),_0x5a46bf[_0xed4b('0x8')],!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')]['xmd-queue'])?_0xed4b('0x4d'):'xmcs-queue',_0x5a46bf[_0xed4b('0x45')]));channels[_0x5a46bf['uniqueid']][_0xed4b('0x4f')]='Queue';channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x50')]=_0x5a46bf[_0xed4b('0x45')];channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0xa')]=!![];}if(!_['isNil'](_0x5a46bf[_0xed4b('0x42')]['xmd-contactid'])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x51'),_0x5a46bf[_0xed4b('0x8')],_0x5a46bf[_0xed4b('0x45')]));channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x52')]=_0x5a46bf[_0xed4b('0x45')];}if(!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')][_0xed4b('0x53')])){utils[_0xed4b('0x6')](util['format'](_0xed4b('0x54'),_0x5a46bf[_0xed4b('0x8')],_0x5a46bf['value']));channels[_0x5a46bf['uniqueid']]['type']=_0x5a46bf[_0xed4b('0x45')];}if(!_[_0xed4b('0x1e')](_0x5a46bf['variable'][_0xed4b('0x55')])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x56'),_0x5a46bf[_0xed4b('0x8')],_0x5a46bf[_0xed4b('0x45')]));channels[_0x5a46bf[_0xed4b('0x8')]][_0xed4b('0x57')]=_0x5a46bf[_0xed4b('0x45')];}if(!_[_0xed4b('0x1e')](_0x5a46bf[_0xed4b('0x42')][_0xed4b('0x58')])){utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x59'),_0x5a46bf[_0xed4b('0x8')],_0x5a46bf['value']));channels[_0x5a46bf[_0xed4b('0x8')]]['sipcallid']=_0x5a46bf['value'];}}}catch(_0x133b4c){utils['error'](util[_0xed4b('0x7')]('[%s][calls][varset]',_0x5a46bf[_0xed4b('0x8')]),_0x133b4c);}};exports['newexten']=function(_0x46caa4){try{if(!_['isNil'](channels[_0x46caa4[_0xed4b('0x8')]])){utils[_0xed4b('0x14')](util['format']('[%s][calls][newexten]',_0x46caa4[_0xed4b('0x8')]),_0x46caa4);utils[_0xed4b('0x6')](util[_0xed4b('0x7')](_0xed4b('0x5a'),_0x46caa4['uniqueid'],_0x46caa4[_0xed4b('0x5b')],_0x46caa4[_0xed4b('0x5c')]));if(_0x46caa4[_0xed4b('0x5b')][_0xed4b('0x5d')]()=='set'&&_['startsWith'](_0x46caa4[_0xed4b('0x5c')][_0xed4b('0x5d')](),_0xed4b('0x5e'))){var _0x1a501d=_0x46caa4[_0xed4b('0x5c')][_0xed4b('0x5f')]('=');var _0x3f8266=_0x1a501d[0x0]['substring'](_0x1a501d[0x0][_0xed4b('0x60')]('(')+0x1,_0x1a501d[0x0][_0xed4b('0x60')](')'));var _0x3b307e=_0x1a501d[0x1];channels[_0x46caa4[_0xed4b('0x8')]][_0x3f8266]=_0x3b307e;}if(!_[_0xed4b('0x61')]([_0xed4b('0x62'),_0xed4b('0x63'),_0xed4b('0x64'),'set',_0xed4b('0x65')],_0x46caa4[_0xed4b('0x5b')][_0xed4b('0x5d')]())){channels[_0x46caa4[_0xed4b('0x8')]][_0xed4b('0x4f')]=_0x46caa4['application'];channels[_0x46caa4['uniqueid']][_0xed4b('0x50')]=_0x46caa4[_0xed4b('0x5c')];}}}catch(_0x4f1b34){utils[_0xed4b('0x1b')](util[_0xed4b('0x7')](_0xed4b('0x66'),_0x46caa4['uniqueid']),_0x4f1b34);}};
\ No newline at end of file
+var _0xa589=['NO\x20ANSWER','FAILED','ANSWERED','format','[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','uniqueid','channel','membername','interface','connectedlinenum','lastevent','accountcode','then','UserId','CreateVoiceCallReport','request','newchannel','debug','[%s][calls][newchannel]','OutgoingSpoolFailed','info','[%s][calls][newchannel]\x20context:%s\x20exten:%s','context','exten','calleridnum','now','DOCUMENTATION','error','newstate','[%s][calls][newstate]','isNil','channelstate','systemanswertime','linkedid','transfer','destinationchannel','answertime','disposition','toNumber','hangup','callerid','cause-txt','endtime','diffTime','billableseconds','[%s][calls][hangup]','attendedtransfer','[%s][calls][attendedtransfer]','origtransfereruniqueid','localtwolinkedid','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','secondtransfererchannel','userfield','_attended','transfertargetchannel','origtransfererchannel','[%s][calls][musiconholdstart]','musiconholdstartAt','[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s','[%s][calls][musiconholdstop]','mohtime','varset','[%s][calls][varset]','variable','xmd-originatecalleridnum','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','value','xmd-phone','xmd-callerid-preview','xmd-callerid','xmd-queue','xmcs-queue','[%s][calls][varset]\x20variable:%s\x20value:%s','lastapplication','Queue','lastdata','queue','xmd-contactid','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','ContactId','[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s','type','outboundrouteid','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','routeid','sipcallid','[%s][calls][varset]\x20variable:sipcallid\x20value:%s','newexten','[%s][calls][newexten]','[%s][calls][newexten]\x20application:%s\x20appdata:%s','application','toLowerCase','set','startsWith','appdata','cdr','split','lastIndexOf','includes','noop','execif','lodash','util','./utils'];(function(_0x2c5340,_0x5c86e5){var _0x3c505e=function(_0x1089d9){while(--_0x1089d9){_0x2c5340['push'](_0x2c5340['shift']());}};_0x3c505e(++_0x5c86e5);}(_0xa589,0x19d));var _0x9a58=function(_0x2e49cc,_0x1f72a7){_0x2e49cc=_0x2e49cc-0x0;var _0xa0c6c1=_0xa589[_0x2e49cc];return _0xa0c6c1;};'use strict';var _=require(_0x9a58('0x0'));var util=require(_0x9a58('0x1'));var utils=require(_0x9a58('0x2'));var dispositions=[_0x9a58('0x3'),_0x9a58('0x4'),_0x9a58('0x4'),_0x9a58('0x3'),_0x9a58('0x3'),_0x9a58('0x3'),_0x9a58('0x5'),'BUSY',_0x9a58('0x4'),_0x9a58('0x4'),_0x9a58('0x4')];var channels={};function writeDB(_0x4c63c4){utils['info'](util[_0x9a58('0x6')](_0x9a58('0x7'),_0x4c63c4[_0x9a58('0x8')],_0x4c63c4[_0x9a58('0x9')],_0x4c63c4['queue'],_0x4c63c4[_0x9a58('0xa')],_0x4c63c4[_0x9a58('0xb')],_0x4c63c4['calleridnum'],_0x4c63c4[_0x9a58('0xc')],_0x4c63c4[_0x9a58('0xd')]));if(_0x4c63c4['accountcode']){utils['getUserByInternal'](_0x4c63c4[_0x9a58('0xe')])[_0x9a58('0xf')](function(_0x3b5425){if(_0x3b5425){_0x4c63c4[_0x9a58('0x10')]=_0x3b5425['id'];}utils['request'](_0x9a58('0x11'),_0x4c63c4);});}else{utils[_0x9a58('0x12')](_0x9a58('0x11'),_0x4c63c4);}if(channels[_0x4c63c4[_0x9a58('0x8')]]){delete channels[_0x4c63c4[_0x9a58('0x8')]];}}exports[_0x9a58('0x13')]=function(_0xcc06cb){try{utils[_0x9a58('0x14')](util[_0x9a58('0x6')](_0x9a58('0x15'),_0xcc06cb[_0x9a58('0x8')]),_0xcc06cb);if(_0xcc06cb[_0x9a58('0x8')]==_0xcc06cb['linkedid']&&_0xcc06cb[_0x9a58('0x9')]!=_0x9a58('0x16')){utils[_0x9a58('0x17')](util[_0x9a58('0x6')](_0x9a58('0x18'),_0xcc06cb[_0x9a58('0x8')],_0xcc06cb[_0x9a58('0x19')],_0xcc06cb[_0x9a58('0x1a')]));channels[_0xcc06cb[_0x9a58('0x8')]]={'uniqueid':_0xcc06cb[_0x9a58('0x8')],'accountcode':_0xcc06cb[_0x9a58('0xe')],'source':_0xcc06cb[_0x9a58('0x1b')],'destination':_0xcc06cb[_0x9a58('0x1a')],'destinationcontext':_0xcc06cb[_0x9a58('0x19')],'channel':_0xcc06cb[_0x9a58('0x9')],'starttime':utils[_0x9a58('0x1c')](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':_0x9a58('0x3'),'amaflags':_0x9a58('0x1d')};}}catch(_0x22e1c3){utils[_0x9a58('0x1e')](util[_0x9a58('0x6')]('[%s][calls][newchannel]',_0xcc06cb[_0x9a58('0x8')]),_0x22e1c3);}};exports[_0x9a58('0x1f')]=function(_0x31a2b6){try{utils[_0x9a58('0x14')](util[_0x9a58('0x6')](_0x9a58('0x20'),_0x31a2b6[_0x9a58('0x8')]),_0x31a2b6);if(!_[_0x9a58('0x21')](channels[_0x31a2b6[_0x9a58('0x8')]])&&_0x31a2b6[_0x9a58('0x22')]==0x6){utils['info'](util[_0x9a58('0x6')]('[%s][calls][newstate]\x20context:%s\x20channel:%s',_0x31a2b6['uniqueid'],_0x31a2b6[_0x9a58('0x19')],_0x31a2b6[_0x9a58('0x9')]));if(_[_0x9a58('0x21')](channels[_0x31a2b6[_0x9a58('0x8')]][_0x9a58('0x23')])){channels[_0x31a2b6[_0x9a58('0x8')]][_0x9a58('0x23')]=utils[_0x9a58('0x1c')]();}}else if(!_[_0x9a58('0x21')](channels[_0x31a2b6[_0x9a58('0x24')]])&&_0x31a2b6['channelstate']==0x6&&_0x31a2b6[_0x9a58('0x19')]!=_0x9a58('0x25')){utils[_0x9a58('0x17')](util['format']('[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s',_0x31a2b6[_0x9a58('0x8')],_0x31a2b6[_0x9a58('0x24')],_0x31a2b6[_0x9a58('0x19')],_0x31a2b6[_0x9a58('0x9')]));channels[_0x31a2b6[_0x9a58('0x24')]][_0x9a58('0xe')]=_0x31a2b6['accountcode'];channels[_0x31a2b6[_0x9a58('0x24')]][_0x9a58('0x26')]=_0x31a2b6[_0x9a58('0x9')];if(_[_0x9a58('0x21')](channels[_0x31a2b6[_0x9a58('0x24')]][_0x9a58('0x27')])){channels[_0x31a2b6['linkedid']][_0x9a58('0x27')]=utils[_0x9a58('0x1c')]();}channels[_0x31a2b6['linkedid']][_0x9a58('0x28')]=dispositions[_[_0x9a58('0x29')](_0x31a2b6[_0x9a58('0x22')])]||'ANSWERED';}}catch(_0x3ce939){utils['error'](util[_0x9a58('0x6')](_0x9a58('0x20'),_0x31a2b6[_0x9a58('0x8')]),_0x3ce939);}};exports[_0x9a58('0x2a')]=function(_0x238155){try{if(!_['isNil'](channels[_0x238155[_0x9a58('0x8')]])){utils[_0x9a58('0x14')](util[_0x9a58('0x6')]('[%s][calls][hangup]',_0x238155[_0x9a58('0x8')]),_0x238155);if(_[_0x9a58('0x21')](channels[_0x238155[_0x9a58('0x8')]]['callerid'])){channels[_0x238155[_0x9a58('0x8')]]['callerid']=_0x238155['calleridname']+'\x20<'+_0x238155[_0x9a58('0x1b')]+'>';}utils[_0x9a58('0x17')](util[_0x9a58('0x6')]('[%s][calls][hangup]\x20callerid:%s\x20reason:%s',_0x238155[_0x9a58('0x8')],channels[_0x238155[_0x9a58('0x8')]][_0x9a58('0x2b')],_0x238155[_0x9a58('0x2c')]));channels[_0x238155[_0x9a58('0x8')]][_0x9a58('0x2d')]=utils[_0x9a58('0x1c')]();channels[_0x238155['uniqueid']]['duration']=utils[_0x9a58('0x2e')](channels[_0x238155['uniqueid']][_0x9a58('0x2d')],channels[_0x238155[_0x9a58('0x8')]]['starttime']);channels[_0x238155[_0x9a58('0x8')]][_0x9a58('0x2f')]=channels[_0x238155['uniqueid']][_0x9a58('0x27')]?utils['diffTime'](channels[_0x238155[_0x9a58('0x8')]][_0x9a58('0x2d')],channels[_0x238155[_0x9a58('0x8')]][_0x9a58('0x27')]):0x0;writeDB(channels[_0x238155[_0x9a58('0x8')]]);}}catch(_0x4e9c11){utils[_0x9a58('0x1e')](util[_0x9a58('0x6')](_0x9a58('0x30'),_0x238155[_0x9a58('0x8')]),_0x4e9c11);}};exports[_0x9a58('0x31')]=function(_0x302b7b){try{if(!_['isNil'](channels[_0x302b7b['localtwolinkedid']])){utils[_0x9a58('0x14')](util['format'](_0x9a58('0x32'),_0x302b7b[_0x9a58('0x33')]),_0x302b7b);if(channels[_0x302b7b[_0x9a58('0x34')]][_0x9a58('0x9')]==_0x302b7b['transfereechannel']){utils[_0x9a58('0x17')](util['format'](_0x9a58('0x35'),_0x302b7b[_0x9a58('0x33')],_0x302b7b[_0x9a58('0x34')],_0x302b7b[_0x9a58('0x36')]));channels[_0x302b7b['localtwolinkedid']][_0x9a58('0x26')]=_0x302b7b[_0x9a58('0x36')];channels[_0x302b7b['localtwolinkedid']][_0x9a58('0x37')]=_0x9a58('0x38');}else if(channels[_0x302b7b['localtwolinkedid']][_0x9a58('0x9')]=_0x302b7b[_0x9a58('0x39')]){utils[_0x9a58('0x17')](util['format'](_0x9a58('0x35'),_0x302b7b['origtransfereruniqueid'],_0x302b7b[_0x9a58('0x34')],_0x302b7b['origtransfererchannel']));channels[_0x302b7b[_0x9a58('0x34')]]['destinationchannel']=_0x302b7b[_0x9a58('0x3a')];channels[_0x302b7b[_0x9a58('0x34')]][_0x9a58('0x37')]=_0x9a58('0x38');}}}catch(_0x569a8f){utils[_0x9a58('0x1e')](util[_0x9a58('0x6')]('[%s][calls][attendedtransfer]',_0x302b7b[_0x9a58('0x33')]),_0x569a8f);}};exports['musiconholdstart']=function(_0x3953c9){try{if(!_[_0x9a58('0x21')](channels[_0x3953c9['uniqueid']])){utils[_0x9a58('0x14')](util['format'](_0x9a58('0x3b'),_0x3953c9[_0x9a58('0x8')]),_0x3953c9);channels[_0x3953c9['uniqueid']][_0x9a58('0x3c')]=utils[_0x9a58('0x1c')]();utils[_0x9a58('0x17')](util[_0x9a58('0x6')](_0x9a58('0x3d'),_0x3953c9['uniqueid'],channels[_0x3953c9['uniqueid']][_0x9a58('0x3c')]));}}catch(_0x4433d7){utils['error'](util[_0x9a58('0x6')](_0x9a58('0x3b'),_0x3953c9[_0x9a58('0x8')]),_0x4433d7);}};exports['musiconholdstop']=function(_0x82c7e6){try{if(!_[_0x9a58('0x21')](channels[_0x82c7e6['uniqueid']])){utils[_0x9a58('0x14')](util['format'](_0x9a58('0x3e'),_0x82c7e6['uniqueid']),_0x82c7e6);if(!_['isNil'](channels[_0x82c7e6[_0x9a58('0x8')]][_0x9a58('0x3c')])){channels[_0x82c7e6[_0x9a58('0x8')]][_0x9a58('0x3f')]+=utils['diffTime'](utils[_0x9a58('0x1c')](),channels[_0x82c7e6[_0x9a58('0x8')]]['musiconholdstartAt']);utils[_0x9a58('0x17')](util['format']('[%s][calls][musiconholdstop]\x20mohtime:%s',_0x82c7e6['uniqueid'],channels[_0x82c7e6[_0x9a58('0x8')]]['mohtime']));delete channels[_0x82c7e6[_0x9a58('0x8')]][_0x9a58('0x3c')];}}}catch(_0x143194){utils[_0x9a58('0x1e')](util[_0x9a58('0x6')](_0x9a58('0x3e'),_0x82c7e6[_0x9a58('0x8')]),_0x143194);}};exports[_0x9a58('0x40')]=function(_0x17ead6){try{if(!_[_0x9a58('0x21')](channels[_0x17ead6['uniqueid']])){utils['debug'](util[_0x9a58('0x6')](_0x9a58('0x41'),_0x17ead6[_0x9a58('0x8')]),_0x17ead6);if(!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x43')])){utils['info'](util[_0x9a58('0x6')](_0x9a58('0x44'),_0x17ead6['uniqueid'],_0x17ead6['value']));channels[_0x17ead6[_0x9a58('0x8')]]['source']=_0x17ead6[_0x9a58('0x45')];}if(!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x46')])){utils[_0x9a58('0x17')](util[_0x9a58('0x6')]('[%s][calls][varset]\x20variable:xmd-phone\x20value:%s',_0x17ead6[_0x9a58('0x8')],_0x17ead6['value']));channels[_0x17ead6[_0x9a58('0x8')]]['destination']=_0x17ead6[_0x9a58('0x45')];channels[_0x17ead6[_0x9a58('0x8')]]['callerid']='\x22'+_0x17ead6[_0x9a58('0x45')]+'\x22\x20<'+_0x17ead6[_0x9a58('0x45')]+'>';}if(!_[_0x9a58('0x21')](_0x17ead6['variable'][_0x9a58('0x47')])||!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')]['xmd-callerid'])){utils[_0x9a58('0x17')](util[_0x9a58('0x6')]('[%s][calls][varset]\x20variable:%s\x20value:%s',_0x17ead6[_0x9a58('0x8')],!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')]['xmd-callerid-preview'])?_0x9a58('0x47'):_0x9a58('0x48'),_0x17ead6['value']));channels[_0x17ead6[_0x9a58('0x8')]]['callerid']=_0x17ead6[_0x9a58('0x45')];}if(!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x49')])||!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x4a')])){utils['info'](util[_0x9a58('0x6')](_0x9a58('0x4b'),_0x17ead6['uniqueid'],!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')]['xmd-queue'])?_0x9a58('0x49'):_0x9a58('0x4a'),_0x17ead6[_0x9a58('0x45')]));channels[_0x17ead6[_0x9a58('0x8')]][_0x9a58('0x4c')]=_0x9a58('0x4d');channels[_0x17ead6['uniqueid']][_0x9a58('0x4e')]=_0x17ead6[_0x9a58('0x45')];channels[_0x17ead6[_0x9a58('0x8')]][_0x9a58('0x4f')]=!![];}if(!_['isNil'](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x50')])){utils[_0x9a58('0x17')](util['format'](_0x9a58('0x51'),_0x17ead6[_0x9a58('0x8')],_0x17ead6[_0x9a58('0x45')]));channels[_0x17ead6['uniqueid']][_0x9a58('0x52')]=_0x17ead6[_0x9a58('0x45')];}if(!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')]['xmd-cdrtype'])){utils[_0x9a58('0x17')](util['format'](_0x9a58('0x53'),_0x17ead6[_0x9a58('0x8')],_0x17ead6[_0x9a58('0x45')]));channels[_0x17ead6[_0x9a58('0x8')]][_0x9a58('0x54')]=_0x17ead6[_0x9a58('0x45')];}if(!_[_0x9a58('0x21')](_0x17ead6[_0x9a58('0x42')][_0x9a58('0x55')])){utils[_0x9a58('0x17')](util[_0x9a58('0x6')](_0x9a58('0x56'),_0x17ead6[_0x9a58('0x8')],_0x17ead6[_0x9a58('0x45')]));channels[_0x17ead6[_0x9a58('0x8')]][_0x9a58('0x57')]=_0x17ead6[_0x9a58('0x45')];}if(!_[_0x9a58('0x21')](_0x17ead6['variable'][_0x9a58('0x58')])){utils[_0x9a58('0x17')](util['format'](_0x9a58('0x59'),_0x17ead6['uniqueid'],_0x17ead6[_0x9a58('0x45')]));channels[_0x17ead6[_0x9a58('0x8')]][_0x9a58('0x58')]=_0x17ead6[_0x9a58('0x45')];}}}catch(_0x409ed0){utils[_0x9a58('0x1e')](util[_0x9a58('0x6')]('[%s][calls][varset]',_0x17ead6[_0x9a58('0x8')]),_0x409ed0);}};exports[_0x9a58('0x5a')]=function(_0xdbdd6b){try{if(!_[_0x9a58('0x21')](channels[_0xdbdd6b['uniqueid']])){utils['debug'](util[_0x9a58('0x6')](_0x9a58('0x5b'),_0xdbdd6b['uniqueid']),_0xdbdd6b);utils['info'](util[_0x9a58('0x6')](_0x9a58('0x5c'),_0xdbdd6b[_0x9a58('0x8')],_0xdbdd6b['application'],_0xdbdd6b['appdata']));if(_0xdbdd6b[_0x9a58('0x5d')][_0x9a58('0x5e')]()==_0x9a58('0x5f')&&_[_0x9a58('0x60')](_0xdbdd6b[_0x9a58('0x61')][_0x9a58('0x5e')](),_0x9a58('0x62'))){var _0x315d32=_0xdbdd6b[_0x9a58('0x61')][_0x9a58('0x63')]('=');var _0xf03a11=_0x315d32[0x0]['substring'](_0x315d32[0x0][_0x9a58('0x64')]('(')+0x1,_0x315d32[0x0][_0x9a58('0x64')](')'));var _0x59f0de=_0x315d32[0x1];channels[_0xdbdd6b[_0x9a58('0x8')]][_0xf03a11]=_0x59f0de;}if(!_[_0x9a58('0x65')]([_0x9a58('0x2a'),_0x9a58('0x66'),_0x9a58('0x67'),_0x9a58('0x5f'),'gotoif'],_0xdbdd6b['application']['toLowerCase']())){channels[_0xdbdd6b[_0x9a58('0x8')]][_0x9a58('0x4c')]=_0xdbdd6b['application'];channels[_0xdbdd6b[_0x9a58('0x8')]]['lastdata']=_0xdbdd6b['appdata'];}}}catch(_0x5c9c17){utils['error'](util[_0x9a58('0x6')](_0x9a58('0x5b'),_0xdbdd6b[_0x9a58('0x8')]),_0x5c9c17);}};
\ No newline at end of file