Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / components / extensions / rewrite.js
index 87079df..73cc5ff 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x556c=['XCALLY-MOTION-ANSWER=1','splice','GotoIfTime','last','concat','transaction','bulkCreate','catch','error','rewrite','models','Interval','findAll','intervals','IntervalId','VoiceExtension','uniq','map','then','filter','groupBy','exten','queue','playback','hasOwnProperty','extensions','extension','find','type','CDR(type)=%s','context','priority','VoiceExtensionId','push','Set','CDR(routeid)=','outbound','cutdigits','${EXTEN:','${EXTEN}','ExecIf','$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto(','):Goto(','CDR(prefix)=noprefix','outboundrouteid=','recordingFormat','none','_XCALLY_MIXMONITOR_FORMAT=','wav','XCALLY-MOTION-ANSWER=0','MONITOR_OPTIONS=ab','length','toLowerCase','createdAt','updatedAt','interval','*,*,*,*','tag','CDR(tag)=','callerID','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)=','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','answer','indexOf','appType','custom','$[${XCALLY-MOTION-ANSWER}=0]?Answer'];(function(_0x4f02e,_0x4ac328){var _0x5a09cd=function(_0x358155){while(--_0x358155){_0x4f02e['push'](_0x4f02e['shift']());}};_0x5a09cd(++_0x4ac328);}(_0x556c,0x1df));var _0xc556=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x556c[_0x20a584];return _0x4b41a8;};'use strict';var _=require('lodash');var util=require('util');function rewrite(_0x5aae13,_0x384f03){var _0x5addd6=this;return _0x5aae13[_0xc556('0x0')][_0xc556('0x1')][_0xc556('0x2')]({'raw':!![]})['then'](function(_0x1be160){_0x5addd6[_0xc556('0x3')]=_0x1be160;return _0x5aae13[_0xc556('0x0')]['VoiceExtension'][_0xc556('0x2')]({'where':{'IntervalId':_0x384f03[_0xc556('0x4')]},'raw':!![]});})['then'](function(_0x239dc8){return _0x5aae13[_0xc556('0x0')][_0xc556('0x5')]['findAll']({'where':{'exten':{'$in':_[_0xc556('0x6')](_[_0xc556('0x7')](_0x239dc8,'exten'))}},'order':[{'raw':'CAST(priority\x20AS\x20UNSIGNED)'}],'raw':!![]});})[_0xc556('0x8')](function(_0x1d3b99){var _0x4dcaff=_[_0xc556('0x9')](_0x1d3b99,{'priority':'1'});var _0x390a46=_[_0xc556('0x9')](_0x1d3b99,{'isApp':0x1});var _0x34e24e=_[_0xc556('0xa')](_0x390a46,_0xc556('0xb'));var _0x2387e8=[_0xc556('0xc'),_0xc556('0xd')];var _0x38324f=[];var _0x3615d6=[];for(var _0x37655c in _0x34e24e){if(_0x34e24e[_0xc556('0xe')](_0x37655c)){_0x5addd6['priority']=0x2;_0x5addd6[_0xc556('0xf')]=[];_0x5addd6[_0xc556('0x10')]=_[_0xc556('0x11')](_0x4dcaff,{'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')]});_0x5addd6['extensions']['push']({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':'Set','appdata':util['format'](_0xc556('0x13'),_0x34e24e[_0x37655c][0x0]['type']),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});if(_0x34e24e[_0x37655c][0x0][_0xc556('0x12')]==='inbound'){_0x5addd6['extensions'][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0xc556('0x19')+_0x34e24e[_0x37655c][0x0]['VoiceExtensionId'],'context':_0x34e24e[_0x37655c][0x0]['context'],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0]['VoiceExtensionId']});}else if(_0x34e24e[_0x37655c][0x0][_0xc556('0x12')]===_0xc556('0x1a')){if(_0x5addd6[_0xc556('0x10')]){_0x5addd6['extensions'][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':'CDR(destination)='+(_0x5addd6['extension'][_0xc556('0x1b')]?_0xc556('0x1c')+_0x5addd6[_0xc556('0x10')][_0xc556('0x1b')]+'}':_0xc556('0x1d')),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0]['VoiceExtensionId']});}_0x5addd6[_0xc556('0xf')]['push']({'type':_0x34e24e[_0x37655c][0x0]['type'],'app':'Set','appdata':'CDR(routeid)='+_0x34e24e[_0x37655c][0x0][_0xc556('0x16')],'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0]['exten'],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});var _0xa0245d=_0x5addd6[_0xc556('0x15')]++;_0x5addd6[_0xc556('0xf')]['push']({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x1e'),'appdata':_0xc556('0x1f')+(_0xa0245d+0x2)+_0xc556('0x20')+(_0xa0245d+0x1)+')','context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0xa0245d,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});if(_0x5addd6['extension']){_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0x5addd6[_0xc556('0x10')][_0xc556('0x1b')]?'CDR(prefix)=${EXTEN:0:'+_0x5addd6[_0xc556('0x10')][_0xc556('0x1b')]+'}':_0xc556('0x21'),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6['priority']++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});}_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0xc556('0x22')+_0x34e24e[_0x37655c][0x0]['VoiceExtensionId'],'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0]['VoiceExtensionId']});if(_0x5addd6[_0xc556('0x10')]&&_0x5addd6[_0xc556('0x10')][_0xc556('0xe')](_0xc556('0x23'))&&_0x5addd6[_0xc556('0x10')][_0xc556('0x23')]!==_0xc556('0x24')){_0x5addd6['extensions'][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':'_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0]['exten'],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0xc556('0x25')+_0x5addd6[_0xc556('0x10')][_0xc556('0x23')]||_0xc556('0x26'),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0]['VoiceExtensionId']});}}_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0xc556('0x27'),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':'XCALLY-MOTION-PROGRESS=0','context':_0x34e24e[_0x37655c][0x0]['context'],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});_0x5addd6[_0xc556('0xf')]['push']({'type':_0x34e24e[_0x37655c][0x0]['type'],'app':_0xc556('0x18'),'appdata':_0xc556('0x28'),'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'priority':_0x5addd6[_0xc556('0x15')]++,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0]['VoiceExtensionId']});for(var _0x23aab4=0x0,_0x3d4050=0x0;_0x23aab4<_0x34e24e[_0x37655c][_0xc556('0x29')];_0x23aab4+=0x1,_0x3d4050=0x0){var _0x54c7a1=_0x34e24e[_0x37655c][_0x23aab4];if(_0x54c7a1[_0xc556('0x12')]){_0x54c7a1[_0xc556('0x12')]=_0x54c7a1[_0xc556('0x12')][_0xc556('0x2a')]();}var _0x19e6aa=[];var _0x1b32f4=[];delete _0x54c7a1['id'];delete _0x54c7a1[_0xc556('0x2b')];delete _0x54c7a1[_0xc556('0x2c')];var _0x5a86c0=_0x54c7a1[_0xc556('0x2d')]!==_0xc556('0x2e')?[_0x54c7a1[_0xc556('0x2d')]]:_0x54c7a1[_0xc556('0x4')]?_['map'](_[_0xc556('0x9')](_0x5addd6['intervals'],{'IntervalId':_0x54c7a1[_0xc556('0x4')]}),'interval'):[];if(_0x54c7a1['hasOwnProperty'](_0xc556('0x2f'))){if(_0x54c7a1[_0xc556('0x2f')]&&_0x54c7a1[_0xc556('0x2f')]!=='--'){_0x19e6aa[_0xc556('0x17')]({'type':_0x54c7a1['type'],'app':_0xc556('0x18'),'appdata':_0xc556('0x30')+_0x54c7a1['tag'],'context':_0x54c7a1[_0xc556('0x14')],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6[_0xc556('0x15')]+_0x3d4050++,'VoiceExtensionId':_0x54c7a1['VoiceExtensionId']});}}if(_0x54c7a1[_0xc556('0x12')]===_0xc556('0x1a')&&_0x54c7a1[_0xc556('0xe')](_0xc556('0x31'))){if(_0x54c7a1[_0xc556('0x31')]){_0x19e6aa['push']({'type':_0x54c7a1[_0xc556('0x12')],'app':_0xc556('0x1e'),'appdata':_0xc556('0x32')+_0x54c7a1[_0xc556('0x31')]+')','context':_0x54c7a1['context'],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6['priority']+_0x3d4050++,'VoiceExtensionId':_0x54c7a1[_0xc556('0x16')]});}else{_0x19e6aa[_0xc556('0x17')]({'type':_0x54c7a1[_0xc556('0x12')],'app':_0xc556('0x1e'),'appdata':_0xc556('0x33'),'context':_0x54c7a1[_0xc556('0x14')],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6[_0xc556('0x15')]+_0x3d4050++,'VoiceExtensionId':_0x54c7a1['VoiceExtensionId']});}}if(_0x54c7a1[_0xc556('0xe')](_0xc556('0x34'))){if(_0x2387e8[_0xc556('0x35')](_0x54c7a1['app'][_0xc556('0x2a')]())>=0x0&&_0x54c7a1[_0xc556('0x36')]!==_0xc556('0x37')){if(_0x54c7a1['answer']){_0x19e6aa['push']({'type':_0x54c7a1['type'],'app':_0xc556('0x1e'),'appdata':_0xc556('0x38'),'context':_0x54c7a1['context'],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6['priority']+_0x3d4050++,'VoiceExtensionId':_0x54c7a1[_0xc556('0x16')]});_0x19e6aa['push']({'type':_0x54c7a1[_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':_0xc556('0x39'),'context':_0x54c7a1[_0xc556('0x14')],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6[_0xc556('0x15')]+_0x3d4050++,'VoiceExtensionId':_0x54c7a1[_0xc556('0x16')]});}else{_0x19e6aa[_0xc556('0x17')]({'type':_0x54c7a1[_0xc556('0x12')],'app':'ExecIf','appdata':'$[${XCALLY-MOTION-PROGRESS}=0]?Progress','context':_0x54c7a1[_0xc556('0x14')],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6[_0xc556('0x15')]+_0x3d4050++,'VoiceExtensionId':_0x54c7a1[_0xc556('0x16')]});_0x19e6aa[_0xc556('0x17')]({'type':_0x54c7a1[_0xc556('0x12')],'app':_0xc556('0x18'),'appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x54c7a1[_0xc556('0x14')],'exten':_0x54c7a1[_0xc556('0xb')],'priority':_0x5a86c0[_0xc556('0x29')]+_0x5addd6[_0xc556('0x15')]+_0x3d4050++,'VoiceExtensionId':_0x54c7a1[_0xc556('0x16')]});}}}for(var _0x444e00=0x0;_0x444e00<_0x5a86c0[_0xc556('0x29')];_0x444e00+=0x1){var _0x1fbb36=_0x5addd6[_0xc556('0x15')]+_0x5a86c0[_0xc556('0x29')];var _0x1e0fe7=_0x444e00===_0x5a86c0[_0xc556('0x29')]-0x1?_0x5addd6[_0xc556('0x15')]+_0x19e6aa[_0xc556('0x29')]+_0x1b32f4[_0xc556('0x29')]+0x2:_0x5addd6[_0xc556('0x15')]+_0x444e00+0x1;_0x19e6aa[_0xc556('0x3a')](_0x444e00,0x0,{'type':_0x54c7a1['type'],'app':_0xc556('0x3b'),'appdata':_0x5a86c0[_0x444e00]+'?'+_0x54c7a1['context']+',${EXTEN},'+_0x1fbb36+':'+_0x54c7a1[_0xc556('0x14')]+',${EXTEN},'+_0x1e0fe7,'exten':_0x54c7a1['exten'],'context':_0x54c7a1[_0xc556('0x14')],'priority':_0x5addd6[_0xc556('0x15')]+_0x444e00,'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});}_0x54c7a1[_0xc556('0x15')]=_0x19e6aa[_0xc556('0x29')]?_[_0xc556('0x3c')](_0x19e6aa)[_0xc556('0x15')]+0x1:_0x5addd6[_0xc556('0x15')];_0x5addd6[_0xc556('0x15')]=(_0x1b32f4[_0xc556('0x29')]?_['last'](_0x1b32f4)[_0xc556('0x15')]:_0x54c7a1[_0xc556('0x15')])+0x1;_0x5addd6[_0xc556('0xf')]=_[_0xc556('0x3d')](_0x5addd6['extensions'],_0x19e6aa,[_0x54c7a1],_0x1b32f4);}_0x5addd6[_0xc556('0xf')][_0xc556('0x17')]({'type':_0x34e24e[_0x37655c][0x0][_0xc556('0x12')],'app':'Hangup','exten':_0x34e24e[_0x37655c][0x0][_0xc556('0xb')],'context':_0x34e24e[_0x37655c][0x0][_0xc556('0x14')],'priority':_0x5addd6[_0xc556('0x15')],'VoiceExtensionId':_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]});_0x38324f[_0xc556('0x17')](_0x34e24e[_0x37655c][0x0][_0xc556('0x16')]);_0x3615d6=_[_0xc556('0x3d')](_0x3615d6,_0x5addd6[_0xc556('0xf')]);}}return _0x5aae13[_0xc556('0x3e')](function(_0x34aa43){return _0x5aae13[_0xc556('0x0')]['VoiceExtension']['destroy']({'where':{'VoiceExtensionId':{'$in':_0x38324f}},'transaction':_0x34aa43})[_0xc556('0x8')](function(_0x6772ab){return _0x5aae13[_0xc556('0x0')]['VoiceExtension'][_0xc556('0x3f')](_['sortBy'](_0x3615d6,_0xc556('0x15')),{'transaction':_0x34aa43});});});})[_0xc556('0x40')](function(_0x4c6fb5){console[_0xc556('0x41')](_0x4c6fb5);});}exports[_0xc556('0x42')]=rewrite;
\ No newline at end of file
+var _0xbb97=['tag','CDR(tag)=','outbound','callerID','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)=','length','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','answer','indexOf','appType','$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1','$[${XCALLY-MOTION-PROGRESS}=0]?Progress','splice','GotoIfTime',',${EXTEN},','concat','Hangup','destroy','bulkCreate','sortBy','error','lodash','models','Interval','findAll','then','intervals','VoiceExtension','uniq','map','exten','CAST(priority\x20AS\x20UNSIGNED)','filter','groupBy','queue','playback','priority','extensions','extension','find','type','format','context','inbound','push','Set','CDR(routeid)=','VoiceExtensionId','CDR(destination)=','cutdigits','${EXTEN:','${EXTEN}','ExecIf','):Goto(','CDR(prefix)=${EXTEN:0:','CDR(prefix)=noprefix','outboundrouteid=','hasOwnProperty','recordingFormat','none','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','_XCALLY_MIXMONITOR_FORMAT=','wav','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','toLowerCase','createdAt','updatedAt','*,*,*,*','interval','IntervalId'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0xbb97,0xf1));var _0x7bb9=function(_0x5c67af,_0x2a1e67){_0x5c67af=_0x5c67af-0x0;var _0x1314a1=_0xbb97[_0x5c67af];return _0x1314a1;};'use strict';var _=require(_0x7bb9('0x0'));var util=require('util');function rewrite(_0x2b6e45,_0x4f231b){var _0x128d3a=this;return _0x2b6e45[_0x7bb9('0x1')][_0x7bb9('0x2')][_0x7bb9('0x3')]({'raw':!![]})[_0x7bb9('0x4')](function(_0x2aa2ce){_0x128d3a[_0x7bb9('0x5')]=_0x2aa2ce;return _0x2b6e45[_0x7bb9('0x1')][_0x7bb9('0x6')][_0x7bb9('0x3')]({'where':{'IntervalId':_0x4f231b['IntervalId']},'raw':!![]});})['then'](function(_0x103477){return _0x2b6e45[_0x7bb9('0x1')][_0x7bb9('0x6')][_0x7bb9('0x3')]({'where':{'exten':{'$in':_[_0x7bb9('0x7')](_[_0x7bb9('0x8')](_0x103477,_0x7bb9('0x9')))}},'order':[{'raw':_0x7bb9('0xa')}],'raw':!![]});})['then'](function(_0x43aed1){var _0x5cf97a=_['filter'](_0x43aed1,{'priority':'1'});var _0x535672=_[_0x7bb9('0xb')](_0x43aed1,{'isApp':0x1});var _0x10bfef=_[_0x7bb9('0xc')](_0x535672,_0x7bb9('0x9'));var _0x4b4817=[_0x7bb9('0xd'),_0x7bb9('0xe')];var _0xd6d0e7=[];var _0x278577=[];for(var _0x3670c0 in _0x10bfef){if(_0x10bfef['hasOwnProperty'](_0x3670c0)){_0x128d3a[_0x7bb9('0xf')]=0x2;_0x128d3a[_0x7bb9('0x10')]=[];_0x128d3a[_0x7bb9('0x11')]=_[_0x7bb9('0x12')](_0x5cf97a,{'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')]});_0x128d3a[_0x7bb9('0x10')]['push']({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':'Set','appdata':util[_0x7bb9('0x14')]('CDR(type)=%s',_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')]),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0]['VoiceExtensionId']});if(_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')]===_0x7bb9('0x16')){_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0]['type'],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x19')+_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')],'context':_0x10bfef[_0x3670c0][0x0]['context'],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a['priority']++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});}else if(_0x10bfef[_0x3670c0][0x0]['type']==='outbound'){if(_0x128d3a[_0x7bb9('0x11')]){_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x1b')+(_0x128d3a[_0x7bb9('0x11')][_0x7bb9('0x1c')]?_0x7bb9('0x1d')+_0x128d3a[_0x7bb9('0x11')]['cutdigits']+'}':_0x7bb9('0x1e')),'context':_0x10bfef[_0x3670c0][0x0]['context'],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a['priority']++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});}_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x19')+_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')],'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0]['VoiceExtensionId']});var _0x2b847d=_0x128d3a[_0x7bb9('0xf')]++;_0x128d3a['extensions'][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x1f'),'appdata':'$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto('+(_0x2b847d+0x2)+_0x7bb9('0x20')+(_0x2b847d+0x1)+')','context':_0x10bfef[_0x3670c0][0x0]['context'],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x2b847d,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});if(_0x128d3a['extension']){_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x128d3a[_0x7bb9('0x11')][_0x7bb9('0x1c')]?_0x7bb9('0x21')+_0x128d3a['extension']['cutdigits']+'}':_0x7bb9('0x22'),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0]['exten'],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0]['VoiceExtensionId']});}_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':'Set','appdata':_0x7bb9('0x23')+_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')],'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0]['exten'],'priority':_0x128d3a['priority']++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});if(_0x128d3a['extension']&&_0x128d3a[_0x7bb9('0x11')][_0x7bb9('0x24')](_0x7bb9('0x25'))&&_0x128d3a[_0x7bb9('0x11')]['recordingFormat']!==_0x7bb9('0x26')){_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0]['type'],'app':'Set','appdata':_0x7bb9('0x27'),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0]['exten'],'priority':_0x128d3a['priority']++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x28')+_0x128d3a[_0x7bb9('0x11')][_0x7bb9('0x25')]||_0x7bb9('0x29'),'context':_0x10bfef[_0x3670c0][0x0]['context'],'exten':_0x10bfef[_0x3670c0][0x0]['exten'],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});}}_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':'Set','appdata':_0x7bb9('0x2a'),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0]['VoiceExtensionId']});_0x128d3a[_0x7bb9('0x10')]['push']({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x2b'),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a[_0x7bb9('0xf')]++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x2c'),'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'priority':_0x128d3a['priority']++,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});for(var _0x5efd57=0x0,_0x1f7d52=0x0;_0x5efd57<_0x10bfef[_0x3670c0]['length'];_0x5efd57+=0x1,_0x1f7d52=0x0){var _0x917685=_0x10bfef[_0x3670c0][_0x5efd57];if(_0x917685[_0x7bb9('0x13')]){_0x917685[_0x7bb9('0x13')]=_0x917685[_0x7bb9('0x13')][_0x7bb9('0x2d')]();}var _0x275fdb=[];var _0x212ad1=[];delete _0x917685['id'];delete _0x917685[_0x7bb9('0x2e')];delete _0x917685[_0x7bb9('0x2f')];var _0x42de5f=_0x917685['interval']!==_0x7bb9('0x30')?[_0x917685[_0x7bb9('0x31')]]:_0x917685['IntervalId']?_[_0x7bb9('0x8')](_[_0x7bb9('0xb')](_0x128d3a[_0x7bb9('0x5')],{'IntervalId':_0x917685[_0x7bb9('0x32')]}),_0x7bb9('0x31')):[];if(_0x917685[_0x7bb9('0x24')](_0x7bb9('0x33'))){if(_0x917685['tag']&&_0x917685[_0x7bb9('0x33')]!=='--'){_0x275fdb[_0x7bb9('0x17')]({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x34')+_0x917685[_0x7bb9('0x33')],'context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685[_0x7bb9('0x9')],'priority':_0x42de5f['length']+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685[_0x7bb9('0x1a')]});}}if(_0x917685[_0x7bb9('0x13')]===_0x7bb9('0x35')&&_0x917685[_0x7bb9('0x24')]('callerID')){if(_0x917685[_0x7bb9('0x36')]){_0x275fdb[_0x7bb9('0x17')]({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x1f'),'appdata':_0x7bb9('0x37')+_0x917685[_0x7bb9('0x36')]+')','context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685[_0x7bb9('0x9')],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685[_0x7bb9('0x1a')]});}else{_0x275fdb[_0x7bb9('0x17')]({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x1f'),'appdata':_0x7bb9('0x39'),'context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685[_0x7bb9('0x9')],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685['VoiceExtensionId']});}}if(_0x917685[_0x7bb9('0x24')](_0x7bb9('0x3a'))){if(_0x4b4817[_0x7bb9('0x3b')](_0x917685['app']['toLowerCase']())>=0x0&&_0x917685[_0x7bb9('0x3c')]!=='custom'){if(_0x917685[_0x7bb9('0x3a')]){_0x275fdb['push']({'type':_0x917685['type'],'app':'ExecIf','appdata':_0x7bb9('0x3d'),'context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685[_0x7bb9('0x9')],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685[_0x7bb9('0x1a')]});_0x275fdb['push']({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':_0x7bb9('0x3e'),'context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685['exten'],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685[_0x7bb9('0x1a')]});}else{_0x275fdb[_0x7bb9('0x17')]({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x1f'),'appdata':_0x7bb9('0x3f'),'context':_0x917685[_0x7bb9('0x15')],'exten':_0x917685['exten'],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685[_0x7bb9('0x1a')]});_0x275fdb[_0x7bb9('0x17')]({'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x18'),'appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x917685['context'],'exten':_0x917685['exten'],'priority':_0x42de5f[_0x7bb9('0x38')]+_0x128d3a[_0x7bb9('0xf')]+_0x1f7d52++,'VoiceExtensionId':_0x917685['VoiceExtensionId']});}}}for(var _0x5c9bc6=0x0;_0x5c9bc6<_0x42de5f[_0x7bb9('0x38')];_0x5c9bc6+=0x1){var _0x181767=_0x128d3a[_0x7bb9('0xf')]+_0x42de5f[_0x7bb9('0x38')];var _0x471cbf=_0x5c9bc6===_0x42de5f[_0x7bb9('0x38')]-0x1?_0x128d3a[_0x7bb9('0xf')]+_0x275fdb[_0x7bb9('0x38')]+_0x212ad1['length']+0x2:_0x128d3a[_0x7bb9('0xf')]+_0x5c9bc6+0x1;_0x275fdb[_0x7bb9('0x40')](_0x5c9bc6,0x0,{'type':_0x917685[_0x7bb9('0x13')],'app':_0x7bb9('0x41'),'appdata':_0x42de5f[_0x5c9bc6]+'?'+_0x917685[_0x7bb9('0x15')]+',${EXTEN},'+_0x181767+':'+_0x917685[_0x7bb9('0x15')]+_0x7bb9('0x42')+_0x471cbf,'exten':_0x917685['exten'],'context':_0x917685[_0x7bb9('0x15')],'priority':_0x128d3a['priority']+_0x5c9bc6,'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0]['VoiceExtensionId']});}_0x917685['priority']=_0x275fdb[_0x7bb9('0x38')]?_['last'](_0x275fdb)['priority']+0x1:_0x128d3a['priority'];_0x128d3a[_0x7bb9('0xf')]=(_0x212ad1[_0x7bb9('0x38')]?_['last'](_0x212ad1)[_0x7bb9('0xf')]:_0x917685[_0x7bb9('0xf')])+0x1;_0x128d3a[_0x7bb9('0x10')]=_[_0x7bb9('0x43')](_0x128d3a[_0x7bb9('0x10')],_0x275fdb,[_0x917685],_0x212ad1);}_0x128d3a[_0x7bb9('0x10')][_0x7bb9('0x17')]({'type':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x13')],'app':_0x7bb9('0x44'),'exten':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x9')],'context':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x15')],'priority':_0x128d3a[_0x7bb9('0xf')],'VoiceExtensionId':_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]});_0xd6d0e7[_0x7bb9('0x17')](_0x10bfef[_0x3670c0][0x0][_0x7bb9('0x1a')]);_0x278577=_['concat'](_0x278577,_0x128d3a['extensions']);}}return _0x2b6e45['transaction'](function(_0x191424){return _0x2b6e45['models'][_0x7bb9('0x6')][_0x7bb9('0x45')]({'where':{'VoiceExtensionId':{'$in':_0xd6d0e7}},'transaction':_0x191424})[_0x7bb9('0x4')](function(_0x10edcf){return _0x2b6e45['models']['VoiceExtension'][_0x7bb9('0x46')](_[_0x7bb9('0x47')](_0x278577,_0x7bb9('0xf')),{'transaction':_0x191424});});});})['catch'](function(_0x2f2ec5){console[_0x7bb9('0x48')](_0x2f2ec5);});}exports['rewrite']=rewrite;
\ No newline at end of file