Built motion from commit ecb45b58.|2.6.31
[motion2.git] / server / components / extensions / rewrite.js
index 7863879..7e7b1c2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1c1=['$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1','$[${XCALLY-MOTION-PROGRESS}=0]?Progress','splice','GotoIfTime',',${EXTEN},','last','concat','Hangup','transaction','destroy','sortBy','catch','rewrite','util','Interval','then','intervals','models','VoiceExtension','findAll','uniq','map','exten','CAST(priority\x20AS\x20UNSIGNED)','filter','groupBy','queue','playback','priority','extensions','find','push','type','Set','format','CDR(type)=%s','context','VoiceExtensionId','CDR(routeid)=','outbound','extension','CDR(destination)=','cutdigits','${EXTEN:','${EXTEN}','ExecIf','):Goto(','CDR(prefix)=${EXTEN:0:','outboundrouteid=','hasOwnProperty','recordingFormat','none','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','_XCALLY_MIXMONITOR_FORMAT=','wav','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','length','createdAt','updatedAt','interval','*,*,*,*','IntervalId','tag','CDR(tag)=','callerID','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','indexOf','app','appType','answer'];(function(_0x45ad37,_0x4e179f){var _0x18fd80=function(_0x5b5644){while(--_0x5b5644){_0x45ad37['push'](_0x45ad37['shift']());}};_0x18fd80(++_0x4e179f);}(_0xf1c1,0x1c4));var _0x1f1c=function(_0x34c46d,_0x4501bd){_0x34c46d=_0x34c46d-0x0;var _0x263c1a=_0xf1c1[_0x34c46d];return _0x263c1a;};'use strict';var _=require('lodash');var util=require(_0x1f1c('0x0'));function rewrite(_0x566eba,_0x14bdfb){var _0x3c9b0d=this;return _0x566eba['models'][_0x1f1c('0x1')]['findAll']({'raw':!![]})[_0x1f1c('0x2')](function(_0x7dbc6b){_0x3c9b0d[_0x1f1c('0x3')]=_0x7dbc6b;return _0x566eba[_0x1f1c('0x4')][_0x1f1c('0x5')][_0x1f1c('0x6')]({'where':{'IntervalId':_0x14bdfb['IntervalId']},'raw':!![]});})[_0x1f1c('0x2')](function(_0x47c947){return _0x566eba[_0x1f1c('0x4')][_0x1f1c('0x5')]['findAll']({'where':{'exten':{'$in':_[_0x1f1c('0x7')](_[_0x1f1c('0x8')](_0x47c947,_0x1f1c('0x9')))}},'order':[{'raw':_0x1f1c('0xa')}],'raw':!![]});})[_0x1f1c('0x2')](function(_0xd7c0fb){var _0x3eb09b=_[_0x1f1c('0xb')](_0xd7c0fb,{'priority':'1'});var _0xe559ed=_[_0x1f1c('0xb')](_0xd7c0fb,{'isApp':0x1});var _0x35c3c1=_[_0x1f1c('0xc')](_0xe559ed,_0x1f1c('0x9'));var _0x49868a=[_0x1f1c('0xd'),_0x1f1c('0xe')];var _0x28c282=[];var _0x1cbd74=[];for(var _0x4b6e32 in _0x35c3c1){if(_0x35c3c1['hasOwnProperty'](_0x4b6e32)){_0x3c9b0d[_0x1f1c('0xf')]=0x2;_0x3c9b0d[_0x1f1c('0x10')]=[];_0x3c9b0d['extension']=_[_0x1f1c('0x11')](_0x3eb09b,{'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')]});_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':util[_0x1f1c('0x15')](_0x1f1c('0x16'),_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')]),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});if(_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')]==='inbound'){_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x19')+_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId'],'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});}else if(_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')]===_0x1f1c('0x1a')){if(_0x3c9b0d[_0x1f1c('0x1b')]){_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0]['type'],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x1c')+(_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x1d')]?_0x1f1c('0x1e')+_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x1d')]+'}':_0x1f1c('0x1f')),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId']});}_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0]['type'],'app':'Set','appdata':'CDR(routeid)='+_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')],'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});var _0x57b347=_0x3c9b0d[_0x1f1c('0xf')]++;_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x20'),'appdata':'$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto('+(_0x57b347+0x2)+_0x1f1c('0x21')+(_0x57b347+0x1)+')','context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x57b347,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId']});if(_0x3c9b0d[_0x1f1c('0x1b')]){_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0]['type'],'app':'Set','appdata':_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x1d')]?_0x1f1c('0x22')+_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x1d')]+'}':'CDR(prefix)=noprefix','context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0]['exten'],'priority':_0x3c9b0d['priority']++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});}_0x3c9b0d['extensions']['push']({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x23')+_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')],'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d['priority']++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});if(_0x3c9b0d[_0x1f1c('0x1b')]&&_0x3c9b0d['extension'][_0x1f1c('0x24')](_0x1f1c('0x25'))&&_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x25')]!==_0x1f1c('0x26')){_0x3c9b0d['extensions'][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':'Set','appdata':_0x1f1c('0x27'),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0]['exten'],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});_0x3c9b0d['extensions']['push']({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x28')+_0x3c9b0d[_0x1f1c('0x1b')][_0x1f1c('0x25')]||_0x1f1c('0x29'),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});}}_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x2a'),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d['priority']++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId']});_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':'Set','appdata':_0x1f1c('0x2b'),'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId']});_0x3c9b0d[_0x1f1c('0x10')]['push']({'type':_0x35c3c1[_0x4b6e32][0x0]['type'],'app':'Set','appdata':_0x1f1c('0x2c'),'context':_0x35c3c1[_0x4b6e32][0x0]['context'],'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'priority':_0x3c9b0d[_0x1f1c('0xf')]++,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});for(var _0x201f03=0x0,_0x21c4e3=0x0;_0x201f03<_0x35c3c1[_0x4b6e32][_0x1f1c('0x2d')];_0x201f03+=0x1,_0x21c4e3=0x0){var _0x4cf765=_0x35c3c1[_0x4b6e32][_0x201f03];if(_0x4cf765[_0x1f1c('0x13')]){_0x4cf765[_0x1f1c('0x13')]=_0x4cf765[_0x1f1c('0x13')]['toLowerCase']();}var _0x470b86=[];var _0x1177b9=[];delete _0x4cf765['id'];delete _0x4cf765[_0x1f1c('0x2e')];delete _0x4cf765[_0x1f1c('0x2f')];var _0x34146f=_0x4cf765[_0x1f1c('0x30')]!==_0x1f1c('0x31')?[_0x4cf765['interval']]:_0x4cf765[_0x1f1c('0x32')]?_['map'](_[_0x1f1c('0xb')](_0x3c9b0d[_0x1f1c('0x3')],{'IntervalId':_0x4cf765[_0x1f1c('0x32')]}),_0x1f1c('0x30')):[];if(_0x4cf765[_0x1f1c('0x24')](_0x1f1c('0x33'))){if(_0x4cf765['tag']&&_0x4cf765[_0x1f1c('0x33')]!=='--'){_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765[_0x1f1c('0x13')],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x34')+_0x4cf765[_0x1f1c('0x33')],'context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765['exten'],'priority':_0x34146f['length']+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765['VoiceExtensionId']});}}if(_0x4cf765[_0x1f1c('0x13')]===_0x1f1c('0x1a')&&_0x4cf765[_0x1f1c('0x24')](_0x1f1c('0x35'))){if(_0x4cf765[_0x1f1c('0x35')]){_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765['type'],'app':_0x1f1c('0x20'),'appdata':'$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)='+_0x4cf765['callerID']+')','context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765[_0x1f1c('0x9')],'priority':_0x34146f[_0x1f1c('0x2d')]+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765['VoiceExtensionId']});}else{_0x470b86['push']({'type':_0x4cf765[_0x1f1c('0x13')],'app':'ExecIf','appdata':_0x1f1c('0x36'),'context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765['exten'],'priority':_0x34146f[_0x1f1c('0x2d')]+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765['VoiceExtensionId']});}}if(_0x4cf765['hasOwnProperty']('answer')){if(_0x49868a[_0x1f1c('0x37')](_0x4cf765[_0x1f1c('0x38')]['toLowerCase']())>=0x0&&_0x4cf765[_0x1f1c('0x39')]!=='custom'){if(_0x4cf765[_0x1f1c('0x3a')]){_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765[_0x1f1c('0x13')],'app':_0x1f1c('0x20'),'appdata':_0x1f1c('0x3b'),'context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765['exten'],'priority':_0x34146f['length']+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765[_0x1f1c('0x18')]});_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765['type'],'app':_0x1f1c('0x14'),'appdata':_0x1f1c('0x3c'),'context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765['exten'],'priority':_0x34146f[_0x1f1c('0x2d')]+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765[_0x1f1c('0x18')]});}else{_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765[_0x1f1c('0x13')],'app':'ExecIf','appdata':_0x1f1c('0x3d'),'context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765[_0x1f1c('0x9')],'priority':_0x34146f[_0x1f1c('0x2d')]+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765[_0x1f1c('0x18')]});_0x470b86[_0x1f1c('0x12')]({'type':_0x4cf765[_0x1f1c('0x13')],'app':'Set','appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x4cf765[_0x1f1c('0x17')],'exten':_0x4cf765[_0x1f1c('0x9')],'priority':_0x34146f[_0x1f1c('0x2d')]+_0x3c9b0d[_0x1f1c('0xf')]+_0x21c4e3++,'VoiceExtensionId':_0x4cf765[_0x1f1c('0x18')]});}}}for(var _0x1a866=0x0;_0x1a866<_0x34146f[_0x1f1c('0x2d')];_0x1a866+=0x1){var _0x19ceff=_0x3c9b0d[_0x1f1c('0xf')]+_0x34146f[_0x1f1c('0x2d')];var _0x4a3e98=_0x1a866===_0x34146f[_0x1f1c('0x2d')]-0x1?_0x3c9b0d[_0x1f1c('0xf')]+_0x470b86[_0x1f1c('0x2d')]+_0x1177b9[_0x1f1c('0x2d')]+0x2:_0x3c9b0d['priority']+_0x1a866+0x1;_0x470b86[_0x1f1c('0x3e')](_0x1a866,0x0,{'type':_0x4cf765[_0x1f1c('0x13')],'app':_0x1f1c('0x3f'),'appdata':_0x34146f[_0x1a866]+'?'+_0x4cf765[_0x1f1c('0x17')]+_0x1f1c('0x40')+_0x19ceff+':'+_0x4cf765['context']+_0x1f1c('0x40')+_0x4a3e98,'exten':_0x4cf765[_0x1f1c('0x9')],'context':_0x4cf765[_0x1f1c('0x17')],'priority':_0x3c9b0d[_0x1f1c('0xf')]+_0x1a866,'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});}_0x4cf765['priority']=_0x470b86['length']?_[_0x1f1c('0x41')](_0x470b86)[_0x1f1c('0xf')]+0x1:_0x3c9b0d[_0x1f1c('0xf')];_0x3c9b0d[_0x1f1c('0xf')]=(_0x1177b9[_0x1f1c('0x2d')]?_[_0x1f1c('0x41')](_0x1177b9)[_0x1f1c('0xf')]:_0x4cf765['priority'])+0x1;_0x3c9b0d[_0x1f1c('0x10')]=_[_0x1f1c('0x42')](_0x3c9b0d[_0x1f1c('0x10')],_0x470b86,[_0x4cf765],_0x1177b9);}_0x3c9b0d[_0x1f1c('0x10')][_0x1f1c('0x12')]({'type':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x13')],'app':_0x1f1c('0x43'),'exten':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x9')],'context':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x17')],'priority':_0x3c9b0d[_0x1f1c('0xf')],'VoiceExtensionId':_0x35c3c1[_0x4b6e32][0x0][_0x1f1c('0x18')]});_0x28c282[_0x1f1c('0x12')](_0x35c3c1[_0x4b6e32][0x0]['VoiceExtensionId']);_0x1cbd74=_[_0x1f1c('0x42')](_0x1cbd74,_0x3c9b0d['extensions']);}}return _0x566eba[_0x1f1c('0x44')](function(_0xa793f8){return _0x566eba[_0x1f1c('0x4')]['VoiceExtension'][_0x1f1c('0x45')]({'where':{'VoiceExtensionId':{'$in':_0x28c282}},'transaction':_0xa793f8})[_0x1f1c('0x2')](function(_0x14fca9){return _0x566eba[_0x1f1c('0x4')][_0x1f1c('0x5')]['bulkCreate'](_[_0x1f1c('0x46')](_0x1cbd74,_0x1f1c('0xf')),{'transaction':_0xa793f8});});});})[_0x1f1c('0x47')](function(_0x498099){console['error'](_0x498099);});}exports[_0x1f1c('0x48')]=rewrite;
\ No newline at end of file
+var _0x8f79=['answer','$[${XCALLY-MOTION-ANSWER}=0]?Answer','XCALLY-MOTION-ANSWER=1','$[${XCALLY-MOTION-PROGRESS}=0]?Progress','XCALLY-MOTION-PROGRESS=1','splice','GotoIfTime',',${EXTEN},','last','concat','Hangup','transaction','destroy','bulkCreate','sortBy','catch','util','models','Interval','findAll','then','intervals','VoiceExtension','IntervalId','uniq','map','exten','CAST(priority\x20AS\x20UNSIGNED)','filter','playback','priority','extensions','find','push','type','VoiceExtensionId','Set','CDR(routeid)=','outbound','extension','CDR(destination)=','cutdigits','${EXTEN:','${EXTEN}','context','ExecIf','$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto(','):Goto(','CDR(prefix)=${EXTEN:0:','hasOwnProperty','recordingFormat','none','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','wav','XCALLY-MOTION-ANSWER=0','XCALLY-MOTION-PROGRESS=0','MONITOR_OPTIONS=ab','toLowerCase','createdAt','updatedAt','*,*,*,*','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)','length','indexOf','app','custom'];(function(_0x9728b2,_0x51634d){var _0x4d304c=function(_0x5a5abf){while(--_0x5a5abf){_0x9728b2['push'](_0x9728b2['shift']());}};_0x4d304c(++_0x51634d);}(_0x8f79,0x1f3));var _0x98f7=function(_0x382ec0,_0x42db70){_0x382ec0=_0x382ec0-0x0;var _0x15c1a7=_0x8f79[_0x382ec0];return _0x15c1a7;};'use strict';var _=require('lodash');var util=require(_0x98f7('0x0'));function rewrite(_0x1a8702,_0x156714){var _0x4951c8=this;return _0x1a8702[_0x98f7('0x1')][_0x98f7('0x2')][_0x98f7('0x3')]({'raw':!![]})[_0x98f7('0x4')](function(_0x389391){_0x4951c8[_0x98f7('0x5')]=_0x389391;return _0x1a8702[_0x98f7('0x1')][_0x98f7('0x6')][_0x98f7('0x3')]({'where':{'IntervalId':_0x156714[_0x98f7('0x7')]},'raw':!![]});})['then'](function(_0x14a849){return _0x1a8702['models']['VoiceExtension'][_0x98f7('0x3')]({'where':{'exten':{'$in':_[_0x98f7('0x8')](_[_0x98f7('0x9')](_0x14a849,_0x98f7('0xa')))}},'order':[{'raw':_0x98f7('0xb')}],'raw':!![]});})[_0x98f7('0x4')](function(_0x39f074){var _0x45f1ca=_[_0x98f7('0xc')](_0x39f074,{'priority':'1'});var _0x3c39ba=_[_0x98f7('0xc')](_0x39f074,{'isApp':0x1});var _0x2a1173=_['groupBy'](_0x3c39ba,_0x98f7('0xa'));var _0x30cbfa=['queue',_0x98f7('0xd')];var _0x51d8dc=[];var _0x295ecd=[];for(var _0x3e070b in _0x2a1173){if(_0x2a1173['hasOwnProperty'](_0x3e070b)){_0x4951c8[_0x98f7('0xe')]=0x2;_0x4951c8[_0x98f7('0xf')]=[];_0x4951c8['extension']=_[_0x98f7('0x10')](_0x45f1ca,{'exten':_0x2a1173[_0x3e070b][0x0]['exten']});_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':'Set','appdata':util['format']('CDR(type)=%s',_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')]),'context':_0x2a1173[_0x3e070b][0x0]['context'],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});if(_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')]==='inbound'){_0x4951c8['extensions'][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x15')+_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')],'context':_0x2a1173[_0x3e070b][0x0]['context'],'exten':_0x2a1173[_0x3e070b][0x0]['exten'],'priority':_0x4951c8[_0x98f7('0xe')]++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});}else if(_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')]===_0x98f7('0x16')){if(_0x4951c8[_0x98f7('0x17')]){_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x18')+(_0x4951c8[_0x98f7('0x17')][_0x98f7('0x19')]?_0x98f7('0x1a')+_0x4951c8['extension'][_0x98f7('0x19')]+'}':_0x98f7('0x1b')),'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0]['VoiceExtensionId']});}_0x4951c8['extensions']['push']({'type':_0x2a1173[_0x3e070b][0x0]['type'],'app':'Set','appdata':'CDR(routeid)='+_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')],'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8[_0x98f7('0xe')]++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});var _0xeb9271=_0x4951c8[_0x98f7('0xe')]++;_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x1d'),'appdata':_0x98f7('0x1e')+(_0xeb9271+0x2)+_0x98f7('0x1f')+(_0xeb9271+0x1)+')','context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0xeb9271,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});if(_0x4951c8['extension']){_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':'Set','appdata':_0x4951c8[_0x98f7('0x17')][_0x98f7('0x19')]?_0x98f7('0x20')+_0x4951c8['extension'][_0x98f7('0x19')]+'}':'CDR(prefix)=noprefix','context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0]['VoiceExtensionId']});}_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0]['type'],'app':_0x98f7('0x14'),'appdata':'outboundrouteid='+_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')],'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0]['VoiceExtensionId']});if(_0x4951c8['extension']&&_0x4951c8[_0x98f7('0x17')][_0x98f7('0x21')](_0x98f7('0x22'))&&_0x4951c8[_0x98f7('0x17')][_0x98f7('0x22')]!==_0x98f7('0x23')){_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x24'),'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8[_0x98f7('0xe')]++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':'_XCALLY_MIXMONITOR_FORMAT='+_0x4951c8['extension'][_0x98f7('0x22')]||_0x98f7('0x25'),'context':_0x2a1173[_0x3e070b][0x0]['context'],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0]['VoiceExtensionId']});}}_0x4951c8['extensions'][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':'Set','appdata':_0x98f7('0x26'),'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0]['exten'],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0]['type'],'app':'Set','appdata':_0x98f7('0x27'),'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0]['type'],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x28'),'context':_0x2a1173[_0x3e070b][0x0]['context'],'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'priority':_0x4951c8['priority']++,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});for(var _0x2d95e6=0x0,_0x2f9281=0x0;_0x2d95e6<_0x2a1173[_0x3e070b]['length'];_0x2d95e6+=0x1,_0x2f9281=0x0){var _0x2ff990=_0x2a1173[_0x3e070b][_0x2d95e6];if(_0x2ff990[_0x98f7('0x12')]){_0x2ff990[_0x98f7('0x12')]=_0x2ff990['type'][_0x98f7('0x29')]();}var _0x533980=[];var _0x38d91d=[];delete _0x2ff990['id'];delete _0x2ff990[_0x98f7('0x2a')];delete _0x2ff990[_0x98f7('0x2b')];var _0xd8e2f6=_0x2ff990['interval']!==_0x98f7('0x2c')?[_0x2ff990['interval']]:_0x2ff990[_0x98f7('0x7')]?_['map'](_['filter'](_0x4951c8[_0x98f7('0x5')],{'IntervalId':_0x2ff990[_0x98f7('0x7')]}),'interval'):[];if(_0x2ff990['hasOwnProperty'](_0x98f7('0x2d'))){if(_0x2ff990[_0x98f7('0x2d')]&&_0x2ff990['tag']!=='--'){_0x533980[_0x98f7('0x11')]({'type':_0x2ff990[_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':'CDR(tag)='+_0x2ff990[_0x98f7('0x2d')],'context':_0x2ff990['context'],'exten':_0x2ff990['exten'],'priority':_0xd8e2f6['length']+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990[_0x98f7('0x13')]});}}if(_0x2ff990[_0x98f7('0x12')]===_0x98f7('0x16')&&_0x2ff990['hasOwnProperty'](_0x98f7('0x2e'))){if(_0x2ff990[_0x98f7('0x2e')]){_0x533980['push']({'type':_0x2ff990[_0x98f7('0x12')],'app':_0x98f7('0x1d'),'appdata':_0x98f7('0x2f')+_0x2ff990[_0x98f7('0x2e')]+')','context':_0x2ff990['context'],'exten':_0x2ff990[_0x98f7('0xa')],'priority':_0xd8e2f6['length']+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990[_0x98f7('0x13')]});}else{_0x533980[_0x98f7('0x11')]({'type':_0x2ff990[_0x98f7('0x12')],'app':_0x98f7('0x1d'),'appdata':_0x98f7('0x30'),'context':_0x2ff990[_0x98f7('0x1c')],'exten':_0x2ff990['exten'],'priority':_0xd8e2f6[_0x98f7('0x31')]+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990['VoiceExtensionId']});}}if(_0x2ff990[_0x98f7('0x21')]('answer')){if(_0x30cbfa[_0x98f7('0x32')](_0x2ff990[_0x98f7('0x33')][_0x98f7('0x29')]())>=0x0&&_0x2ff990['appType']!==_0x98f7('0x34')){if(_0x2ff990[_0x98f7('0x35')]){_0x533980['push']({'type':_0x2ff990['type'],'app':'ExecIf','appdata':_0x98f7('0x36'),'context':_0x2ff990[_0x98f7('0x1c')],'exten':_0x2ff990[_0x98f7('0xa')],'priority':_0xd8e2f6[_0x98f7('0x31')]+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990[_0x98f7('0x13')]});_0x533980[_0x98f7('0x11')]({'type':_0x2ff990[_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x37'),'context':_0x2ff990[_0x98f7('0x1c')],'exten':_0x2ff990[_0x98f7('0xa')],'priority':_0xd8e2f6['length']+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990['VoiceExtensionId']});}else{_0x533980[_0x98f7('0x11')]({'type':_0x2ff990[_0x98f7('0x12')],'app':'ExecIf','appdata':_0x98f7('0x38'),'context':_0x2ff990['context'],'exten':_0x2ff990[_0x98f7('0xa')],'priority':_0xd8e2f6['length']+_0x4951c8['priority']+_0x2f9281++,'VoiceExtensionId':_0x2ff990['VoiceExtensionId']});_0x533980[_0x98f7('0x11')]({'type':_0x2ff990[_0x98f7('0x12')],'app':_0x98f7('0x14'),'appdata':_0x98f7('0x39'),'context':_0x2ff990[_0x98f7('0x1c')],'exten':_0x2ff990[_0x98f7('0xa')],'priority':_0xd8e2f6[_0x98f7('0x31')]+_0x4951c8[_0x98f7('0xe')]+_0x2f9281++,'VoiceExtensionId':_0x2ff990['VoiceExtensionId']});}}}for(var _0x45509b=0x0;_0x45509b<_0xd8e2f6['length'];_0x45509b+=0x1){var _0x5e3f9d=_0x4951c8[_0x98f7('0xe')]+_0xd8e2f6[_0x98f7('0x31')];var _0xbebb1e=_0x45509b===_0xd8e2f6[_0x98f7('0x31')]-0x1?_0x4951c8[_0x98f7('0xe')]+_0x533980[_0x98f7('0x31')]+_0x38d91d[_0x98f7('0x31')]+0x2:_0x4951c8[_0x98f7('0xe')]+_0x45509b+0x1;_0x533980[_0x98f7('0x3a')](_0x45509b,0x0,{'type':_0x2ff990['type'],'app':_0x98f7('0x3b'),'appdata':_0xd8e2f6[_0x45509b]+'?'+_0x2ff990[_0x98f7('0x1c')]+_0x98f7('0x3c')+_0x5e3f9d+':'+_0x2ff990[_0x98f7('0x1c')]+_0x98f7('0x3c')+_0xbebb1e,'exten':_0x2ff990[_0x98f7('0xa')],'context':_0x2ff990[_0x98f7('0x1c')],'priority':_0x4951c8['priority']+_0x45509b,'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0]['VoiceExtensionId']});}_0x2ff990[_0x98f7('0xe')]=_0x533980[_0x98f7('0x31')]?_[_0x98f7('0x3d')](_0x533980)[_0x98f7('0xe')]+0x1:_0x4951c8[_0x98f7('0xe')];_0x4951c8[_0x98f7('0xe')]=(_0x38d91d[_0x98f7('0x31')]?_[_0x98f7('0x3d')](_0x38d91d)['priority']:_0x2ff990[_0x98f7('0xe')])+0x1;_0x4951c8[_0x98f7('0xf')]=_[_0x98f7('0x3e')](_0x4951c8[_0x98f7('0xf')],_0x533980,[_0x2ff990],_0x38d91d);}_0x4951c8[_0x98f7('0xf')][_0x98f7('0x11')]({'type':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x12')],'app':_0x98f7('0x3f'),'exten':_0x2a1173[_0x3e070b][0x0][_0x98f7('0xa')],'context':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x1c')],'priority':_0x4951c8[_0x98f7('0xe')],'VoiceExtensionId':_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]});_0x51d8dc[_0x98f7('0x11')](_0x2a1173[_0x3e070b][0x0][_0x98f7('0x13')]);_0x295ecd=_[_0x98f7('0x3e')](_0x295ecd,_0x4951c8[_0x98f7('0xf')]);}}return _0x1a8702[_0x98f7('0x40')](function(_0x520347){return _0x1a8702[_0x98f7('0x1')][_0x98f7('0x6')][_0x98f7('0x41')]({'where':{'VoiceExtensionId':{'$in':_0x51d8dc}},'transaction':_0x520347})[_0x98f7('0x4')](function(_0x3b9a87){return _0x1a8702[_0x98f7('0x1')][_0x98f7('0x6')][_0x98f7('0x42')](_[_0x98f7('0x43')](_0x295ecd,_0x98f7('0xe')),{'transaction':_0x520347});});});})[_0x98f7('0x44')](function(_0x16a7c2){console['error'](_0x16a7c2);});}exports['rewrite']=rewrite;
\ No newline at end of file