00f79d03953e229ed988baf859724d36f4e25b43
[motion-next.git] / server / components / extensions / rewrite.js
1 const a829_0x1dc1=['MONITOR_OPTIONS=ab','splice','IntervalId','ExecIf','uniq','groupBy','XCALLY-MOTION-PROGRESS=0','push','lodash','CDR(prefix)=noprefix','Interval','_XCALLY_MIXMONITOR_UNIQUEID=${UNIQUEID}','models','interval','concat','Hangup','outboundrouteid=','CDR(type)=%s','$[${XCALLY-MOTION-PROGRESS}=0]?Progress','playback','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):Set(CALLERID(all)=','exten','_XCALLY_MIXMONITOR_FORMAT=','intervals','outbound','$[${LEN(${PREFIX-CALLERIDALL})}\x20>\x200]?Set(CALLERID(all)=${PREFIX-CALLERIDALL}):NoOp(No\x20number\x20available)','undefined','filter','answer','Set','callerID','${EXTEN}','VoiceExtension','XCALLY-MOTION-ANSWER=0','literal','sortBy','extension','find','catch','rewrite','length','VoiceExtensionId','format','tag','CAST(priority\x20AS\x20UNSIGNED)','extensions','XCALLY-MOTION-ANSWER=1','bulkCreate','none','findAll','context','last','createdAt','):Goto(','CDR(routeid)=',',${EXTEN},','cutdigits','priority','recordingFormat','CDR(destination)=','type','then','toLowerCase','destroy','map','appType','queue','CDR(tag)=','error','custom','sequelize','indexOf'];(function(_0x292c81,_0x1dc10b){const _0x15c07c=function(_0x2947d8){while(--_0x2947d8){_0x292c81['push'](_0x292c81['shift']());}};_0x15c07c(++_0x1dc10b);}(a829_0x1dc1,0x95));const a829_0x15c0=function(_0x292c81,_0x1dc10b){_0x292c81=_0x292c81-0x0;let _0x15c07c=a829_0x1dc1[_0x292c81];return _0x15c07c;};const _0x483084=a829_0x15c0;'use strict';const _=require(_0x483084('0x3')),util=require('util'),{Op}=require(_0x483084('0x41'));function rewrite(_0x2947d8,_0x2c8678){const _0x20c34b=_0x483084,_0x4f9d8b=this;return _0x2947d8[_0x20c34b('0x7')][_0x20c34b('0x5')][_0x20c34b('0x2c')]({'raw':!![]})[_0x20c34b('0x38')](function(_0x2935db){const _0x3be89a=_0x20c34b;return _0x4f9d8b[_0x3be89a('0x12')]=_0x2935db,_0x2947d8[_0x3be89a('0x7')][_0x3be89a('0x1b')]['findAll']({'where':{'IntervalId':_0x2c8678[_0x3be89a('0x45')]},'raw':!![]});})[_0x20c34b('0x38')](function(_0x5793ec){const _0x22f707=_0x20c34b;return _0x2947d8[_0x22f707('0x7')][_0x22f707('0x1b')][_0x22f707('0x2c')]({'where':{'exten':{[Op['in']]:_[_0x22f707('0x47')](_['map'](_0x5793ec,_0x22f707('0x10')))}},'order':_0x2947d8[_0x22f707('0x1d')](_0x22f707('0x27')),'raw':!![]});})[_0x20c34b('0x38')](function(_0x4b8157){const _0x544654=_0x20c34b,_0x7ad066=_[_0x544654('0x16')](_0x4b8157,{'priority':'1'}),_0x1f7c69=_['filter'](_0x4b8157,{'isApp':0x1}),_0x35213a=_[_0x544654('0x0')](_0x1f7c69,_0x544654('0x10')),_0x39b507=[_0x544654('0x3d'),_0x544654('0xe')],_0x4120e6=[];let _0x10ba52=[];for(const _0x53fdda in _0x35213a){if(typeof _0x35213a[_0x53fdda]!=='undefined'){_0x4f9d8b[_0x544654('0x34')]=0x2,_0x4f9d8b[_0x544654('0x28')]=[],_0x4f9d8b[_0x544654('0x1f')]=_[_0x544654('0x20')](_0x7ad066,{'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')]}),_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':'Set','appdata':util[_0x544654('0x25')](_0x544654('0xc'),_0x35213a[_0x53fdda][0x0][_0x544654('0x37')]),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]});if(_0x35213a[_0x53fdda][0x0][_0x544654('0x37')]===_0x544654('0x13')){_0x4f9d8b[_0x544654('0x1f')]&&_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':'Set','appdata':_0x544654('0x36')+(_0x4f9d8b['extension'][_0x544654('0x33')]?'${EXTEN:'+_0x4f9d8b[_0x544654('0x1f')][_0x544654('0x33')]+'}':_0x544654('0x1a')),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]});_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':'Set','appdata':_0x544654('0x31')+_0x35213a[_0x53fdda][0x0][_0x544654('0x24')],'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]});const _0xe42bfa=_0x4f9d8b[_0x544654('0x34')]++;_0x4f9d8b[_0x544654('0x28')]['push']({'type':_0x35213a[_0x53fdda][0x0]['type'],'app':'ExecIf','appdata':'$[${LEN(${CDR(prefix)})}\x20>\x200]?Goto('+(_0xe42bfa+0x2)+_0x544654('0x30')+(_0xe42bfa+0x1)+')','context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0]['exten'],'priority':_0xe42bfa,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4f9d8b[_0x544654('0x1f')]&&_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x4f9d8b[_0x544654('0x1f')][_0x544654('0x33')]?'CDR(prefix)=${EXTEN:0:'+_0x4f9d8b[_0x544654('0x1f')][_0x544654('0x33')]+'}':_0x544654('0x4'),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0xb')+_0x35213a[_0x53fdda][0x0][_0x544654('0x24')],'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0]['exten'],'priority':_0x4f9d8b['priority']++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4f9d8b[_0x544654('0x1f')]&&typeof _0x4f9d8b['extension']['recordingFormat']!==_0x544654('0x15')&&_0x4f9d8b[_0x544654('0x1f')][_0x544654('0x35')]!==_0x544654('0x2b')&&(_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0]['type'],'app':_0x544654('0x18'),'appdata':_0x544654('0x6'),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b['priority']++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0x11')+_0x4f9d8b[_0x544654('0x1f')][_0x544654('0x35')]||'wav','context':_0x35213a[_0x53fdda][0x0]['context'],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b['priority']++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}));}_0x4f9d8b[_0x544654('0x28')][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0x1c'),'context':_0x35213a[_0x53fdda][0x0]['context'],'exten':_0x35213a[_0x53fdda][0x0][_0x544654('0x10')],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0]['VoiceExtensionId']}),_0x4f9d8b[_0x544654('0x28')]['push']({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0x1'),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0]['exten'],'priority':_0x4f9d8b[_0x544654('0x34')]++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4f9d8b['extensions'][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':'Set','appdata':_0x544654('0x43'),'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'exten':_0x35213a[_0x53fdda][0x0]['exten'],'priority':_0x4f9d8b['priority']++,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]});for(let _0x3f5d46=0x0,_0x80e6fe=0x0;_0x3f5d46<_0x35213a[_0x53fdda][_0x544654('0x23')];_0x3f5d46+=0x1,_0x80e6fe=0x0){const _0x44ed64=_0x35213a[_0x53fdda][_0x3f5d46];_0x44ed64['type']&&(_0x44ed64[_0x544654('0x37')]=_0x44ed64[_0x544654('0x37')]['toLowerCase']());const _0x197edf=[],_0xd1abc4=[];delete _0x44ed64['id'],delete _0x44ed64[_0x544654('0x2f')],delete _0x44ed64['updatedAt'];const _0x7c8c0a=_0x44ed64[_0x544654('0x8')]!=='*,*,*,*'?[_0x44ed64['interval']]:_0x44ed64[_0x544654('0x45')]?_[_0x544654('0x3b')](_[_0x544654('0x16')](_0x4f9d8b[_0x544654('0x12')],{'IntervalId':_0x44ed64['IntervalId']}),'interval'):[];typeof _0x44ed64[_0x544654('0x26')]!==_0x544654('0x15')&&(_0x44ed64[_0x544654('0x26')]&&_0x44ed64['tag']!=='--'&&_0x197edf['push']({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0x3e')+_0x44ed64['tag'],'context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64[_0x544654('0x10')],'priority':_0x7c8c0a[_0x544654('0x23')]+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]}));_0x44ed64[_0x544654('0x37')]==='outbound'&&typeof _0x44ed64[_0x544654('0x19')]!==_0x544654('0x15')&&(_0x44ed64[_0x544654('0x19')]?_0x197edf['push']({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x46'),'appdata':_0x544654('0xf')+_0x44ed64['callerID']+')','context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64['exten'],'priority':_0x7c8c0a['length']+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]}):_0x197edf[_0x544654('0x2')]({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x46'),'appdata':_0x544654('0x14'),'context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64['exten'],'priority':_0x7c8c0a[_0x544654('0x23')]+_0x4f9d8b['priority']+_0x80e6fe++,'VoiceExtensionId':_0x44ed64['VoiceExtensionId']}));typeof _0x44ed64[_0x544654('0x17')]!==_0x544654('0x15')&&(_0x39b507[_0x544654('0x42')](_0x44ed64['app'][_0x544654('0x39')]())>=0x0&&_0x44ed64[_0x544654('0x3c')]!==_0x544654('0x40')&&(_0x44ed64[_0x544654('0x17')]?(_0x197edf[_0x544654('0x2')]({'type':_0x44ed64[_0x544654('0x37')],'app':'ExecIf','appdata':'$[${XCALLY-MOTION-ANSWER}=0]?Answer','context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64[_0x544654('0x10')],'priority':_0x7c8c0a['length']+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]}),_0x197edf['push']({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':_0x544654('0x29'),'context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64[_0x544654('0x10')],'priority':_0x7c8c0a[_0x544654('0x23')]+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]})):(_0x197edf['push']({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x46'),'appdata':_0x544654('0xd'),'context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64[_0x544654('0x10')],'priority':_0x7c8c0a[_0x544654('0x23')]+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]}),_0x197edf['push']({'type':_0x44ed64[_0x544654('0x37')],'app':_0x544654('0x18'),'appdata':'XCALLY-MOTION-PROGRESS=1','context':_0x44ed64[_0x544654('0x2d')],'exten':_0x44ed64[_0x544654('0x10')],'priority':_0x7c8c0a[_0x544654('0x23')]+_0x4f9d8b[_0x544654('0x34')]+_0x80e6fe++,'VoiceExtensionId':_0x44ed64[_0x544654('0x24')]}))));for(let _0x161319=0x0;_0x161319<_0x7c8c0a[_0x544654('0x23')];_0x161319+=0x1){const _0x550114=_0x4f9d8b[_0x544654('0x34')]+_0x7c8c0a[_0x544654('0x23')],_0xeda908=_0x161319===_0x7c8c0a[_0x544654('0x23')]-0x1?_0x4f9d8b[_0x544654('0x34')]+_0x197edf[_0x544654('0x23')]+_0xd1abc4[_0x544654('0x23')]+0x2:_0x4f9d8b[_0x544654('0x34')]+_0x161319+0x1;_0x197edf[_0x544654('0x44')](_0x161319,0x0,{'type':_0x44ed64[_0x544654('0x37')],'app':'GotoIfTime','appdata':_0x7c8c0a[_0x161319]+'?'+_0x44ed64[_0x544654('0x2d')]+_0x544654('0x32')+_0x550114+':'+_0x44ed64[_0x544654('0x2d')]+',${EXTEN},'+_0xeda908,'exten':_0x44ed64[_0x544654('0x10')],'context':_0x44ed64[_0x544654('0x2d')],'priority':_0x4f9d8b[_0x544654('0x34')]+_0x161319,'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]});}_0x44ed64[_0x544654('0x34')]=_0x197edf[_0x544654('0x23')]?_[_0x544654('0x2e')](_0x197edf)['priority']+0x1:_0x4f9d8b[_0x544654('0x34')],_0x4f9d8b[_0x544654('0x34')]=(_0xd1abc4[_0x544654('0x23')]?_['last'](_0xd1abc4)[_0x544654('0x34')]:_0x44ed64['priority'])+0x1,_0x4f9d8b[_0x544654('0x28')]=_['concat'](_0x4f9d8b['extensions'],_0x197edf,[_0x44ed64],_0xd1abc4);}_0x4f9d8b['extensions'][_0x544654('0x2')]({'type':_0x35213a[_0x53fdda][0x0][_0x544654('0x37')],'app':_0x544654('0xa'),'exten':_0x35213a[_0x53fdda][0x0]['exten'],'context':_0x35213a[_0x53fdda][0x0][_0x544654('0x2d')],'priority':_0x4f9d8b[_0x544654('0x34')],'VoiceExtensionId':_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]}),_0x4120e6[_0x544654('0x2')](_0x35213a[_0x53fdda][0x0][_0x544654('0x24')]),_0x10ba52=_[_0x544654('0x9')](_0x10ba52,_0x4f9d8b[_0x544654('0x28')]);}}return _0x2947d8['transaction'](function(_0x2d6d77){const _0x19030f=_0x544654;return _0x2947d8['models'][_0x19030f('0x1b')][_0x19030f('0x3a')]({'where':{'VoiceExtensionId':{[Op['in']]:_0x4120e6}},'transaction':_0x2d6d77})[_0x19030f('0x38')](function(){const _0x434d72=_0x19030f;return _0x2947d8[_0x434d72('0x7')][_0x434d72('0x1b')][_0x434d72('0x2a')](_[_0x434d72('0x1e')](_0x10ba52,_0x434d72('0x34')),{'transaction':_0x2d6d77});});});})[_0x20c34b('0x21')](function(_0x45e71c){const _0x4c7a18=_0x20c34b;console[_0x4c7a18('0x3f')](_0x45e71c);});}exports[_0x483084('0x22')]=rewrite;