Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / services / xdr / calls.controller.js
index c8e1546..474e747 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xba69=['lastIndexOf','includes','noop','execif','gotoif','util','FAILED','NO\x20ANSWER','ANSWERED','BUSY','info','format','uniqueid','queue','interface','calleridnum','connectedlinenum','lastevent','getUserByInternal','accountcode','then','UserId','CreateVoiceCallReport','request','newchannel','[%s][calls][newchannel]','linkedid','channel','OutgoingSpoolFailed','[%s][calls][newchannel]\x20context:%s\x20exten:%s','context','exten','DOCUMENTATION','error','debug','[%s][calls][newstate]','isNil','channelstate','[%s][calls][newstate]\x20context:%s\x20channel:%s','systemanswertime','now','[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','destinationchannel','answertime','toNumber','hangup','[%s][calls][hangup]','callerid','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','cause-txt','endtime','duration','diffTime','starttime','attendedtransfer','localtwolinkedid','transfereechannel','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','origtransfereruniqueid','secondtransfererchannel','userfield','_attended','origtransfererchannel','[%s][calls][attendedtransfer]','musiconholdstart','[%s][calls][musiconholdstart]','musiconholdstartAt','[%s][calls][musiconholdstop]','mohtime','[%s][calls][musiconholdstop]\x20mohtime:%s','[%s][calls][varset]','variable','xmd-originatecalleridnum','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','value','source','xmd-phone','[%s][calls][varset]\x20variable:xmd-phone\x20value:%s','destination','\x22\x20<','xmd-callerid','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-callerid-preview','xmd-queue','xmcs-queue','lastapplication','lastdata','xmd-contactid','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','ContactId','xmd-cdrtype','type','outboundrouteid','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','routeid','sipcallid','[%s][calls][varset]\x20variable:sipcallid\x20value:%s','newexten','[%s][calls][newexten]\x20application:%s\x20appdata:%s','application','toLowerCase','set','startsWith','appdata','split'];(function(_0x23f642,_0x3c8f66){var _0x4ba0d0=function(_0x507a88){while(--_0x507a88){_0x23f642['push'](_0x23f642['shift']());}};_0x4ba0d0(++_0x3c8f66);}(_0xba69,0x6e));var _0x9ba6=function(_0xc9b9c1,_0x49714a){_0xc9b9c1=_0xc9b9c1-0x0;var _0xf0aa3e=_0xba69[_0xc9b9c1];return _0xf0aa3e;};'use strict';var _=require('lodash');var util=require(_0x9ba6('0x0'));var utils=require('./utils');var dispositions=['NO\x20ANSWER',_0x9ba6('0x1'),_0x9ba6('0x1'),_0x9ba6('0x2'),_0x9ba6('0x2'),_0x9ba6('0x2'),_0x9ba6('0x3'),_0x9ba6('0x4'),_0x9ba6('0x1'),_0x9ba6('0x1'),_0x9ba6('0x1')];var channels={};function writeDB(_0x19f968){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')]('[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s',_0x19f968[_0x9ba6('0x7')],_0x19f968['channel'],_0x19f968[_0x9ba6('0x8')],_0x19f968['membername'],_0x19f968[_0x9ba6('0x9')],_0x19f968[_0x9ba6('0xa')],_0x19f968[_0x9ba6('0xb')],_0x19f968[_0x9ba6('0xc')]));if(_0x19f968['accountcode']){utils[_0x9ba6('0xd')](_0x19f968[_0x9ba6('0xe')])[_0x9ba6('0xf')](function(_0x11b4fb){if(_0x11b4fb){_0x19f968[_0x9ba6('0x10')]=_0x11b4fb['id'];}utils['request'](_0x9ba6('0x11'),_0x19f968);});}else{utils[_0x9ba6('0x12')](_0x9ba6('0x11'),_0x19f968);}if(channels[_0x19f968[_0x9ba6('0x7')]]){delete channels[_0x19f968[_0x9ba6('0x7')]];}}exports[_0x9ba6('0x13')]=function(_0xa53c1a){try{utils['debug'](util[_0x9ba6('0x6')](_0x9ba6('0x14'),_0xa53c1a[_0x9ba6('0x7')]),_0xa53c1a);if(_0xa53c1a['uniqueid']==_0xa53c1a[_0x9ba6('0x15')]&&_0xa53c1a[_0x9ba6('0x16')]!=_0x9ba6('0x17')){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x18'),_0xa53c1a[_0x9ba6('0x7')],_0xa53c1a[_0x9ba6('0x19')],_0xa53c1a['exten']));channels[_0xa53c1a[_0x9ba6('0x7')]]={'uniqueid':_0xa53c1a[_0x9ba6('0x7')],'accountcode':_0xa53c1a[_0x9ba6('0xe')],'source':_0xa53c1a['calleridnum'],'destination':_0xa53c1a[_0x9ba6('0x1a')],'destinationcontext':_0xa53c1a[_0x9ba6('0x19')],'channel':_0xa53c1a[_0x9ba6('0x16')],'starttime':utils['now'](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':_0x9ba6('0x2'),'amaflags':_0x9ba6('0x1b')};}}catch(_0x28d201){utils[_0x9ba6('0x1c')](util['format']('[%s][calls][newchannel]',_0xa53c1a[_0x9ba6('0x7')]),_0x28d201);}};exports['newstate']=function(_0x19fc92){try{utils[_0x9ba6('0x1d')](util[_0x9ba6('0x6')](_0x9ba6('0x1e'),_0x19fc92[_0x9ba6('0x7')]),_0x19fc92);if(!_[_0x9ba6('0x1f')](channels[_0x19fc92[_0x9ba6('0x7')]])&&_0x19fc92[_0x9ba6('0x20')]==0x6){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x21'),_0x19fc92[_0x9ba6('0x7')],_0x19fc92[_0x9ba6('0x19')],_0x19fc92[_0x9ba6('0x16')]));if(_[_0x9ba6('0x1f')](channels[_0x19fc92['uniqueid']][_0x9ba6('0x22')])){channels[_0x19fc92[_0x9ba6('0x7')]][_0x9ba6('0x22')]=utils[_0x9ba6('0x23')]();}}else if(!_[_0x9ba6('0x1f')](channels[_0x19fc92[_0x9ba6('0x15')]])&&_0x19fc92[_0x9ba6('0x20')]==0x6&&_0x19fc92[_0x9ba6('0x19')]!='transfer'){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x24'),_0x19fc92[_0x9ba6('0x7')],_0x19fc92[_0x9ba6('0x15')],_0x19fc92[_0x9ba6('0x19')],_0x19fc92[_0x9ba6('0x16')]));channels[_0x19fc92['linkedid']]['accountcode']=_0x19fc92[_0x9ba6('0xe')];channels[_0x19fc92[_0x9ba6('0x15')]][_0x9ba6('0x25')]=_0x19fc92[_0x9ba6('0x16')];if(_['isNil'](channels[_0x19fc92[_0x9ba6('0x15')]][_0x9ba6('0x26')])){channels[_0x19fc92[_0x9ba6('0x15')]][_0x9ba6('0x26')]=utils[_0x9ba6('0x23')]();}channels[_0x19fc92[_0x9ba6('0x15')]]['disposition']=dispositions[_[_0x9ba6('0x27')](_0x19fc92[_0x9ba6('0x20')])]||_0x9ba6('0x3');}}catch(_0x27b11a){utils[_0x9ba6('0x1c')](util[_0x9ba6('0x6')](_0x9ba6('0x1e'),_0x19fc92[_0x9ba6('0x7')]),_0x27b11a);}};exports[_0x9ba6('0x28')]=function(_0x598325){try{if(!_[_0x9ba6('0x1f')](channels[_0x598325[_0x9ba6('0x7')]])){utils[_0x9ba6('0x1d')](util[_0x9ba6('0x6')](_0x9ba6('0x29'),_0x598325['uniqueid']),_0x598325);if(_[_0x9ba6('0x1f')](channels[_0x598325['uniqueid']][_0x9ba6('0x2a')])){channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x2a')]=_0x598325['calleridname']+'\x20<'+_0x598325['calleridnum']+'>';}utils[_0x9ba6('0x5')](util['format'](_0x9ba6('0x2b'),_0x598325['uniqueid'],channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x2a')],_0x598325[_0x9ba6('0x2c')]));channels[_0x598325['uniqueid']][_0x9ba6('0x2d')]=utils['now']();channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x2e')]=utils[_0x9ba6('0x2f')](channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x2d')],channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x30')]);channels[_0x598325['uniqueid']]['billableseconds']=channels[_0x598325['uniqueid']][_0x9ba6('0x26')]?utils[_0x9ba6('0x2f')](channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x2d')],channels[_0x598325[_0x9ba6('0x7')]][_0x9ba6('0x26')]):0x0;writeDB(channels[_0x598325[_0x9ba6('0x7')]]);}}catch(_0x35ff02){utils[_0x9ba6('0x1c')](util[_0x9ba6('0x6')](_0x9ba6('0x29'),_0x598325['uniqueid']),_0x35ff02);}};exports[_0x9ba6('0x31')]=function(_0x22c2d0){try{if(!_['isNil'](channels[_0x22c2d0[_0x9ba6('0x32')]])){utils['debug'](util[_0x9ba6('0x6')]('[%s][calls][attendedtransfer]',_0x22c2d0['origtransfereruniqueid']),_0x22c2d0);if(channels[_0x22c2d0[_0x9ba6('0x32')]][_0x9ba6('0x16')]==_0x22c2d0[_0x9ba6('0x33')]){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x34'),_0x22c2d0[_0x9ba6('0x35')],_0x22c2d0['localtwolinkedid'],_0x22c2d0['secondtransfererchannel']));channels[_0x22c2d0[_0x9ba6('0x32')]][_0x9ba6('0x25')]=_0x22c2d0[_0x9ba6('0x36')];channels[_0x22c2d0[_0x9ba6('0x32')]][_0x9ba6('0x37')]=_0x9ba6('0x38');}else if(channels[_0x22c2d0[_0x9ba6('0x32')]][_0x9ba6('0x16')]=_0x22c2d0['transfertargetchannel']){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x34'),_0x22c2d0[_0x9ba6('0x35')],_0x22c2d0['localtwolinkedid'],_0x22c2d0[_0x9ba6('0x39')]));channels[_0x22c2d0[_0x9ba6('0x32')]]['destinationchannel']=_0x22c2d0[_0x9ba6('0x39')];channels[_0x22c2d0[_0x9ba6('0x32')]][_0x9ba6('0x37')]=_0x9ba6('0x38');}}}catch(_0x21f86d){utils[_0x9ba6('0x1c')](util[_0x9ba6('0x6')](_0x9ba6('0x3a'),_0x22c2d0[_0x9ba6('0x35')]),_0x21f86d);}};exports[_0x9ba6('0x3b')]=function(_0x58cf31){try{if(!_[_0x9ba6('0x1f')](channels[_0x58cf31[_0x9ba6('0x7')]])){utils[_0x9ba6('0x1d')](util['format'](_0x9ba6('0x3c'),_0x58cf31[_0x9ba6('0x7')]),_0x58cf31);channels[_0x58cf31[_0x9ba6('0x7')]]['musiconholdstartAt']=utils['now']();utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')]('[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s',_0x58cf31[_0x9ba6('0x7')],channels[_0x58cf31[_0x9ba6('0x7')]][_0x9ba6('0x3d')]));}}catch(_0x4a6d3c){utils[_0x9ba6('0x1c')](util['format'](_0x9ba6('0x3c'),_0x58cf31[_0x9ba6('0x7')]),_0x4a6d3c);}};exports['musiconholdstop']=function(_0x33f73f){try{if(!_[_0x9ba6('0x1f')](channels[_0x33f73f[_0x9ba6('0x7')]])){utils[_0x9ba6('0x1d')](util[_0x9ba6('0x6')](_0x9ba6('0x3e'),_0x33f73f[_0x9ba6('0x7')]),_0x33f73f);if(!_[_0x9ba6('0x1f')](channels[_0x33f73f[_0x9ba6('0x7')]][_0x9ba6('0x3d')])){channels[_0x33f73f[_0x9ba6('0x7')]][_0x9ba6('0x3f')]+=utils['diffTime'](utils[_0x9ba6('0x23')](),channels[_0x33f73f[_0x9ba6('0x7')]]['musiconholdstartAt']);utils['info'](util[_0x9ba6('0x6')](_0x9ba6('0x40'),_0x33f73f[_0x9ba6('0x7')],channels[_0x33f73f[_0x9ba6('0x7')]]['mohtime']));delete channels[_0x33f73f[_0x9ba6('0x7')]][_0x9ba6('0x3d')];}}}catch(_0x49d1a4){utils['error'](util['format'](_0x9ba6('0x3e'),_0x33f73f[_0x9ba6('0x7')]),_0x49d1a4);}};exports['varset']=function(_0x432412){try{if(!_[_0x9ba6('0x1f')](channels[_0x432412[_0x9ba6('0x7')]])){utils[_0x9ba6('0x1d')](util[_0x9ba6('0x6')](_0x9ba6('0x41'),_0x432412[_0x9ba6('0x7')]),_0x432412);if(!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x43')])){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x44'),_0x432412[_0x9ba6('0x7')],_0x432412[_0x9ba6('0x45')]));channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x46')]=_0x432412[_0x9ba6('0x45')];}if(!_['isNil'](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x47')])){utils['info'](util['format'](_0x9ba6('0x48'),_0x432412[_0x9ba6('0x7')],_0x432412[_0x9ba6('0x45')]));channels[_0x432412['uniqueid']][_0x9ba6('0x49')]=_0x432412[_0x9ba6('0x45')];channels[_0x432412['uniqueid']]['callerid']='\x22'+_0x432412[_0x9ba6('0x45')]+_0x9ba6('0x4a')+_0x432412['value']+'>';}if(!_['isNil'](_0x432412['variable']['xmd-callerid-preview'])||!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x4b')])){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x4c'),_0x432412[_0x9ba6('0x7')],!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x4d')])?_0x9ba6('0x4d'):_0x9ba6('0x4b'),_0x432412[_0x9ba6('0x45')]));channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x2a')]=_0x432412['value'];}if(!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x4e')])||!_['isNil'](_0x432412['variable']['xmcs-queue'])){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')]('[%s][calls][varset]\x20variable:%s\x20value:%s',_0x432412[_0x9ba6('0x7')],!_['isNil'](_0x432412[_0x9ba6('0x42')]['xmd-queue'])?_0x9ba6('0x4e'):_0x9ba6('0x4f'),_0x432412[_0x9ba6('0x45')]));channels[_0x432412['uniqueid']][_0x9ba6('0x50')]='Queue';channels[_0x432412['uniqueid']][_0x9ba6('0x51')]=_0x432412[_0x9ba6('0x45')];channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x8')]=!![];}if(!_[_0x9ba6('0x1f')](_0x432412['variable'][_0x9ba6('0x52')])){utils['info'](util[_0x9ba6('0x6')](_0x9ba6('0x53'),_0x432412[_0x9ba6('0x7')],_0x432412[_0x9ba6('0x45')]));channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x54')]=_0x432412[_0x9ba6('0x45')];}if(!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x55')])){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')]('[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s',_0x432412[_0x9ba6('0x7')],_0x432412['value']));channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x56')]=_0x432412[_0x9ba6('0x45')];}if(!_['isNil'](_0x432412['variable'][_0x9ba6('0x57')])){utils['info'](util[_0x9ba6('0x6')](_0x9ba6('0x58'),_0x432412[_0x9ba6('0x7')],_0x432412[_0x9ba6('0x45')]));channels[_0x432412[_0x9ba6('0x7')]][_0x9ba6('0x59')]=_0x432412[_0x9ba6('0x45')];}if(!_[_0x9ba6('0x1f')](_0x432412[_0x9ba6('0x42')][_0x9ba6('0x5a')])){utils[_0x9ba6('0x5')](util[_0x9ba6('0x6')](_0x9ba6('0x5b'),_0x432412[_0x9ba6('0x7')],_0x432412[_0x9ba6('0x45')]));channels[_0x432412[_0x9ba6('0x7')]]['sipcallid']=_0x432412[_0x9ba6('0x45')];}}}catch(_0x25e04d){utils[_0x9ba6('0x1c')](util['format'](_0x9ba6('0x41'),_0x432412[_0x9ba6('0x7')]),_0x25e04d);}};exports[_0x9ba6('0x5c')]=function(_0x3a6650){try{if(!_[_0x9ba6('0x1f')](channels[_0x3a6650['uniqueid']])){utils[_0x9ba6('0x1d')](util[_0x9ba6('0x6')]('[%s][calls][newexten]',_0x3a6650[_0x9ba6('0x7')]),_0x3a6650);utils[_0x9ba6('0x5')](util['format'](_0x9ba6('0x5d'),_0x3a6650['uniqueid'],_0x3a6650[_0x9ba6('0x5e')],_0x3a6650['appdata']));if(_0x3a6650[_0x9ba6('0x5e')][_0x9ba6('0x5f')]()==_0x9ba6('0x60')&&_[_0x9ba6('0x61')](_0x3a6650[_0x9ba6('0x62')][_0x9ba6('0x5f')](),'cdr')){var _0x1ddf66=_0x3a6650[_0x9ba6('0x62')][_0x9ba6('0x63')]('=');var _0x7a7081=_0x1ddf66[0x0]['substring'](_0x1ddf66[0x0][_0x9ba6('0x64')]('(')+0x1,_0x1ddf66[0x0]['lastIndexOf'](')'));var _0x104051=_0x1ddf66[0x1];channels[_0x3a6650[_0x9ba6('0x7')]][_0x7a7081]=_0x104051;}if(!_[_0x9ba6('0x65')]([_0x9ba6('0x28'),_0x9ba6('0x66'),_0x9ba6('0x67'),_0x9ba6('0x60'),_0x9ba6('0x68')],_0x3a6650[_0x9ba6('0x5e')][_0x9ba6('0x5f')]())){channels[_0x3a6650[_0x9ba6('0x7')]]['lastapplication']=_0x3a6650[_0x9ba6('0x5e')];channels[_0x3a6650[_0x9ba6('0x7')]][_0x9ba6('0x51')]=_0x3a6650[_0x9ba6('0x62')];}}}catch(_0x31f643){utils[_0x9ba6('0x1c')](util[_0x9ba6('0x6')]('[%s][calls][newexten]',_0x3a6650[_0x9ba6('0x7')]),_0x31f643);}};
\ No newline at end of file
+var _0x2862=['application','startsWith','toLowerCase','split','substring','lastIndexOf','includes','noop','execif','set','gotoif','lodash','util','./utils','./transfers.controller','FAILED','NO\x20ANSWER','ANSWERED','BUSY','uniqueid','blinds','info','queue','interface','connectedlinenum','accountcode','getUserByInternal','then','UserId','CreateVoiceCallReport','request','newchannel','debug','[%s][calls][newchannel]','channel','OutgoingSpoolFailed','format','context','calleridnum','now','DOCUMENTATION','newstate','[%s][calls][newstate]','isNil','[%s][calls][newstate]\x20context:%s\x20channel:%s','systemanswertime','linkedid','channelstate','[%s][calls][newstate]\x20linkedid:%s\x20context:%s\x20channel:%s','destinationchannel','answertime','disposition','error','hangup','callerid','calleridname','[%s][calls][hangup]\x20callerid:%s\x20reason:%s','cause-txt','endtime','duration','diffTime','starttime','[%s][calls][hangup]','attendedtransfer','localtwolinkedid','origtransfereruniqueid','[%s][calls][attendedtransfer]\x20localtwolinkedid:%s\x20destinationchannel:%s','secondtransfererchannel','_attended','origtransfererchannel','userfield','[%s][calls][attendedtransfer]','musiconholdstartAt','[%s][calls][musiconholdstart]\x20musiconholdstartAt:%s','[%s][calls][musiconholdstart]','musiconholdstop','[%s][calls][musiconholdstop]','mohtime','varset','[%s][calls][varset]','variable','xmd-originatecalleridnum','[%s][calls][varset]\x20variable:xmd-originatecalleridnum\x20value:%s','value','xmd-phone','[%s][calls][varset]\x20variable:xmd-phone\x20value:%s','destination','\x22\x20<','xmd-callerid','[%s][calls][varset]\x20variable:%s\x20value:%s','xmd-callerid-preview','xmd-queue','xmcs-queue','lastapplication','Queue','lastdata','[%s][calls][varset]\x20variable:xmd-contactid\x20value:%s','ContactId','xmd-cdrtype','type','[%s][calls][varset]\x20variable:outboundrouteid\x20value:%s','sipcallid','[%s][calls][newexten]','[%s][calls][newexten]\x20application:%s\x20appdata:%s','appdata'];(function(_0x4e55df,_0x13821d){var _0x5904eb=function(_0x30edf5){while(--_0x30edf5){_0x4e55df['push'](_0x4e55df['shift']());}};_0x5904eb(++_0x13821d);}(_0x2862,0x74));var _0x2286=function(_0x9b22a4,_0x52162c){_0x9b22a4=_0x9b22a4-0x0;var _0xcad23b=_0x2862[_0x9b22a4];return _0xcad23b;};'use strict';var _=require(_0x2286('0x0'));var util=require(_0x2286('0x1'));var utils=require(_0x2286('0x2'));var transfers=require(_0x2286('0x3'));var dispositions=['NO\x20ANSWER',_0x2286('0x4'),'FAILED',_0x2286('0x5'),_0x2286('0x5'),_0x2286('0x5'),_0x2286('0x6'),_0x2286('0x7'),_0x2286('0x4'),'FAILED','FAILED'];var channels={};function writeDB(_0x392d9d){var _0x2778da;if(transfers['blinds'][_0x392d9d[_0x2286('0x8')]]){_0x2778da=_0x392d9d[_0x2286('0x8')];_0x392d9d[_0x2286('0x8')]=transfers[_0x2286('0x9')][_0x392d9d['uniqueid']]['transfereeuniqueid'];}utils[_0x2286('0xa')](util['format']('[%s][calls][writeDB]\x20channel:%s\x20queue:%s\x20agent:%s\x20interface:%s\x20calleridnum:%s\x20connectedlinenum:%s\x20lastevent:%s',_0x392d9d['uniqueid'],_0x392d9d['channel'],_0x392d9d[_0x2286('0xb')],_0x392d9d['membername'],_0x392d9d[_0x2286('0xc')],_0x392d9d['calleridnum'],_0x392d9d[_0x2286('0xd')],_0x392d9d['lastevent']));if(_0x392d9d[_0x2286('0xe')]){utils[_0x2286('0xf')](_0x392d9d[_0x2286('0xe')])[_0x2286('0x10')](function(_0x41d32a){if(_0x41d32a){_0x392d9d[_0x2286('0x11')]=_0x41d32a['id'];}utils['request'](_0x2286('0x12'),_0x392d9d);});}else{utils[_0x2286('0x13')]('CreateVoiceCallReport',_0x392d9d);}if(channels[_0x392d9d[_0x2286('0x8')]]){delete channels[_0x392d9d['uniqueid']];}else if(_0x2778da&&channels[_0x2778da]){delete transfers[_0x2286('0x9')][_0x2778da];delete channels[_0x2778da];}}exports[_0x2286('0x14')]=function(_0x31986b){try{utils[_0x2286('0x15')](util['format'](_0x2286('0x16'),_0x31986b[_0x2286('0x8')]),_0x31986b);if(_0x31986b[_0x2286('0x8')]==_0x31986b['linkedid']&&_0x31986b[_0x2286('0x17')]!=_0x2286('0x18')){utils[_0x2286('0xa')](util[_0x2286('0x19')]('[%s][calls][newchannel]\x20context:%s\x20exten:%s',_0x31986b[_0x2286('0x8')],_0x31986b[_0x2286('0x1a')],_0x31986b['exten']));channels[_0x31986b[_0x2286('0x8')]]={'uniqueid':_0x31986b[_0x2286('0x8')],'accountcode':_0x31986b[_0x2286('0xe')],'source':_0x31986b[_0x2286('0x1b')],'destination':_0x31986b['exten'],'destinationcontext':_0x31986b[_0x2286('0x1a')],'channel':_0x31986b['channel'],'starttime':utils[_0x2286('0x1c')](),'answertime':null,'systemanswertime':null,'mohtime':0x0,'disposition':_0x2286('0x5'),'amaflags':_0x2286('0x1d')};}}catch(_0x248c6c){utils['error'](util[_0x2286('0x19')](_0x2286('0x16'),_0x31986b[_0x2286('0x8')]),_0x248c6c);}};exports[_0x2286('0x1e')]=function(_0x4db053){try{utils[_0x2286('0x15')](util[_0x2286('0x19')](_0x2286('0x1f'),_0x4db053[_0x2286('0x8')]),_0x4db053);if(!_[_0x2286('0x20')](channels[_0x4db053['uniqueid']])&&_0x4db053['channelstate']==0x6){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x21'),_0x4db053[_0x2286('0x8')],_0x4db053['context'],_0x4db053[_0x2286('0x17')]));if(_['isNil'](channels[_0x4db053[_0x2286('0x8')]]['systemanswertime'])){channels[_0x4db053['uniqueid']][_0x2286('0x22')]=utils[_0x2286('0x1c')]();}}else if(!_[_0x2286('0x20')](channels[_0x4db053[_0x2286('0x23')]])&&_0x4db053[_0x2286('0x24')]==0x6&&_0x4db053[_0x2286('0x1a')]!='transfer'){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x25'),_0x4db053[_0x2286('0x8')],_0x4db053[_0x2286('0x23')],_0x4db053['context'],_0x4db053[_0x2286('0x17')]));channels[_0x4db053[_0x2286('0x23')]][_0x2286('0xe')]=_0x4db053['accountcode'];channels[_0x4db053['linkedid']][_0x2286('0x26')]=_0x4db053[_0x2286('0x17')];if(_[_0x2286('0x20')](channels[_0x4db053['linkedid']][_0x2286('0x27')])){channels[_0x4db053[_0x2286('0x23')]][_0x2286('0x27')]=utils[_0x2286('0x1c')]();}channels[_0x4db053[_0x2286('0x23')]][_0x2286('0x28')]=dispositions[_['toNumber'](_0x4db053['channelstate'])]||_0x2286('0x6');}}catch(_0x280f19){utils[_0x2286('0x29')](util['format'](_0x2286('0x1f'),_0x4db053['uniqueid']),_0x280f19);}};exports[_0x2286('0x2a')]=function(_0x4adb39){try{if(!_[_0x2286('0x20')](channels[_0x4adb39[_0x2286('0x8')]])){utils[_0x2286('0x15')](util[_0x2286('0x19')]('[%s][calls][hangup]',_0x4adb39[_0x2286('0x8')]),_0x4adb39);if(_[_0x2286('0x20')](channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x2b')])){channels[_0x4adb39['uniqueid']][_0x2286('0x2b')]=_0x4adb39[_0x2286('0x2c')]+'\x20<'+_0x4adb39['calleridnum']+'>';}utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x2d'),_0x4adb39[_0x2286('0x8')],channels[_0x4adb39['uniqueid']]['callerid'],_0x4adb39[_0x2286('0x2e')]));channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x2f')]=utils[_0x2286('0x1c')]();channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x30')]=utils[_0x2286('0x31')](channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x2f')],channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x32')]);channels[_0x4adb39[_0x2286('0x8')]]['billableseconds']=channels[_0x4adb39['uniqueid']]['answertime']?utils['diffTime'](channels[_0x4adb39['uniqueid']][_0x2286('0x2f')],channels[_0x4adb39[_0x2286('0x8')]][_0x2286('0x27')]):0x0;writeDB(channels[_0x4adb39[_0x2286('0x8')]]);}}catch(_0x589311){utils['error'](util[_0x2286('0x19')](_0x2286('0x33'),_0x4adb39[_0x2286('0x8')]),_0x589311);}};exports[_0x2286('0x34')]=function(_0x1e4189){try{if(!_['isNil'](channels[_0x1e4189[_0x2286('0x35')]])){utils[_0x2286('0x15')](util['format']('[%s][calls][attendedtransfer]',_0x1e4189[_0x2286('0x36')]),_0x1e4189);if(channels[_0x1e4189[_0x2286('0x35')]][_0x2286('0x17')]==_0x1e4189['transfereechannel']){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x37'),_0x1e4189[_0x2286('0x36')],_0x1e4189[_0x2286('0x35')],_0x1e4189[_0x2286('0x38')]));channels[_0x1e4189[_0x2286('0x35')]][_0x2286('0x26')]=_0x1e4189[_0x2286('0x38')];channels[_0x1e4189[_0x2286('0x35')]]['userfield']=_0x2286('0x39');}else if(channels[_0x1e4189[_0x2286('0x35')]]['channel']=_0x1e4189['transfertargetchannel']){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x37'),_0x1e4189[_0x2286('0x36')],_0x1e4189[_0x2286('0x35')],_0x1e4189[_0x2286('0x3a')]));channels[_0x1e4189[_0x2286('0x35')]][_0x2286('0x26')]=_0x1e4189[_0x2286('0x3a')];channels[_0x1e4189[_0x2286('0x35')]][_0x2286('0x3b')]=_0x2286('0x39');}}}catch(_0x4ce5e8){utils['error'](util[_0x2286('0x19')](_0x2286('0x3c'),_0x1e4189['origtransfereruniqueid']),_0x4ce5e8);}};exports['musiconholdstart']=function(_0x3e7d02){try{if(!_[_0x2286('0x20')](channels[_0x3e7d02[_0x2286('0x8')]])){utils['debug'](util[_0x2286('0x19')]('[%s][calls][musiconholdstart]',_0x3e7d02['uniqueid']),_0x3e7d02);channels[_0x3e7d02[_0x2286('0x8')]][_0x2286('0x3d')]=utils[_0x2286('0x1c')]();utils[_0x2286('0xa')](util['format'](_0x2286('0x3e'),_0x3e7d02[_0x2286('0x8')],channels[_0x3e7d02['uniqueid']][_0x2286('0x3d')]));}}catch(_0x3dc060){utils[_0x2286('0x29')](util[_0x2286('0x19')](_0x2286('0x3f'),_0x3e7d02[_0x2286('0x8')]),_0x3dc060);}};exports[_0x2286('0x40')]=function(_0x1e2079){try{if(!_['isNil'](channels[_0x1e2079[_0x2286('0x8')]])){utils[_0x2286('0x15')](util[_0x2286('0x19')](_0x2286('0x41'),_0x1e2079[_0x2286('0x8')]),_0x1e2079);if(!_[_0x2286('0x20')](channels[_0x1e2079[_0x2286('0x8')]][_0x2286('0x3d')])){channels[_0x1e2079[_0x2286('0x8')]][_0x2286('0x42')]+=utils[_0x2286('0x31')](utils[_0x2286('0x1c')](),channels[_0x1e2079[_0x2286('0x8')]][_0x2286('0x3d')]);utils[_0x2286('0xa')](util['format']('[%s][calls][musiconholdstop]\x20mohtime:%s',_0x1e2079[_0x2286('0x8')],channels[_0x1e2079[_0x2286('0x8')]][_0x2286('0x42')]));delete channels[_0x1e2079[_0x2286('0x8')]][_0x2286('0x3d')];}}}catch(_0x1ea3ca){utils[_0x2286('0x29')](util['format'](_0x2286('0x41'),_0x1e2079[_0x2286('0x8')]),_0x1ea3ca);}};exports[_0x2286('0x43')]=function(_0x512c07){try{if(!_['isNil'](channels[_0x512c07[_0x2286('0x8')]])){utils[_0x2286('0x15')](util['format'](_0x2286('0x44'),_0x512c07['uniqueid']),_0x512c07);if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x46')])){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x47'),_0x512c07[_0x2286('0x8')],_0x512c07[_0x2286('0x48')]));channels[_0x512c07[_0x2286('0x8')]]['source']=_0x512c07[_0x2286('0x48')];}if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x49')])){utils['info'](util[_0x2286('0x19')](_0x2286('0x4a'),_0x512c07[_0x2286('0x8')],_0x512c07[_0x2286('0x48')]));channels[_0x512c07[_0x2286('0x8')]][_0x2286('0x4b')]=_0x512c07[_0x2286('0x48')];channels[_0x512c07[_0x2286('0x8')]][_0x2286('0x2b')]='\x22'+_0x512c07[_0x2286('0x48')]+_0x2286('0x4c')+_0x512c07[_0x2286('0x48')]+'>';}if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')]['xmd-callerid-preview'])||!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x4d')])){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x4e'),_0x512c07['uniqueid'],!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x4f')])?_0x2286('0x4f'):'xmd-callerid',_0x512c07[_0x2286('0x48')]));channels[_0x512c07[_0x2286('0x8')]]['callerid']=_0x512c07[_0x2286('0x48')];}if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x50')])||!_[_0x2286('0x20')](_0x512c07['variable'][_0x2286('0x51')])){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x4e'),_0x512c07[_0x2286('0x8')],!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')][_0x2286('0x50')])?_0x2286('0x50'):_0x2286('0x51'),_0x512c07['value']));channels[_0x512c07[_0x2286('0x8')]][_0x2286('0x52')]=_0x2286('0x53');channels[_0x512c07['uniqueid']][_0x2286('0x54')]=_0x512c07['value'];channels[_0x512c07[_0x2286('0x8')]][_0x2286('0xb')]=!![];}if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')]['xmd-contactid'])){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x55'),_0x512c07['uniqueid'],_0x512c07['value']));channels[_0x512c07[_0x2286('0x8')]][_0x2286('0x56')]=_0x512c07[_0x2286('0x48')];}if(!_['isNil'](_0x512c07['variable'][_0x2286('0x57')])){utils[_0x2286('0xa')](util['format']('[%s][calls][varset]\x20variable:xmd-cdrtype\x20value:%s',_0x512c07[_0x2286('0x8')],_0x512c07[_0x2286('0x48')]));channels[_0x512c07[_0x2286('0x8')]][_0x2286('0x58')]=_0x512c07[_0x2286('0x48')];}if(!_['isNil'](_0x512c07['variable']['outboundrouteid'])){utils[_0x2286('0xa')](util[_0x2286('0x19')](_0x2286('0x59'),_0x512c07[_0x2286('0x8')],_0x512c07[_0x2286('0x48')]));channels[_0x512c07[_0x2286('0x8')]]['routeid']=_0x512c07['value'];}if(!_[_0x2286('0x20')](_0x512c07[_0x2286('0x45')]['sipcallid'])){utils[_0x2286('0xa')](util[_0x2286('0x19')]('[%s][calls][varset]\x20variable:sipcallid\x20value:%s',_0x512c07['uniqueid'],_0x512c07[_0x2286('0x48')]));channels[_0x512c07['uniqueid']][_0x2286('0x5a')]=_0x512c07[_0x2286('0x48')];}}}catch(_0x345ae2){utils[_0x2286('0x29')](util[_0x2286('0x19')]('[%s][calls][varset]',_0x512c07[_0x2286('0x8')]),_0x345ae2);}};exports['newexten']=function(_0x4f1ac5){try{if(!_['isNil'](channels[_0x4f1ac5['uniqueid']])){utils[_0x2286('0x15')](util[_0x2286('0x19')](_0x2286('0x5b'),_0x4f1ac5['uniqueid']),_0x4f1ac5);utils['info'](util[_0x2286('0x19')](_0x2286('0x5c'),_0x4f1ac5[_0x2286('0x8')],_0x4f1ac5['application'],_0x4f1ac5[_0x2286('0x5d')]));if(_0x4f1ac5[_0x2286('0x5e')]['toLowerCase']()=='set'&&_[_0x2286('0x5f')](_0x4f1ac5[_0x2286('0x5d')][_0x2286('0x60')](),'cdr')){var _0x5b3c04=_0x4f1ac5[_0x2286('0x5d')][_0x2286('0x61')]('=');var _0x4ec42b=_0x5b3c04[0x0][_0x2286('0x62')](_0x5b3c04[0x0][_0x2286('0x63')]('(')+0x1,_0x5b3c04[0x0][_0x2286('0x63')](')'));var _0x2498da=_0x5b3c04[0x1];channels[_0x4f1ac5[_0x2286('0x8')]][_0x4ec42b]=_0x2498da;}if(!_[_0x2286('0x64')]([_0x2286('0x2a'),_0x2286('0x65'),_0x2286('0x66'),_0x2286('0x67'),_0x2286('0x68')],_0x4f1ac5[_0x2286('0x5e')]['toLowerCase']())){channels[_0x4f1ac5[_0x2286('0x8')]][_0x2286('0x52')]=_0x4f1ac5[_0x2286('0x5e')];channels[_0x4f1ac5[_0x2286('0x8')]][_0x2286('0x54')]=_0x4f1ac5[_0x2286('0x5d')];}}}catch(_0x3006c0){utils['error'](util[_0x2286('0x19')](_0x2286('0x5b'),_0x4f1ac5[_0x2286('0x8')]),_0x3006c0);}};
\ No newline at end of file