Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / services / xdr / calls.controller.js
index 068eae3..797eafb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xef1c=['[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s','type','[%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','appdata','toLowerCase','set','startsWith','split','substring','lastIndexOf','includes','execif','gotoif','lodash','./utils','FAILED','NO\x20ANSWER','ANSWERED','BUSY','info','format','[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s','uniqueid','queue','membername','interface','connectedlinenum','lastevent','accountcode','getUserByInternal','request','CreateVoiceCallReport','linkedid','channel','OutgoingSpoolFailed','[%s][calls][newchannel]\x20context:%s\x20exten:%s','context','exten','calleridnum','DOCUMENTATION','[%s][calls][newchannel]','newstate','debug','[%s][calls][newstate]','isNil','channelstate','systemanswertime','transfer','destinationchannel','now','disposition','toNumber','error','hangup','callerid','calleridname','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','cause-txt','endtime','diffTime','starttime','billableseconds','answertime','[%s][calls][hangup]','attendedtransfer','localtwolinkedid','[%s][calls][attendedtransfer]','origtransfereruniqueid','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','secondtransfererchannel','userfield','_attended','origtransfererchannel','[%s][calls][musiconholdstart]','[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s','musiconholdstartAt','[%s][calls][musiconholdstop]','mohtime','[%s][calls][musiconholdstop]\x20mohtime:%s','[%s][calls][varset]','xmd-originatecalleridnum','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','value','source','variable','xmd-phone','[%s][calls][varset]\x20variable:xmd-phone\x20value:%s','xmd-callerid-preview','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-callerid','xmd-queue','xmcs-queue','lastapplication','Queue','lastdata','xmd-contactid'];(function(_0x3b55d4,_0x9373){var _0x5ce0af=function(_0x2139f7){while(--_0x2139f7){_0x3b55d4['push'](_0x3b55d4['shift']());}};_0x5ce0af(++_0x9373);}(_0xef1c,0x14d));var _0xcef1=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0xef1c[_0x3bf83f];return _0x22c4a9;};'use strict';var _=require(_0xcef1('0x0'));var util=require('util');var utils=require(_0xcef1('0x1'));var dispositions=['NO\x20ANSWER','FAILED',_0xcef1('0x2'),_0xcef1('0x3'),_0xcef1('0x3'),_0xcef1('0x3'),_0xcef1('0x4'),_0xcef1('0x5'),_0xcef1('0x2'),_0xcef1('0x2'),_0xcef1('0x2')];var channels={};function writeDB(_0x28eaef){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x8'),_0x28eaef[_0xcef1('0x9')],_0x28eaef['channel'],_0x28eaef[_0xcef1('0xa')],_0x28eaef[_0xcef1('0xb')],_0x28eaef[_0xcef1('0xc')],_0x28eaef['calleridnum'],_0x28eaef[_0xcef1('0xd')],_0x28eaef[_0xcef1('0xe')]));if(_0x28eaef[_0xcef1('0xf')]){utils[_0xcef1('0x10')](_0x28eaef['accountcode'])['then'](function(_0xfafb30){if(_0xfafb30){_0x28eaef['UserId']=_0xfafb30['id'];}utils[_0xcef1('0x11')](_0xcef1('0x12'),_0x28eaef);});}else{utils[_0xcef1('0x11')](_0xcef1('0x12'),_0x28eaef);}if(channels[_0x28eaef[_0xcef1('0x9')]]){delete channels[_0x28eaef[_0xcef1('0x9')]];}}exports['newchannel']=function(_0x1297ae){try{utils['debug'](util[_0xcef1('0x7')]('[%s][calls][newchannel]',_0x1297ae[_0xcef1('0x9')]),_0x1297ae);if(_0x1297ae['uniqueid']==_0x1297ae[_0xcef1('0x13')]&&_0x1297ae[_0xcef1('0x14')]!=_0xcef1('0x15')){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x16'),_0x1297ae[_0xcef1('0x9')],_0x1297ae[_0xcef1('0x17')],_0x1297ae[_0xcef1('0x18')]));channels[_0x1297ae['uniqueid']]={'uniqueid':_0x1297ae[_0xcef1('0x9')],'accountcode':_0x1297ae[_0xcef1('0xf')],'source':_0x1297ae[_0xcef1('0x19')],'destination':_0x1297ae[_0xcef1('0x18')],'destinationcontext':_0x1297ae[_0xcef1('0x17')],'channel':_0x1297ae[_0xcef1('0x14')],'starttime':utils['now'](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':'NO\x20ANSWER','amaflags':_0xcef1('0x1a')};}}catch(_0x1e7efe){utils['error'](util[_0xcef1('0x7')](_0xcef1('0x1b'),_0x1297ae[_0xcef1('0x9')]),_0x1e7efe);}};exports[_0xcef1('0x1c')]=function(_0x4fbe5a){try{utils[_0xcef1('0x1d')](util[_0xcef1('0x7')](_0xcef1('0x1e'),_0x4fbe5a['uniqueid']),_0x4fbe5a);if(!_[_0xcef1('0x1f')](channels[_0x4fbe5a[_0xcef1('0x9')]])&&_0x4fbe5a[_0xcef1('0x20')]==0x6){utils['info'](util[_0xcef1('0x7')]('[%s][calls][newstate]\x20context:%s\x20channel:%s',_0x4fbe5a[_0xcef1('0x9')],_0x4fbe5a[_0xcef1('0x17')],_0x4fbe5a[_0xcef1('0x14')]));if(_['isNil'](channels[_0x4fbe5a[_0xcef1('0x9')]][_0xcef1('0x21')])){channels[_0x4fbe5a['uniqueid']]['systemanswertime']=utils['now']();}}else if(!_[_0xcef1('0x1f')](channels[_0x4fbe5a['linkedid']])&&_0x4fbe5a[_0xcef1('0x20')]==0x6&&_0x4fbe5a[_0xcef1('0x17')]!=_0xcef1('0x22')){utils['info'](util[_0xcef1('0x7')]('[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s',_0x4fbe5a[_0xcef1('0x9')],_0x4fbe5a[_0xcef1('0x13')],_0x4fbe5a['context'],_0x4fbe5a['channel']));channels[_0x4fbe5a[_0xcef1('0x13')]][_0xcef1('0xf')]=_0x4fbe5a['accountcode'];channels[_0x4fbe5a[_0xcef1('0x13')]][_0xcef1('0x23')]=_0x4fbe5a[_0xcef1('0x14')];if(_['isNil'](channels[_0x4fbe5a['linkedid']]['answertime'])){channels[_0x4fbe5a[_0xcef1('0x13')]]['answertime']=utils[_0xcef1('0x24')]();}channels[_0x4fbe5a[_0xcef1('0x13')]][_0xcef1('0x25')]=dispositions[_[_0xcef1('0x26')](_0x4fbe5a['channelstate'])]||_0xcef1('0x4');}}catch(_0xf40f62){utils[_0xcef1('0x27')](util[_0xcef1('0x7')](_0xcef1('0x1e'),_0x4fbe5a[_0xcef1('0x9')]),_0xf40f62);}};exports[_0xcef1('0x28')]=function(_0x2167ea){try{if(!_['isNil'](channels[_0x2167ea[_0xcef1('0x9')]])){utils['debug'](util[_0xcef1('0x7')]('[%s][calls][hangup]',_0x2167ea[_0xcef1('0x9')]),_0x2167ea);if(_['isNil'](channels[_0x2167ea['uniqueid']][_0xcef1('0x29')])){channels[_0x2167ea['uniqueid']][_0xcef1('0x29')]=_0x2167ea[_0xcef1('0x2a')]+'\x20<'+_0x2167ea[_0xcef1('0x19')]+'>';}utils[_0xcef1('0x6')](util['format'](_0xcef1('0x2b'),_0x2167ea[_0xcef1('0x9')],channels[_0x2167ea['uniqueid']][_0xcef1('0x29')],_0x2167ea[_0xcef1('0x2c')]));channels[_0x2167ea[_0xcef1('0x9')]][_0xcef1('0x2d')]=utils['now']();channels[_0x2167ea[_0xcef1('0x9')]]['duration']=utils[_0xcef1('0x2e')](channels[_0x2167ea[_0xcef1('0x9')]]['endtime'],channels[_0x2167ea[_0xcef1('0x9')]][_0xcef1('0x2f')]);channels[_0x2167ea[_0xcef1('0x9')]][_0xcef1('0x30')]=channels[_0x2167ea[_0xcef1('0x9')]]['answertime']?utils[_0xcef1('0x2e')](channels[_0x2167ea[_0xcef1('0x9')]][_0xcef1('0x2d')],channels[_0x2167ea[_0xcef1('0x9')]][_0xcef1('0x31')]):0x0;writeDB(channels[_0x2167ea['uniqueid']]);}}catch(_0x515e65){utils[_0xcef1('0x27')](util[_0xcef1('0x7')](_0xcef1('0x32'),_0x2167ea[_0xcef1('0x9')]),_0x515e65);}};exports[_0xcef1('0x33')]=function(_0x526a11){try{if(!_['isNil'](channels[_0x526a11[_0xcef1('0x34')]])){utils[_0xcef1('0x1d')](util['format'](_0xcef1('0x35'),_0x526a11[_0xcef1('0x36')]),_0x526a11);if(channels[_0x526a11['localtwolinkedid']][_0xcef1('0x14')]==_0x526a11['transfereechannel']){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x37'),_0x526a11[_0xcef1('0x36')],_0x526a11[_0xcef1('0x34')],_0x526a11['secondtransfererchannel']));channels[_0x526a11[_0xcef1('0x34')]][_0xcef1('0x23')]=_0x526a11[_0xcef1('0x38')];channels[_0x526a11['localtwolinkedid']][_0xcef1('0x39')]=_0xcef1('0x3a');}else if(channels[_0x526a11[_0xcef1('0x34')]][_0xcef1('0x14')]=_0x526a11['transfertargetchannel']){utils[_0xcef1('0x6')](util['format']('[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s',_0x526a11[_0xcef1('0x36')],_0x526a11['localtwolinkedid'],_0x526a11[_0xcef1('0x3b')]));channels[_0x526a11[_0xcef1('0x34')]][_0xcef1('0x23')]=_0x526a11[_0xcef1('0x3b')];channels[_0x526a11['localtwolinkedid']]['userfield']=_0xcef1('0x3a');}}}catch(_0xc2f5b5){utils[_0xcef1('0x27')](util[_0xcef1('0x7')](_0xcef1('0x35'),_0x526a11[_0xcef1('0x36')]),_0xc2f5b5);}};exports['musiconholdstart']=function(_0x229c60){try{if(!_['isNil'](channels[_0x229c60[_0xcef1('0x9')]])){utils[_0xcef1('0x1d')](util[_0xcef1('0x7')](_0xcef1('0x3c'),_0x229c60[_0xcef1('0x9')]),_0x229c60);channels[_0x229c60[_0xcef1('0x9')]]['musiconholdstartAt']=utils[_0xcef1('0x24')]();utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x3d'),_0x229c60[_0xcef1('0x9')],channels[_0x229c60['uniqueid']][_0xcef1('0x3e')]));}}catch(_0x4c8878){utils['error'](util['format'](_0xcef1('0x3c'),_0x229c60[_0xcef1('0x9')]),_0x4c8878);}};exports['musiconholdstop']=function(_0x45896b){try{if(!_[_0xcef1('0x1f')](channels[_0x45896b[_0xcef1('0x9')]])){utils[_0xcef1('0x1d')](util['format'](_0xcef1('0x3f'),_0x45896b['uniqueid']),_0x45896b);if(!_[_0xcef1('0x1f')](channels[_0x45896b['uniqueid']]['musiconholdstartAt'])){channels[_0x45896b['uniqueid']][_0xcef1('0x40')]+=utils[_0xcef1('0x2e')](utils[_0xcef1('0x24')](),channels[_0x45896b[_0xcef1('0x9')]][_0xcef1('0x3e')]);utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x41'),_0x45896b[_0xcef1('0x9')],channels[_0x45896b[_0xcef1('0x9')]][_0xcef1('0x40')]));delete channels[_0x45896b['uniqueid']]['musiconholdstartAt'];}}}catch(_0xbf823a){utils[_0xcef1('0x27')](util[_0xcef1('0x7')](_0xcef1('0x3f'),_0x45896b[_0xcef1('0x9')]),_0xbf823a);}};exports['varset']=function(_0x126f71){try{if(!_['isNil'](channels[_0x126f71[_0xcef1('0x9')]])){utils[_0xcef1('0x1d')](util[_0xcef1('0x7')](_0xcef1('0x42'),_0x126f71['uniqueid']),_0x126f71);if(!_[_0xcef1('0x1f')](_0x126f71['variable'][_0xcef1('0x43')])){utils[_0xcef1('0x6')](util['format'](_0xcef1('0x44'),_0x126f71[_0xcef1('0x9')],_0x126f71[_0xcef1('0x45')]));channels[_0x126f71[_0xcef1('0x9')]][_0xcef1('0x46')]=_0x126f71['value'];}if(!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x48')])){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x49'),_0x126f71[_0xcef1('0x9')],_0x126f71[_0xcef1('0x45')]));channels[_0x126f71[_0xcef1('0x9')]]['destination']=_0x126f71[_0xcef1('0x45')];channels[_0x126f71[_0xcef1('0x9')]][_0xcef1('0x29')]='\x22'+_0x126f71[_0xcef1('0x45')]+'\x22\x20<'+_0x126f71[_0xcef1('0x45')]+'>';}if(!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x4a')])||!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')]['xmd-callerid'])){utils[_0xcef1('0x6')](util['format'](_0xcef1('0x4b'),_0x126f71[_0xcef1('0x9')],!_[_0xcef1('0x1f')](_0x126f71['variable'][_0xcef1('0x4a')])?_0xcef1('0x4a'):_0xcef1('0x4c'),_0x126f71[_0xcef1('0x45')]));channels[_0x126f71[_0xcef1('0x9')]][_0xcef1('0x29')]=_0x126f71[_0xcef1('0x45')];}if(!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x4d')])||!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x4e')])){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x4b'),_0x126f71[_0xcef1('0x9')],!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x4d')])?'xmd-queue':'xmcs-queue',_0x126f71[_0xcef1('0x45')]));channels[_0x126f71['uniqueid']][_0xcef1('0x4f')]=_0xcef1('0x50');channels[_0x126f71['uniqueid']][_0xcef1('0x51')]=_0x126f71[_0xcef1('0x45')];channels[_0x126f71[_0xcef1('0x9')]][_0xcef1('0xa')]=!![];}if(!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x52')])){utils['info'](util[_0xcef1('0x7')](_0xcef1('0x53'),_0x126f71[_0xcef1('0x9')],_0x126f71[_0xcef1('0x45')]));channels[_0x126f71[_0xcef1('0x9')]]['ContactId']=_0x126f71[_0xcef1('0x45')];}if(!_[_0xcef1('0x1f')](_0x126f71['variable']['xmd-cdrtype'])){utils['info'](util['format'](_0xcef1('0x54'),_0x126f71[_0xcef1('0x9')],_0x126f71[_0xcef1('0x45')]));channels[_0x126f71['uniqueid']][_0xcef1('0x55')]=_0x126f71[_0xcef1('0x45')];}if(!_['isNil'](_0x126f71['variable']['outboundrouteid'])){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x56'),_0x126f71[_0xcef1('0x9')],_0x126f71[_0xcef1('0x45')]));channels[_0x126f71[_0xcef1('0x9')]][_0xcef1('0x57')]=_0x126f71[_0xcef1('0x45')];}if(!_[_0xcef1('0x1f')](_0x126f71[_0xcef1('0x47')][_0xcef1('0x58')])){utils[_0xcef1('0x6')](util[_0xcef1('0x7')](_0xcef1('0x59'),_0x126f71['uniqueid'],_0x126f71['value']));channels[_0x126f71['uniqueid']][_0xcef1('0x58')]=_0x126f71[_0xcef1('0x45')];}}}catch(_0x2968ea){utils['error'](util[_0xcef1('0x7')](_0xcef1('0x42'),_0x126f71[_0xcef1('0x9')]),_0x2968ea);}};exports[_0xcef1('0x5a')]=function(_0x3bcbb8){try{if(!_[_0xcef1('0x1f')](channels[_0x3bcbb8[_0xcef1('0x9')]])){utils[_0xcef1('0x1d')](util[_0xcef1('0x7')](_0xcef1('0x5b'),_0x3bcbb8['uniqueid']),_0x3bcbb8);utils[_0xcef1('0x6')](util['format'](_0xcef1('0x5c'),_0x3bcbb8[_0xcef1('0x9')],_0x3bcbb8[_0xcef1('0x5d')],_0x3bcbb8[_0xcef1('0x5e')]));if(_0x3bcbb8[_0xcef1('0x5d')][_0xcef1('0x5f')]()==_0xcef1('0x60')&&_[_0xcef1('0x61')](_0x3bcbb8[_0xcef1('0x5e')][_0xcef1('0x5f')](),'cdr')){var _0x2d9a00=_0x3bcbb8[_0xcef1('0x5e')][_0xcef1('0x62')]('=');var _0xf38819=_0x2d9a00[0x0][_0xcef1('0x63')](_0x2d9a00[0x0][_0xcef1('0x64')]('(')+0x1,_0x2d9a00[0x0][_0xcef1('0x64')](')'));var _0x42b1b3=_0x2d9a00[0x1];channels[_0x3bcbb8[_0xcef1('0x9')]][_0xf38819]=_0x42b1b3;}if(!_[_0xcef1('0x65')]([_0xcef1('0x28'),'noop',_0xcef1('0x66'),_0xcef1('0x60'),_0xcef1('0x67')],_0x3bcbb8[_0xcef1('0x5d')][_0xcef1('0x5f')]())){channels[_0x3bcbb8[_0xcef1('0x9')]][_0xcef1('0x4f')]=_0x3bcbb8[_0xcef1('0x5d')];channels[_0x3bcbb8[_0xcef1('0x9')]][_0xcef1('0x51')]=_0x3bcbb8['appdata'];}}}catch(_0x7b1a63){utils[_0xcef1('0x27')](util[_0xcef1('0x7')]('[%s][calls][newexten]',_0x3bcbb8[_0xcef1('0x9')]),_0x7b1a63);}};
\ No newline at end of file
+var _0x387e=['\x22\x20<','xmd-callerid-preview','xmd-callerid','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-queue','xmcs-queue','Queue','queue','xmd-contactid','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','ContactId','xmd-cdrtype','[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','[%s][calls][varset]\x20variable:sipcallid\x20value:%s','[%s][calls][newexten]','[%s][calls][newexten]\x20application:%s\x20appdata:%s','application','appdata','toLowerCase','set','startsWith','split','substring','lastIndexOf','includes','hangup','execif','gotoif','lastapplication','./utils','NO\x20ANSWER','FAILED','BUSY','info','format','uniqueid','channel','membername','interface','connectedlinenum','lastevent','accountcode','getUserByInternal','UserId','CreateVoiceCallReport','request','newchannel','debug','linkedid','OutgoingSpoolFailed','[%s][calls][newchannel]\x20context:%s\x20exten:%s','exten','calleridnum','context','now','DOCUMENTATION','error','newstate','[%s][calls][newstate]','isNil','channelstate','systemanswertime','transfer','[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','destinationchannel','answertime','disposition','toNumber','[%s][calls][hangup]','callerid','calleridname','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','cause-txt','endtime','diffTime','starttime','localtwolinkedid','transfereechannel','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','origtransfereruniqueid','_attended','transfertargetchannel','origtransfererchannel','userfield','[%s][calls][attendedtransfer]','musiconholdstart','[%s][calls][musiconholdstart]','musiconholdstartAt','musiconholdstop','[%s][calls][musiconholdstop]','mohtime','[%s][calls][musiconholdstop]\x20mohtime:%s','varset','[%s][calls][varset]','variable','xmd-originatecalleridnum','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','value','source','xmd-phone'];(function(_0x2cd689,_0x246e08){var _0x5a62f8=function(_0x6e8532){while(--_0x6e8532){_0x2cd689['push'](_0x2cd689['shift']());}};_0x5a62f8(++_0x246e08);}(_0x387e,0x1b2));var _0xe387=function(_0x8afdd0,_0x548ad1){_0x8afdd0=_0x8afdd0-0x0;var _0x3de7ac=_0x387e[_0x8afdd0];return _0x3de7ac;};'use strict';var _=require('lodash');var util=require('util');var utils=require(_0xe387('0x0'));var dispositions=[_0xe387('0x1'),_0xe387('0x2'),_0xe387('0x2'),'NO\x20ANSWER',_0xe387('0x1'),_0xe387('0x1'),'ANSWERED',_0xe387('0x3'),'FAILED',_0xe387('0x2'),_0xe387('0x2')];var channels={};function writeDB(_0x31cfe7){utils[_0xe387('0x4')](util[_0xe387('0x5')]('[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s',_0x31cfe7[_0xe387('0x6')],_0x31cfe7[_0xe387('0x7')],_0x31cfe7['queue'],_0x31cfe7[_0xe387('0x8')],_0x31cfe7[_0xe387('0x9')],_0x31cfe7['calleridnum'],_0x31cfe7[_0xe387('0xa')],_0x31cfe7[_0xe387('0xb')]));if(_0x31cfe7[_0xe387('0xc')]){utils[_0xe387('0xd')](_0x31cfe7[_0xe387('0xc')])['then'](function(_0x1e0882){if(_0x1e0882){_0x31cfe7[_0xe387('0xe')]=_0x1e0882['id'];}utils['request'](_0xe387('0xf'),_0x31cfe7);});}else{utils[_0xe387('0x10')](_0xe387('0xf'),_0x31cfe7);}if(channels[_0x31cfe7[_0xe387('0x6')]]){delete channels[_0x31cfe7[_0xe387('0x6')]];}}exports[_0xe387('0x11')]=function(_0x43f1d9){try{utils[_0xe387('0x12')](util['format']('[%s][calls][newchannel]',_0x43f1d9['uniqueid']),_0x43f1d9);if(_0x43f1d9[_0xe387('0x6')]==_0x43f1d9[_0xe387('0x13')]&&_0x43f1d9[_0xe387('0x7')]!=_0xe387('0x14')){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x15'),_0x43f1d9[_0xe387('0x6')],_0x43f1d9['context'],_0x43f1d9[_0xe387('0x16')]));channels[_0x43f1d9[_0xe387('0x6')]]={'uniqueid':_0x43f1d9[_0xe387('0x6')],'accountcode':_0x43f1d9[_0xe387('0xc')],'source':_0x43f1d9[_0xe387('0x17')],'destination':_0x43f1d9[_0xe387('0x16')],'destinationcontext':_0x43f1d9[_0xe387('0x18')],'channel':_0x43f1d9[_0xe387('0x7')],'starttime':utils[_0xe387('0x19')](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':_0xe387('0x1'),'amaflags':_0xe387('0x1a')};}}catch(_0x9fd806){utils[_0xe387('0x1b')](util[_0xe387('0x5')]('[%s][calls][newchannel]',_0x43f1d9['uniqueid']),_0x9fd806);}};exports[_0xe387('0x1c')]=function(_0x3f73a6){try{utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x1d'),_0x3f73a6[_0xe387('0x6')]),_0x3f73a6);if(!_[_0xe387('0x1e')](channels[_0x3f73a6[_0xe387('0x6')]])&&_0x3f73a6[_0xe387('0x1f')]==0x6){utils[_0xe387('0x4')](util[_0xe387('0x5')]('[%s][calls][newstate]\x20context:%s\x20channel:%s',_0x3f73a6[_0xe387('0x6')],_0x3f73a6['context'],_0x3f73a6['channel']));if(_['isNil'](channels[_0x3f73a6['uniqueid']][_0xe387('0x20')])){channels[_0x3f73a6['uniqueid']][_0xe387('0x20')]=utils['now']();}}else if(!_[_0xe387('0x1e')](channels[_0x3f73a6[_0xe387('0x13')]])&&_0x3f73a6[_0xe387('0x1f')]==0x6&&_0x3f73a6[_0xe387('0x18')]!=_0xe387('0x21')){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x22'),_0x3f73a6['uniqueid'],_0x3f73a6['linkedid'],_0x3f73a6[_0xe387('0x18')],_0x3f73a6['channel']));channels[_0x3f73a6[_0xe387('0x13')]][_0xe387('0xc')]=_0x3f73a6[_0xe387('0xc')];channels[_0x3f73a6['linkedid']][_0xe387('0x23')]=_0x3f73a6[_0xe387('0x7')];if(_[_0xe387('0x1e')](channels[_0x3f73a6[_0xe387('0x13')]][_0xe387('0x24')])){channels[_0x3f73a6[_0xe387('0x13')]][_0xe387('0x24')]=utils[_0xe387('0x19')]();}channels[_0x3f73a6[_0xe387('0x13')]][_0xe387('0x25')]=dispositions[_[_0xe387('0x26')](_0x3f73a6[_0xe387('0x1f')])]||'ANSWERED';}}catch(_0x18d81d){utils[_0xe387('0x1b')](util[_0xe387('0x5')](_0xe387('0x1d'),_0x3f73a6[_0xe387('0x6')]),_0x18d81d);}};exports['hangup']=function(_0xa23cba){try{if(!_[_0xe387('0x1e')](channels[_0xa23cba['uniqueid']])){utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x27'),_0xa23cba['uniqueid']),_0xa23cba);if(_[_0xe387('0x1e')](channels[_0xa23cba[_0xe387('0x6')]][_0xe387('0x28')])){channels[_0xa23cba[_0xe387('0x6')]]['callerid']=_0xa23cba[_0xe387('0x29')]+'\x20<'+_0xa23cba[_0xe387('0x17')]+'>';}utils['info'](util[_0xe387('0x5')](_0xe387('0x2a'),_0xa23cba['uniqueid'],channels[_0xa23cba[_0xe387('0x6')]][_0xe387('0x28')],_0xa23cba[_0xe387('0x2b')]));channels[_0xa23cba['uniqueid']][_0xe387('0x2c')]=utils[_0xe387('0x19')]();channels[_0xa23cba[_0xe387('0x6')]]['duration']=utils[_0xe387('0x2d')](channels[_0xa23cba[_0xe387('0x6')]][_0xe387('0x2c')],channels[_0xa23cba[_0xe387('0x6')]][_0xe387('0x2e')]);channels[_0xa23cba['uniqueid']]['billableseconds']=channels[_0xa23cba['uniqueid']][_0xe387('0x24')]?utils[_0xe387('0x2d')](channels[_0xa23cba[_0xe387('0x6')]][_0xe387('0x2c')],channels[_0xa23cba[_0xe387('0x6')]]['answertime']):0x0;writeDB(channels[_0xa23cba[_0xe387('0x6')]]);}}catch(_0x2378ff){utils[_0xe387('0x1b')](util[_0xe387('0x5')]('[%s][calls][hangup]',_0xa23cba[_0xe387('0x6')]),_0x2378ff);}};exports['attendedtransfer']=function(_0x1c1827){try{if(!_[_0xe387('0x1e')](channels[_0x1c1827[_0xe387('0x2f')]])){utils['debug'](util[_0xe387('0x5')]('[%s][calls][attendedtransfer]',_0x1c1827['origtransfereruniqueid']),_0x1c1827);if(channels[_0x1c1827[_0xe387('0x2f')]][_0xe387('0x7')]==_0x1c1827[_0xe387('0x30')]){utils['info'](util['format'](_0xe387('0x31'),_0x1c1827[_0xe387('0x32')],_0x1c1827[_0xe387('0x2f')],_0x1c1827['secondtransfererchannel']));channels[_0x1c1827[_0xe387('0x2f')]][_0xe387('0x23')]=_0x1c1827['secondtransfererchannel'];channels[_0x1c1827[_0xe387('0x2f')]]['userfield']=_0xe387('0x33');}else if(channels[_0x1c1827[_0xe387('0x2f')]][_0xe387('0x7')]=_0x1c1827[_0xe387('0x34')]){utils['info'](util[_0xe387('0x5')]('[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s',_0x1c1827[_0xe387('0x32')],_0x1c1827[_0xe387('0x2f')],_0x1c1827[_0xe387('0x35')]));channels[_0x1c1827[_0xe387('0x2f')]][_0xe387('0x23')]=_0x1c1827[_0xe387('0x35')];channels[_0x1c1827[_0xe387('0x2f')]][_0xe387('0x36')]=_0xe387('0x33');}}}catch(_0x32f506){utils[_0xe387('0x1b')](util[_0xe387('0x5')](_0xe387('0x37'),_0x1c1827[_0xe387('0x32')]),_0x32f506);}};exports[_0xe387('0x38')]=function(_0x30db11){try{if(!_['isNil'](channels[_0x30db11[_0xe387('0x6')]])){utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x39'),_0x30db11['uniqueid']),_0x30db11);channels[_0x30db11[_0xe387('0x6')]][_0xe387('0x3a')]=utils[_0xe387('0x19')]();utils['info'](util[_0xe387('0x5')]('[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s',_0x30db11[_0xe387('0x6')],channels[_0x30db11[_0xe387('0x6')]]['musiconholdstartAt']));}}catch(_0x1af1eb){utils['error'](util['format'](_0xe387('0x39'),_0x30db11[_0xe387('0x6')]),_0x1af1eb);}};exports[_0xe387('0x3b')]=function(_0x43d437){try{if(!_[_0xe387('0x1e')](channels[_0x43d437[_0xe387('0x6')]])){utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x3c'),_0x43d437[_0xe387('0x6')]),_0x43d437);if(!_[_0xe387('0x1e')](channels[_0x43d437['uniqueid']][_0xe387('0x3a')])){channels[_0x43d437[_0xe387('0x6')]][_0xe387('0x3d')]+=utils[_0xe387('0x2d')](utils[_0xe387('0x19')](),channels[_0x43d437['uniqueid']][_0xe387('0x3a')]);utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x3e'),_0x43d437[_0xe387('0x6')],channels[_0x43d437[_0xe387('0x6')]][_0xe387('0x3d')]));delete channels[_0x43d437[_0xe387('0x6')]][_0xe387('0x3a')];}}}catch(_0x52e276){utils[_0xe387('0x1b')](util[_0xe387('0x5')](_0xe387('0x3c'),_0x43d437['uniqueid']),_0x52e276);}};exports[_0xe387('0x3f')]=function(_0x2ae807){try{if(!_[_0xe387('0x1e')](channels[_0x2ae807[_0xe387('0x6')]])){utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x40'),_0x2ae807[_0xe387('0x6')]),_0x2ae807);if(!_['isNil'](_0x2ae807[_0xe387('0x41')][_0xe387('0x42')])){utils['info'](util[_0xe387('0x5')](_0xe387('0x43'),_0x2ae807[_0xe387('0x6')],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]][_0xe387('0x45')]=_0x2ae807[_0xe387('0x44')];}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')][_0xe387('0x46')])){utils[_0xe387('0x4')](util['format']('[%s][calls][varset]\x20variable:xmd-phone\x20value:%s',_0x2ae807['uniqueid'],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]]['destination']=_0x2ae807['value'];channels[_0x2ae807[_0xe387('0x6')]][_0xe387('0x28')]='\x22'+_0x2ae807[_0xe387('0x44')]+_0xe387('0x47')+_0x2ae807[_0xe387('0x44')]+'>';}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')][_0xe387('0x48')])||!_['isNil'](_0x2ae807['variable'][_0xe387('0x49')])){utils[_0xe387('0x4')](util['format'](_0xe387('0x4a'),_0x2ae807[_0xe387('0x6')],!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')]['xmd-callerid-preview'])?'xmd-callerid-preview':_0xe387('0x49'),_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]][_0xe387('0x28')]=_0x2ae807['value'];}if(!_[_0xe387('0x1e')](_0x2ae807['variable'][_0xe387('0x4b')])||!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')][_0xe387('0x4c')])){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x4a'),_0x2ae807[_0xe387('0x6')],!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')]['xmd-queue'])?_0xe387('0x4b'):'xmcs-queue',_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807['uniqueid']]['lastapplication']=_0xe387('0x4d');channels[_0x2ae807[_0xe387('0x6')]]['lastdata']=_0x2ae807[_0xe387('0x44')];channels[_0x2ae807[_0xe387('0x6')]][_0xe387('0x4e')]=!![];}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')][_0xe387('0x4f')])){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x50'),_0x2ae807[_0xe387('0x6')],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]][_0xe387('0x51')]=_0x2ae807['value'];}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')][_0xe387('0x52')])){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x53'),_0x2ae807[_0xe387('0x6')],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]]['type']=_0x2ae807[_0xe387('0x44')];}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')]['outboundrouteid'])){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x54'),_0x2ae807[_0xe387('0x6')],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807['uniqueid']]['routeid']=_0x2ae807[_0xe387('0x44')];}if(!_[_0xe387('0x1e')](_0x2ae807[_0xe387('0x41')]['sipcallid'])){utils[_0xe387('0x4')](util[_0xe387('0x5')](_0xe387('0x55'),_0x2ae807['uniqueid'],_0x2ae807[_0xe387('0x44')]));channels[_0x2ae807[_0xe387('0x6')]]['sipcallid']=_0x2ae807[_0xe387('0x44')];}}}catch(_0x5930ef){utils['error'](util[_0xe387('0x5')](_0xe387('0x40'),_0x2ae807[_0xe387('0x6')]),_0x5930ef);}};exports['newexten']=function(_0x1ab141){try{if(!_[_0xe387('0x1e')](channels[_0x1ab141[_0xe387('0x6')]])){utils[_0xe387('0x12')](util[_0xe387('0x5')](_0xe387('0x56'),_0x1ab141[_0xe387('0x6')]),_0x1ab141);utils[_0xe387('0x4')](util['format'](_0xe387('0x57'),_0x1ab141[_0xe387('0x6')],_0x1ab141[_0xe387('0x58')],_0x1ab141[_0xe387('0x59')]));if(_0x1ab141['application'][_0xe387('0x5a')]()==_0xe387('0x5b')&&_[_0xe387('0x5c')](_0x1ab141[_0xe387('0x59')][_0xe387('0x5a')](),'cdr')){var _0x111ccf=_0x1ab141[_0xe387('0x59')][_0xe387('0x5d')]('=');var _0x441488=_0x111ccf[0x0][_0xe387('0x5e')](_0x111ccf[0x0]['lastIndexOf']('(')+0x1,_0x111ccf[0x0][_0xe387('0x5f')](')'));var _0x3a64f9=_0x111ccf[0x1];channels[_0x1ab141[_0xe387('0x6')]][_0x441488]=_0x3a64f9;}if(!_[_0xe387('0x60')]([_0xe387('0x61'),'noop',_0xe387('0x62'),_0xe387('0x5b'),_0xe387('0x63')],_0x1ab141[_0xe387('0x58')][_0xe387('0x5a')]())){channels[_0x1ab141['uniqueid']][_0xe387('0x64')]=_0x1ab141['application'];channels[_0x1ab141[_0xe387('0x6')]]['lastdata']=_0x1ab141['appdata'];}}}catch(_0x2199cb){utils[_0xe387('0x1b')](util['format']('[%s][calls][newexten]',_0x1ab141[_0xe387('0x6')]),_0x2199cb);}};
\ No newline at end of file