Built motion from commit 980b26c3.|2.6.29
[motion2.git] / server / components / extensions / rewrite.js
index cf8d75f..f3fca23 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8188=['last','Hangup','concat','transaction','bulkCreate','sortBy','catch','error','rewrite','lodash','util','Interval','findAll','intervals','models','VoiceExtension','IntervalId','map','then','filter','exten','queue','playback','hasOwnProperty','priority','extensions','find','push','type','Set','format','CDR(type)=%s','VoiceExtensionId','CDR(routeid)=','outbound','extension','cutdigits','${EXTEN:','context','$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto(','):Goto(','outboundrouteid=','none','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','_XCALLY_MIXMONITOR_FORMAT=','recordingFormat','wav','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','length','toLowerCase','updatedAt','interval','CDR(tag)=','tag','callerID','ExecIf','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','answer','indexOf','app','appType','custom','$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1','$[${XCALLY-MOTION-PROGRESS}=0]?Progress','GotoIfTime',',${EXTEN},'];(function(_0x277075,_0x2dea35){var _0x120e79=function(_0x3f649b){while(--_0x3f649b){_0x277075['push'](_0x277075['shift']());}};_0x120e79(++_0x2dea35);}(_0x8188,0xd8));var _0x8818=function(_0x4ba12d,_0x42933b){_0x4ba12d=_0x4ba12d-0x0;var _0x306029=_0x8188[_0x4ba12d];return _0x306029;};'use strict';var _=require(_0x8818('0x0'));var util=require(_0x8818('0x1'));function rewrite(_0xcb64a0,_0x3ae805){var _0x4bedf8=this;return _0xcb64a0['models'][_0x8818('0x2')][_0x8818('0x3')]({'raw':!![]})['then'](function(_0x109879){_0x4bedf8[_0x8818('0x4')]=_0x109879;return _0xcb64a0[_0x8818('0x5')][_0x8818('0x6')][_0x8818('0x3')]({'where':{'IntervalId':_0x3ae805[_0x8818('0x7')]},'raw':!![]});})['then'](function(_0x22d13c){return _0xcb64a0[_0x8818('0x5')][_0x8818('0x6')]['findAll']({'where':{'exten':{'$in':_['uniq'](_[_0x8818('0x8')](_0x22d13c,'exten'))}},'order':[{'raw':'CAST(priority\x20AS\x20UNSIGNED)'}],'raw':!![]});})[_0x8818('0x9')](function(_0x4f7832){var _0x342e3c=_[_0x8818('0xa')](_0x4f7832,{'priority':'1'});var _0x30de9b=_[_0x8818('0xa')](_0x4f7832,{'isApp':0x1});var _0x9d63=_['groupBy'](_0x30de9b,_0x8818('0xb'));var _0x44e800=[_0x8818('0xc'),_0x8818('0xd')];var _0x43b754=[];var _0x19d08b=[];for(var _0x2a2845 in _0x9d63){if(_0x9d63[_0x8818('0xe')](_0x2a2845)){_0x4bedf8[_0x8818('0xf')]=0x2;_0x4bedf8[_0x8818('0x10')]=[];_0x4bedf8['extension']=_[_0x8818('0x11')](_0x342e3c,{'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')]});_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':util[_0x8818('0x15')](_0x8818('0x16'),_0x9d63[_0x2a2845][0x0]['type']),'context':_0x9d63[_0x2a2845][0x0]['context'],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});if(_0x9d63[_0x2a2845][0x0][_0x8818('0x13')]==='inbound'){_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x18')+_0x9d63[_0x2a2845][0x0][_0x8818('0x17')],'context':_0x9d63[_0x2a2845][0x0]['context'],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});}else if(_0x9d63[_0x2a2845][0x0]['type']===_0x8818('0x19')){if(_0x4bedf8['extension']){_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':'Set','appdata':'CDR(destination)='+(_0x4bedf8[_0x8818('0x1a')][_0x8818('0x1b')]?_0x8818('0x1c')+_0x4bedf8['extension'][_0x8818('0x1b')]+'}':'${EXTEN}'),'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});}_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':'CDR(routeid)='+_0x9d63[_0x2a2845][0x0][_0x8818('0x17')],'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});var _0x553cfd=_0x4bedf8[_0x8818('0xf')]++;_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':'ExecIf','appdata':_0x8818('0x1e')+(_0x553cfd+0x2)+_0x8818('0x1f')+(_0x553cfd+0x1)+')','context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x553cfd,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});if(_0x4bedf8[_0x8818('0x1a')]){_0x4bedf8['extensions'][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':'Set','appdata':_0x4bedf8[_0x8818('0x1a')]['cutdigits']?'CDR(prefix)=${EXTEN:0:'+_0x4bedf8[_0x8818('0x1a')]['cutdigits']+'}':'CDR(prefix)=noprefix','context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});}_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':'Set','appdata':_0x8818('0x20')+_0x9d63[_0x2a2845][0x0][_0x8818('0x17')],'context':_0x9d63[_0x2a2845][0x0]['context'],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});if(_0x4bedf8[_0x8818('0x1a')]&&_0x4bedf8['extension'][_0x8818('0xe')]('recordingFormat')&&_0x4bedf8[_0x8818('0x1a')]['recordingFormat']!==_0x8818('0x21')){_0x4bedf8['extensions'][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x22'),'context':_0x9d63[_0x2a2845][0x0]['context'],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8['priority']++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x23')+_0x4bedf8[_0x8818('0x1a')][_0x8818('0x24')]||_0x8818('0x25'),'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0]['VoiceExtensionId']});}}_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x26'),'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8['priority']++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0]['VoiceExtensionId']});_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':'Set','appdata':_0x8818('0x27'),'context':_0x9d63[_0x2a2845][0x0]['context'],'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});_0x4bedf8['extensions'][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0]['type'],'app':_0x8818('0x14'),'appdata':_0x8818('0x28'),'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'exten':_0x9d63[_0x2a2845][0x0]['exten'],'priority':_0x4bedf8[_0x8818('0xf')]++,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});for(var _0x4be678=0x0,_0x4202e0=0x0;_0x4be678<_0x9d63[_0x2a2845][_0x8818('0x29')];_0x4be678+=0x1,_0x4202e0=0x0){var _0x241c63=_0x9d63[_0x2a2845][_0x4be678];if(_0x241c63[_0x8818('0x13')]){_0x241c63[_0x8818('0x13')]=_0x241c63['type'][_0x8818('0x2a')]();}var _0x51ae16=[];var _0x4802ba=[];delete _0x241c63['id'];delete _0x241c63['createdAt'];delete _0x241c63[_0x8818('0x2b')];var _0x442af9=_0x241c63[_0x8818('0x2c')]!=='*,*,*,*'?[_0x241c63[_0x8818('0x2c')]]:_0x241c63[_0x8818('0x7')]?_[_0x8818('0x8')](_['filter'](_0x4bedf8[_0x8818('0x4')],{'IntervalId':_0x241c63[_0x8818('0x7')]}),'interval'):[];if(_0x241c63['hasOwnProperty']('tag')){if(_0x241c63['tag']&&_0x241c63['tag']!=='--'){_0x51ae16[_0x8818('0x12')]({'type':_0x241c63[_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x2d')+_0x241c63[_0x8818('0x2e')],'context':_0x241c63[_0x8818('0x1d')],'exten':_0x241c63[_0x8818('0xb')],'priority':_0x442af9['length']+_0x4bedf8[_0x8818('0xf')]+_0x4202e0++,'VoiceExtensionId':_0x241c63[_0x8818('0x17')]});}}if(_0x241c63['type']===_0x8818('0x19')&&_0x241c63[_0x8818('0xe')](_0x8818('0x2f'))){if(_0x241c63['callerID']){_0x51ae16['push']({'type':_0x241c63['type'],'app':_0x8818('0x30'),'appdata':'$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)='+_0x241c63[_0x8818('0x2f')]+')','context':_0x241c63['context'],'exten':_0x241c63[_0x8818('0xb')],'priority':_0x442af9['length']+_0x4bedf8[_0x8818('0xf')]+_0x4202e0++,'VoiceExtensionId':_0x241c63[_0x8818('0x17')]});}else{_0x51ae16[_0x8818('0x12')]({'type':_0x241c63[_0x8818('0x13')],'app':_0x8818('0x30'),'appdata':_0x8818('0x31'),'context':_0x241c63['context'],'exten':_0x241c63['exten'],'priority':_0x442af9[_0x8818('0x29')]+_0x4bedf8[_0x8818('0xf')]+_0x4202e0++,'VoiceExtensionId':_0x241c63[_0x8818('0x17')]});}}if(_0x241c63[_0x8818('0xe')](_0x8818('0x32'))){if(_0x44e800[_0x8818('0x33')](_0x241c63[_0x8818('0x34')][_0x8818('0x2a')]())>=0x0&&_0x241c63[_0x8818('0x35')]!==_0x8818('0x36')){if(_0x241c63[_0x8818('0x32')]){_0x51ae16[_0x8818('0x12')]({'type':_0x241c63[_0x8818('0x13')],'app':_0x8818('0x30'),'appdata':_0x8818('0x37'),'context':_0x241c63[_0x8818('0x1d')],'exten':_0x241c63[_0x8818('0xb')],'priority':_0x442af9[_0x8818('0x29')]+_0x4bedf8['priority']+_0x4202e0++,'VoiceExtensionId':_0x241c63[_0x8818('0x17')]});_0x51ae16['push']({'type':_0x241c63[_0x8818('0x13')],'app':_0x8818('0x14'),'appdata':_0x8818('0x38'),'context':_0x241c63[_0x8818('0x1d')],'exten':_0x241c63[_0x8818('0xb')],'priority':_0x442af9[_0x8818('0x29')]+_0x4bedf8[_0x8818('0xf')]+_0x4202e0++,'VoiceExtensionId':_0x241c63['VoiceExtensionId']});}else{_0x51ae16[_0x8818('0x12')]({'type':_0x241c63[_0x8818('0x13')],'app':_0x8818('0x30'),'appdata':_0x8818('0x39'),'context':_0x241c63[_0x8818('0x1d')],'exten':_0x241c63[_0x8818('0xb')],'priority':_0x442af9[_0x8818('0x29')]+_0x4bedf8['priority']+_0x4202e0++,'VoiceExtensionId':_0x241c63[_0x8818('0x17')]});_0x51ae16[_0x8818('0x12')]({'type':_0x241c63[_0x8818('0x13')],'app':'Set','appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x241c63[_0x8818('0x1d')],'exten':_0x241c63['exten'],'priority':_0x442af9[_0x8818('0x29')]+_0x4bedf8[_0x8818('0xf')]+_0x4202e0++,'VoiceExtensionId':_0x241c63['VoiceExtensionId']});}}}for(var _0x7b7f83=0x0;_0x7b7f83<_0x442af9[_0x8818('0x29')];_0x7b7f83+=0x1){var _0x10cc36=_0x4bedf8[_0x8818('0xf')]+_0x442af9[_0x8818('0x29')];var _0x523d82=_0x7b7f83===_0x442af9[_0x8818('0x29')]-0x1?_0x4bedf8['priority']+_0x51ae16[_0x8818('0x29')]+_0x4802ba[_0x8818('0x29')]+0x2:_0x4bedf8[_0x8818('0xf')]+_0x7b7f83+0x1;_0x51ae16['splice'](_0x7b7f83,0x0,{'type':_0x241c63['type'],'app':_0x8818('0x3a'),'appdata':_0x442af9[_0x7b7f83]+'?'+_0x241c63[_0x8818('0x1d')]+',${EXTEN},'+_0x10cc36+':'+_0x241c63[_0x8818('0x1d')]+_0x8818('0x3b')+_0x523d82,'exten':_0x241c63[_0x8818('0xb')],'context':_0x241c63[_0x8818('0x1d')],'priority':_0x4bedf8['priority']+_0x7b7f83,'VoiceExtensionId':_0x9d63[_0x2a2845][0x0]['VoiceExtensionId']});}_0x241c63[_0x8818('0xf')]=_0x51ae16['length']?_[_0x8818('0x3c')](_0x51ae16)[_0x8818('0xf')]+0x1:_0x4bedf8['priority'];_0x4bedf8[_0x8818('0xf')]=(_0x4802ba['length']?_[_0x8818('0x3c')](_0x4802ba)[_0x8818('0xf')]:_0x241c63[_0x8818('0xf')])+0x1;_0x4bedf8[_0x8818('0x10')]=_['concat'](_0x4bedf8[_0x8818('0x10')],_0x51ae16,[_0x241c63],_0x4802ba);}_0x4bedf8[_0x8818('0x10')][_0x8818('0x12')]({'type':_0x9d63[_0x2a2845][0x0][_0x8818('0x13')],'app':_0x8818('0x3d'),'exten':_0x9d63[_0x2a2845][0x0][_0x8818('0xb')],'context':_0x9d63[_0x2a2845][0x0][_0x8818('0x1d')],'priority':_0x4bedf8[_0x8818('0xf')],'VoiceExtensionId':_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]});_0x43b754['push'](_0x9d63[_0x2a2845][0x0][_0x8818('0x17')]);_0x19d08b=_[_0x8818('0x3e')](_0x19d08b,_0x4bedf8[_0x8818('0x10')]);}}return _0xcb64a0[_0x8818('0x3f')](function(_0xccf1fb){return _0xcb64a0[_0x8818('0x5')]['VoiceExtension']['destroy']({'where':{'VoiceExtensionId':{'$in':_0x43b754}},'transaction':_0xccf1fb})[_0x8818('0x9')](function(_0x46a65f){return _0xcb64a0['models'][_0x8818('0x6')][_0x8818('0x40')](_[_0x8818('0x41')](_0x19d08b,_0x8818('0xf')),{'transaction':_0xccf1fb});});});})[_0x8818('0x42')](function(_0x4fbed2){console[_0x8818('0x43')](_0x4fbed2);});}exports[_0x8818('0x44')]=rewrite;
\ No newline at end of file
+var _0x36f3=['_XCALLY_MIXMONITOR_FORMAT=','recordingFormat','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','length','toLowerCase','updatedAt','interval','*,*,*,*','tag','CDR(tag)=','outbound','callerID','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','indexOf','app','appType','custom','$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1','GotoIfTime',',${EXTEN},','last','concat','Hangup','transaction','destroy','bulkCreate','sortBy','catch','error','rewrite','lodash','util','Interval','findAll','then','intervals','models','VoiceExtension','IntervalId','uniq','map','exten','CAST(priority\x20AS\x20UNSIGNED)','filter','groupBy','queue','playback','hasOwnProperty','priority','extensions','find','push','type','Set','CDR(type)=%s','context','VoiceExtensionId','CDR(routeid)=','extension','${EXTEN:','cutdigits','${EXTEN}','ExecIf','$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto(','):Goto(','CDR(prefix)=${EXTEN:0:','CDR(prefix)=noprefix','none'];(function(_0xbb1465,_0x1443bf){var _0xdeeff4=function(_0x27d07f){while(--_0x27d07f){_0xbb1465['push'](_0xbb1465['shift']());}};_0xdeeff4(++_0x1443bf);}(_0x36f3,0x68));var _0x336f=function(_0x17357f,_0xe5ae66){_0x17357f=_0x17357f-0x0;var _0x283ab9=_0x36f3[_0x17357f];return _0x283ab9;};'use strict';var _=require(_0x336f('0x0'));var util=require(_0x336f('0x1'));function rewrite(_0x138648,_0x2b8108){var _0x20f9fc=this;return _0x138648['models'][_0x336f('0x2')][_0x336f('0x3')]({'raw':!![]})[_0x336f('0x4')](function(_0x314ed6){_0x20f9fc[_0x336f('0x5')]=_0x314ed6;return _0x138648[_0x336f('0x6')][_0x336f('0x7')][_0x336f('0x3')]({'where':{'IntervalId':_0x2b8108[_0x336f('0x8')]},'raw':!![]});})[_0x336f('0x4')](function(_0x57b606){return _0x138648[_0x336f('0x6')][_0x336f('0x7')][_0x336f('0x3')]({'where':{'exten':{'$in':_[_0x336f('0x9')](_[_0x336f('0xa')](_0x57b606,_0x336f('0xb')))}},'order':[{'raw':_0x336f('0xc')}],'raw':!![]});})[_0x336f('0x4')](function(_0x33c37b){var _0x5f1bdc=_[_0x336f('0xd')](_0x33c37b,{'priority':'1'});var _0x2d6d5b=_[_0x336f('0xd')](_0x33c37b,{'isApp':0x1});var _0x22aa19=_[_0x336f('0xe')](_0x2d6d5b,_0x336f('0xb'));var _0x3ceb42=[_0x336f('0xf'),_0x336f('0x10')];var _0x47097e=[];var _0x58d345=[];for(var _0x4ffd8e in _0x22aa19){if(_0x22aa19[_0x336f('0x11')](_0x4ffd8e)){_0x20f9fc[_0x336f('0x12')]=0x2;_0x20f9fc[_0x336f('0x13')]=[];_0x20f9fc['extension']=_[_0x336f('0x14')](_0x5f1bdc,{'exten':_0x22aa19[_0x4ffd8e][0x0]['exten']});_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':util['format'](_0x336f('0x18'),_0x22aa19[_0x4ffd8e][0x0]['type']),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc['priority']++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});if(_0x22aa19[_0x4ffd8e][0x0]['type']==='inbound'){_0x20f9fc['extensions'][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':_0x336f('0x1b')+_0x22aa19[_0x4ffd8e][0x0]['VoiceExtensionId'],'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0]['exten'],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});}else if(_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')]==='outbound'){if(_0x20f9fc[_0x336f('0x1c')]){_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':'Set','appdata':'CDR(destination)='+(_0x20f9fc[_0x336f('0x1c')]['cutdigits']?_0x336f('0x1d')+_0x20f9fc[_0x336f('0x1c')][_0x336f('0x1e')]+'}':_0x336f('0x1f')),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0]['VoiceExtensionId']});}_0x20f9fc['extensions'][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':_0x336f('0x1b')+_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')],'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});var _0x3575f6=_0x20f9fc[_0x336f('0x12')]++;_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0]['type'],'app':_0x336f('0x20'),'appdata':_0x336f('0x21')+(_0x3575f6+0x2)+_0x336f('0x22')+(_0x3575f6+0x1)+')','context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x3575f6,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});if(_0x20f9fc[_0x336f('0x1c')]){_0x20f9fc['extensions'][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0]['type'],'app':_0x336f('0x17'),'appdata':_0x20f9fc['extension']['cutdigits']?_0x336f('0x23')+_0x20f9fc[_0x336f('0x1c')][_0x336f('0x1e')]+'}':_0x336f('0x24'),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0]['VoiceExtensionId']});}_0x20f9fc[_0x336f('0x13')]['push']({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':'outboundrouteid='+_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')],'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});if(_0x20f9fc[_0x336f('0x1c')]&&_0x20f9fc[_0x336f('0x1c')][_0x336f('0x11')]('recordingFormat')&&_0x20f9fc[_0x336f('0x1c')]['recordingFormat']!==_0x336f('0x25')){_0x20f9fc['extensions']['push']({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':'_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc['priority']++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':_0x336f('0x26')+_0x20f9fc[_0x336f('0x1c')][_0x336f('0x27')]||'wav','context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0]['VoiceExtensionId']});}}_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0]['type'],'app':'Set','appdata':_0x336f('0x28'),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});_0x20f9fc[_0x336f('0x13')][_0x336f('0x15')]({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':_0x336f('0x29'),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});_0x20f9fc[_0x336f('0x13')]['push']({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':'Set','appdata':_0x336f('0x2a'),'context':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x19')],'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'priority':_0x20f9fc[_0x336f('0x12')]++,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});for(var _0x43b4ed=0x0,_0x21f957=0x0;_0x43b4ed<_0x22aa19[_0x4ffd8e][_0x336f('0x2b')];_0x43b4ed+=0x1,_0x21f957=0x0){var _0x38d382=_0x22aa19[_0x4ffd8e][_0x43b4ed];if(_0x38d382[_0x336f('0x16')]){_0x38d382['type']=_0x38d382[_0x336f('0x16')][_0x336f('0x2c')]();}var _0x14ce3c=[];var _0x2ed46c=[];delete _0x38d382['id'];delete _0x38d382['createdAt'];delete _0x38d382[_0x336f('0x2d')];var _0x154ac6=_0x38d382[_0x336f('0x2e')]!==_0x336f('0x2f')?[_0x38d382[_0x336f('0x2e')]]:_0x38d382[_0x336f('0x8')]?_[_0x336f('0xa')](_[_0x336f('0xd')](_0x20f9fc[_0x336f('0x5')],{'IntervalId':_0x38d382[_0x336f('0x8')]}),_0x336f('0x2e')):[];if(_0x38d382[_0x336f('0x11')]('tag')){if(_0x38d382[_0x336f('0x30')]&&_0x38d382['tag']!=='--'){_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382[_0x336f('0x16')],'app':_0x336f('0x17'),'appdata':_0x336f('0x31')+_0x38d382[_0x336f('0x30')],'context':_0x38d382[_0x336f('0x19')],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6['length']+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382[_0x336f('0x1a')]});}}if(_0x38d382[_0x336f('0x16')]===_0x336f('0x32')&&_0x38d382['hasOwnProperty'](_0x336f('0x33'))){if(_0x38d382[_0x336f('0x33')]){_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382['type'],'app':_0x336f('0x20'),'appdata':'$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)='+_0x38d382['callerID']+')','context':_0x38d382['context'],'exten':_0x38d382['exten'],'priority':_0x154ac6[_0x336f('0x2b')]+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382[_0x336f('0x1a')]});}else{_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382[_0x336f('0x16')],'app':'ExecIf','appdata':_0x336f('0x34'),'context':_0x38d382['context'],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6['length']+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382[_0x336f('0x1a')]});}}if(_0x38d382[_0x336f('0x11')]('answer')){if(_0x3ceb42[_0x336f('0x35')](_0x38d382[_0x336f('0x36')][_0x336f('0x2c')]())>=0x0&&_0x38d382[_0x336f('0x37')]!==_0x336f('0x38')){if(_0x38d382['answer']){_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382['type'],'app':_0x336f('0x20'),'appdata':_0x336f('0x39'),'context':_0x38d382[_0x336f('0x19')],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6[_0x336f('0x2b')]+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382['VoiceExtensionId']});_0x14ce3c['push']({'type':_0x38d382['type'],'app':'Set','appdata':_0x336f('0x3a'),'context':_0x38d382[_0x336f('0x19')],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6[_0x336f('0x2b')]+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382[_0x336f('0x1a')]});}else{_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382['type'],'app':_0x336f('0x20'),'appdata':'$[${XCALLY-MOTION-PROGRESS}=0]?Progress','context':_0x38d382['context'],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6['length']+_0x20f9fc['priority']+_0x21f957++,'VoiceExtensionId':_0x38d382[_0x336f('0x1a')]});_0x14ce3c[_0x336f('0x15')]({'type':_0x38d382[_0x336f('0x16')],'app':'Set','appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x38d382['context'],'exten':_0x38d382[_0x336f('0xb')],'priority':_0x154ac6[_0x336f('0x2b')]+_0x20f9fc[_0x336f('0x12')]+_0x21f957++,'VoiceExtensionId':_0x38d382['VoiceExtensionId']});}}}for(var _0x1b5ece=0x0;_0x1b5ece<_0x154ac6[_0x336f('0x2b')];_0x1b5ece+=0x1){var _0x1daa66=_0x20f9fc['priority']+_0x154ac6[_0x336f('0x2b')];var _0x2281ac=_0x1b5ece===_0x154ac6[_0x336f('0x2b')]-0x1?_0x20f9fc['priority']+_0x14ce3c[_0x336f('0x2b')]+_0x2ed46c[_0x336f('0x2b')]+0x2:_0x20f9fc[_0x336f('0x12')]+_0x1b5ece+0x1;_0x14ce3c['splice'](_0x1b5ece,0x0,{'type':_0x38d382[_0x336f('0x16')],'app':_0x336f('0x3b'),'appdata':_0x154ac6[_0x1b5ece]+'?'+_0x38d382[_0x336f('0x19')]+_0x336f('0x3c')+_0x1daa66+':'+_0x38d382['context']+_0x336f('0x3c')+_0x2281ac,'exten':_0x38d382[_0x336f('0xb')],'context':_0x38d382[_0x336f('0x19')],'priority':_0x20f9fc[_0x336f('0x12')]+_0x1b5ece,'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});}_0x38d382[_0x336f('0x12')]=_0x14ce3c[_0x336f('0x2b')]?_['last'](_0x14ce3c)[_0x336f('0x12')]+0x1:_0x20f9fc[_0x336f('0x12')];_0x20f9fc[_0x336f('0x12')]=(_0x2ed46c[_0x336f('0x2b')]?_[_0x336f('0x3d')](_0x2ed46c)[_0x336f('0x12')]:_0x38d382[_0x336f('0x12')])+0x1;_0x20f9fc[_0x336f('0x13')]=_[_0x336f('0x3e')](_0x20f9fc[_0x336f('0x13')],_0x14ce3c,[_0x38d382],_0x2ed46c);}_0x20f9fc[_0x336f('0x13')]['push']({'type':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x16')],'app':_0x336f('0x3f'),'exten':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0xb')],'context':_0x22aa19[_0x4ffd8e][0x0]['context'],'priority':_0x20f9fc[_0x336f('0x12')],'VoiceExtensionId':_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]});_0x47097e[_0x336f('0x15')](_0x22aa19[_0x4ffd8e][0x0][_0x336f('0x1a')]);_0x58d345=_[_0x336f('0x3e')](_0x58d345,_0x20f9fc[_0x336f('0x13')]);}}return _0x138648[_0x336f('0x40')](function(_0x193d32){return _0x138648['models'][_0x336f('0x7')][_0x336f('0x41')]({'where':{'VoiceExtensionId':{'$in':_0x47097e}},'transaction':_0x193d32})[_0x336f('0x4')](function(_0x415b61){return _0x138648['models'][_0x336f('0x7')][_0x336f('0x42')](_[_0x336f('0x43')](_0x58d345,'priority'),{'transaction':_0x193d32});});});})[_0x336f('0x44')](function(_0x527606){console[_0x336f('0x45')](_0x527606);});}exports[_0x336f('0x46')]=rewrite;
\ No newline at end of file