Built motion from commit 06eb8eb0.|2.6.31
[motion2.git] / server / api / voiceExtension / voiceExtension.controller.js
index 8aa4263..36753e6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2ad0=['filters','intersection','attributes','fields','nolimit','order','sort','where','pick','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','keys','include','create','body','exten','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','update','context','description','cutdigits','mandatoryDisposition','alias','addApplications','sequelize','Transaction','ISOLATION_LEVELS','findOne','VoiceExtensionId','bulkCreate','cast(priority\x20as\x20unsigned)','finally','lodash','ioredis','../../config/logger','../../mysqldb','redis','localhost','socket.io-emitter','./voiceExtension.socket','sendStatus','status','offset','undefined','count','limit','set','Content-Range','json','destroy','get','InboundRoutes','inbound','OutboundRoutes','outbound','InternalRoutes','internal','filter','ignore','map','value','type','find','UserProfileResource','then','end','error','stack','name','send','index','VoiceExtension','rawAttributes','key','model','query'];(function(_0x161757,_0x2f29af){var _0x4a6adc=function(_0xdd7a56){while(--_0xdd7a56){_0x161757['push'](_0x161757['shift']());}};_0x4a6adc(++_0x2f29af);}(_0x2ad0,0x82));var _0x02ad=function(_0x4c6cf0,_0x826f70){_0x4c6cf0=_0x4c6cf0-0x0;var _0x108145=_0x2ad0[_0x4c6cf0];return _0x108145;};'use strict';var _=require(_0x02ad('0x0'));var Redis=require(_0x02ad('0x1'));var qs=require('../../components/parsers/qs');var logger=require(_0x02ad('0x2'))('api');var config=require('../../config/environment');var db=require(_0x02ad('0x3'))['db'];config[_0x02ad('0x4')]=_['defaults'](config[_0x02ad('0x4')],{'host':_0x02ad('0x5'),'port':0x18eb});var socket=require(_0x02ad('0x6'))(new Redis(config[_0x02ad('0x4')]));require(_0x02ad('0x7'))['register'](socket);function respondWithStatusCode(_0x299135,_0x3a3e17){_0x3a3e17=_0x3a3e17||0xcc;return function(_0xf46c2){if(_0xf46c2){return _0x299135[_0x02ad('0x8')](_0x3a3e17);}return _0x299135[_0x02ad('0x9')](_0x3a3e17)['end']();};}function respondWithResult(_0x131873,_0x25e4ea){_0x25e4ea=_0x25e4ea||0xc8;return function(_0x55f675){if(_0x55f675){return _0x131873[_0x02ad('0x9')](_0x25e4ea)['json'](_0x55f675);}};}function respondWithFilteredResult(_0x20c86b,_0x1aecbd){return function(_0x1d647b){if(_0x1d647b){var _0x2ecfb7=typeof _0x1aecbd[_0x02ad('0xa')]===_0x02ad('0xb')&&typeof _0x1aecbd['limit']===_0x02ad('0xb');var _0xa39277=_0x1d647b[_0x02ad('0xc')];var _0x381d4e=_0x2ecfb7?0x0:_0x1aecbd['offset'];var _0x3c2f15=_0x2ecfb7?_0x1d647b[_0x02ad('0xc')]:_0x1aecbd[_0x02ad('0xa')]+_0x1aecbd[_0x02ad('0xd')];var _0x5146ae;if(_0x3c2f15>=_0xa39277){_0x3c2f15=_0xa39277;_0x5146ae=0xc8;}else{_0x5146ae=0xce;}_0x20c86b[_0x02ad('0x9')](_0x5146ae);return _0x20c86b[_0x02ad('0xe')](_0x02ad('0xf'),_0x381d4e+'-'+_0x3c2f15+'/'+_0xa39277)[_0x02ad('0x10')](_0x1d647b);}return null;};}function removeEntity(_0xb7ac62){return function(_0x2e136d){if(_0x2e136d){return _0x2e136d[_0x02ad('0x11')]()['then'](function(){var _0x432725=_0x2e136d[_0x02ad('0x12')]({'plain':!![]});var _0x2692b6=[{'name':_0x02ad('0x13'),'value':_0x02ad('0x14'),'ignore':![]},{'name':_0x02ad('0x15'),'value':_0x02ad('0x16'),'ignore':![]},{'name':_0x02ad('0x17'),'value':_0x02ad('0x18'),'ignore':![]}];var _0x464d3a=_(_0x2692b6)[_0x02ad('0x19')](_0x02ad('0x1a'))[_0x02ad('0x1b')](_0x02ad('0x1c'))[_0x02ad('0x1c')]();if(_['includes'](_0x464d3a,_0x432725[_0x02ad('0x1d')])){return;}var _0x2b270c=_[_0x02ad('0x1e')](_0x2692b6,[_0x02ad('0x1c'),_0x432725[_0x02ad('0x1d')]])['name'];return db[_0x02ad('0x1f')][_0x02ad('0x11')]({'where':{'type':_0x2b270c,'resourceId':_0x432725['id']}})['then'](function(){return _0x2e136d;});})[_0x02ad('0x20')](function(){_0xb7ac62[_0x02ad('0x9')](0xcc)[_0x02ad('0x21')]();});}};}function handleEntityNotFound(_0x560e7b){return function(_0x53fb96){if(!_0x53fb96){_0x560e7b[_0x02ad('0x8')](0x194);}return _0x53fb96;};}function handleError(_0x528de9,_0xd0e22e){_0xd0e22e=_0xd0e22e||0x1f4;return function(_0x560e2a){logger[_0x02ad('0x22')](_0x560e2a[_0x02ad('0x23')]);if(_0x560e2a['name']){delete _0x560e2a[_0x02ad('0x24')];}_0x528de9[_0x02ad('0x9')](_0xd0e22e)[_0x02ad('0x25')](_0x560e2a);};}exports[_0x02ad('0x26')]=function(_0x6dd6c8,_0xe51753){var _0x31dfe3={},_0x6aed1b={},_0x1c4aea={'count':0x0,'rows':[]};var _0x4c4bd0=_[_0x02ad('0x1b')](db[_0x02ad('0x27')][_0x02ad('0x28')],function(_0x20a1f9){return{'name':_0x20a1f9['fieldName'],'type':_0x20a1f9['type'][_0x02ad('0x29')]};});_0x6aed1b[_0x02ad('0x2a')]=_[_0x02ad('0x1b')](_0x4c4bd0,_0x02ad('0x24'));_0x6aed1b[_0x02ad('0x2b')]=_['keys'](_0x6dd6c8[_0x02ad('0x2b')]);_0x6aed1b[_0x02ad('0x2c')]=_[_0x02ad('0x2d')](_0x6aed1b[_0x02ad('0x2a')],_0x6aed1b[_0x02ad('0x2b')]);_0x31dfe3[_0x02ad('0x2e')]=_[_0x02ad('0x2d')](_0x6aed1b['model'],qs[_0x02ad('0x2f')](_0x6dd6c8[_0x02ad('0x2b')][_0x02ad('0x2f')]));_0x31dfe3[_0x02ad('0x2e')]=_0x31dfe3[_0x02ad('0x2e')]['length']?_0x31dfe3['attributes']:_0x6aed1b[_0x02ad('0x2a')];if(!_0x6dd6c8[_0x02ad('0x2b')]['hasOwnProperty'](_0x02ad('0x30'))){_0x31dfe3[_0x02ad('0xd')]=qs[_0x02ad('0xd')](_0x6dd6c8[_0x02ad('0x2b')]['limit']);_0x31dfe3[_0x02ad('0xa')]=qs[_0x02ad('0xa')](_0x6dd6c8[_0x02ad('0x2b')]['offset']);}_0x31dfe3[_0x02ad('0x31')]=qs[_0x02ad('0x32')](_0x6dd6c8[_0x02ad('0x2b')][_0x02ad('0x32')]);_0x31dfe3[_0x02ad('0x33')]=qs[_0x02ad('0x2c')](_[_0x02ad('0x34')](_0x6dd6c8[_0x02ad('0x2b')],_0x6aed1b['filters']),_0x4c4bd0);if(_0x6dd6c8[_0x02ad('0x2b')]['filter']){_0x31dfe3[_0x02ad('0x33')]=_[_0x02ad('0x35')](_0x31dfe3[_0x02ad('0x33')],{'$or':_['map'](_0x4c4bd0,function(_0x5b136b){if(_0x5b136b[_0x02ad('0x1d')]!==_0x02ad('0x36')){var _0x5b40d0={};_0x5b40d0[_0x5b136b[_0x02ad('0x24')]]={'$like':'%'+_0x6dd6c8[_0x02ad('0x2b')][_0x02ad('0x19')]+'%'};return _0x5b40d0;}})});}_0x31dfe3=_[_0x02ad('0x35')]({},_0x31dfe3,_0x6dd6c8[_0x02ad('0x37')]);var _0x136a40={'where':_0x31dfe3[_0x02ad('0x33')]};return db[_0x02ad('0x27')][_0x02ad('0xc')](_0x136a40)['then'](function(_0xafd3c7){_0x1c4aea[_0x02ad('0xc')]=_0xafd3c7;if(_0x6dd6c8[_0x02ad('0x2b')][_0x02ad('0x38')]){_0x31dfe3['include']=[{'all':!![]}];}return db[_0x02ad('0x27')][_0x02ad('0x39')](_0x31dfe3);})[_0x02ad('0x20')](function(_0xbabb02){_0x1c4aea[_0x02ad('0x3a')]=_0xbabb02;return _0x1c4aea;})['then'](respondWithFilteredResult(_0xe51753,_0x31dfe3))[_0x02ad('0x3b')](handleError(_0xe51753,null));};exports[_0x02ad('0x3c')]=function(_0x1066d6,_0xfca9b5){var _0x2084b4={'raw':![],'where':{'id':_0x1066d6[_0x02ad('0x3d')]['id']}},_0x16b3eb={};_0x16b3eb[_0x02ad('0x2a')]=_['keys'](db['VoiceExtension'][_0x02ad('0x28')]);_0x16b3eb['query']=_[_0x02ad('0x3e')](_0x1066d6['query']);_0x16b3eb[_0x02ad('0x2c')]=_['intersection'](_0x16b3eb[_0x02ad('0x2a')],_0x16b3eb[_0x02ad('0x2b')]);_0x2084b4[_0x02ad('0x2e')]=_['intersection'](_0x16b3eb[_0x02ad('0x2a')],qs[_0x02ad('0x2f')](_0x1066d6[_0x02ad('0x2b')][_0x02ad('0x2f')]));_0x2084b4[_0x02ad('0x2e')]=_0x2084b4[_0x02ad('0x2e')]['length']?_0x2084b4['attributes']:_0x16b3eb[_0x02ad('0x2a')];if(_0x1066d6['query'][_0x02ad('0x38')]){_0x2084b4[_0x02ad('0x3f')]=[{'all':!![]}];}_0x2084b4=_[_0x02ad('0x35')]({},_0x2084b4,_0x1066d6['options']);return db[_0x02ad('0x27')][_0x02ad('0x1e')](_0x2084b4)['then'](handleEntityNotFound(_0xfca9b5,null))['then'](respondWithResult(_0xfca9b5,null))[_0x02ad('0x3b')](handleError(_0xfca9b5,null));};exports[_0x02ad('0x11')]=function(_0x4eb344,_0x37e019){return db[_0x02ad('0x27')][_0x02ad('0x1e')]({'where':{'id':_0x4eb344['params']['id']}})[_0x02ad('0x20')](handleEntityNotFound(_0x37e019,null))['then'](removeEntity(_0x37e019,null))[_0x02ad('0x3b')](handleError(_0x37e019,null));};exports[_0x02ad('0x40')]=function(_0x36b87e,_0x1b7206){if(_0x36b87e[_0x02ad('0x41')]['type']===_0x02ad('0x16')&&!_['startsWith'](_0x36b87e[_0x02ad('0x41')][_0x02ad('0x42')],'_')){_0x36b87e[_0x02ad('0x41')][_0x02ad('0x42')]='_'['concat'](_0x36b87e[_0x02ad('0x41')][_0x02ad('0x42')]);}return db[_0x02ad('0x27')][_0x02ad('0x40')](_0x36b87e['body'],{'raw':![]})['then'](function(_0xf13b4a){var _0x53a967=_0x36b87e[_0x02ad('0x43')]['get']({'plain':!![]});if(!_0x53a967)throw new Error(_0x02ad('0x44'));if(_0x53a967['role']===_0x02ad('0x43')){var _0x2598a1=_0xf13b4a[_0x02ad('0x12')]({'plain':!![]});var _0x2068ca=[{'name':_0x02ad('0x13'),'value':_0x02ad('0x14')},{'name':_0x02ad('0x15'),'value':'outbound'},{'name':_0x02ad('0x17'),'value':_0x02ad('0x18')}];var _0xe2522f=_[_0x02ad('0x1e')](_0x2068ca,['value',_0x2598a1[_0x02ad('0x1d')]])[_0x02ad('0x24')];return db[_0x02ad('0x45')]['find']({'where':{'name':_0xe2522f,'userProfileId':_0x53a967[_0x02ad('0x46')]},'raw':!![]})[_0x02ad('0x20')](function(_0x3a3cff){if(_0x3a3cff&&_0x3a3cff[_0x02ad('0x47')]===0x0){return db[_0x02ad('0x1f')][_0x02ad('0x40')]({'name':_0x2598a1[_0x02ad('0x24')],'resourceId':_0x2598a1['id'],'type':_0x3a3cff['name'],'sectionId':_0x3a3cff['id']},{})[_0x02ad('0x20')](function(){return _0xf13b4a;});}else{return _0xf13b4a;}})[_0x02ad('0x3b')](function(_0x74aea){logger[_0x02ad('0x22')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x74aea);throw _0x74aea;});}return _0xf13b4a;})[_0x02ad('0x20')](respondWithResult(_0x1b7206,0xc9))['catch'](handleError(_0x1b7206,null));};exports['update']=function(_0xb7af6b,_0x8f7f29){if(_0xb7af6b[_0x02ad('0x41')]['id']){delete _0xb7af6b[_0x02ad('0x41')]['id'];}return db['VoiceExtension']['find']({'where':{'id':_0xb7af6b[_0x02ad('0x3d')]['id']}})[_0x02ad('0x20')](handleEntityNotFound(_0x8f7f29,null))[_0x02ad('0x20')](function(_0x25660b){if(_0x25660b){return db[_0x02ad('0x27')][_0x02ad('0x48')](_[_0x02ad('0x34')](_0xb7af6b[_0x02ad('0x41')],[_0x02ad('0x42'),_0x02ad('0x49'),_0x02ad('0x4a'),'recordingFormat',_0x02ad('0x4b'),_0x02ad('0x4c'),_0x02ad('0x4d')]),{'where':{'context':_0x25660b['context'],'exten':_0x25660b['exten']},'individualHooks':!![]})[_0x02ad('0x20')](function(_0x1a9adc){return _0x1a9adc;});}return null;})[_0x02ad('0x20')](respondWithStatusCode(_0x8f7f29,null))[_0x02ad('0x3b')](handleError(_0x8f7f29,null));};exports[_0x02ad('0x4e')]=function(_0x1909db,_0x1fca1b){var _0x240ced=_0x1909db[_0x02ad('0x3d')]['id'];var _0x13af8c=_0x1909db['body'];var _0x50b109=0xc8;var _0x48c984=null;return db[_0x02ad('0x4f')]['transaction']({'isolationLevel':db[_0x02ad('0x4f')][_0x02ad('0x50')][_0x02ad('0x51')]['READ_COMMITTED']},function(_0x235576){return db[_0x02ad('0x27')][_0x02ad('0x52')]({'where':{'id':_0x240ced},'transaction':_0x235576})['then'](function(_0x6240d6){if(_0x6240d6){return db[_0x02ad('0x27')][_0x02ad('0x11')]({'where':{'VoiceExtensionId':_0x240ced},'transaction':_0x235576})[_0x02ad('0x20')](function(){var _0x5f580f=_['map'](_0x13af8c,function(_0xe17044){_0xe17044[_0x02ad('0x53')]=_0x240ced;_0xe17044['isApp']=!![];return _0xe17044;});return _0x6240d6['createRouting'](_0x5f580f);})[_0x02ad('0x20')](function(_0x38f812){return db[_0x02ad('0x27')][_0x02ad('0x54')](_0x38f812,{'transaction':_0x235576});});}else{_0x50b109=0x194;_0x48c984=[];}});})[_0x02ad('0x20')](function(){if(_0x50b109!==0x194){return db[_0x02ad('0x27')]['findAndCountAll']({'where':{'isApp':!![],'VoiceExtensionId':_0x240ced},'order':_0x02ad('0x55')})['then'](function(_0x38a017){_0x48c984=_0x38a017;});}})[_0x02ad('0x3b')](function(_0x485048){_0x50b109=0x1f4;logger[_0x02ad('0x22')](_0x485048[_0x02ad('0x23')]);if(_0x485048[_0x02ad('0x24')]){delete _0x485048[_0x02ad('0x24')];}_0x48c984=_0x485048;})[_0x02ad('0x56')](function(){if(_0x48c984===null){_0x1fca1b[_0x02ad('0x8')](_0x50b109);}else{if(_0x50b109===0x1f4){_0x1fca1b[_0x02ad('0x9')](_0x50b109)[_0x02ad('0x25')](_0x48c984);}else{_0x1fca1b['status'](_0x50b109)[_0x02ad('0x10')](_0x48c984);}}});};
\ No newline at end of file
+var _0xf511=['cutdigits','mandatoryDisposition','alias','context','sequelize','transaction','Transaction','ISOLATION_LEVELS','findOne','isApp','createRouting','bulkCreate','findAndCountAll','cast(priority\x20as\x20unsigned)','finally','ioredis','../../components/parsers/qs','api','../../mysqldb','localhost','socket.io-emitter','./voiceExtension.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','destroy','get','InboundRoutes','OutboundRoutes','outbound','filter','ignore','map','value','includes','type','find','name','UserProfileResource','then','error','stack','send','index','VoiceExtension','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','create','body','exten','concat','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','inbound','InternalRoutes','internal','UserProfileSection','userProfileId','update','pick','description','recordingFormat'];(function(_0x531c11,_0xebb84){var _0x258c49=function(_0x3e472b){while(--_0x3e472b){_0x531c11['push'](_0x531c11['shift']());}};_0x258c49(++_0xebb84);}(_0xf511,0x123));var _0x1f51=function(_0x585133,_0x2412a1){_0x585133=_0x585133-0x0;var _0x18254a=_0xf511[_0x585133];return _0x18254a;};'use strict';var _=require('lodash');var Redis=require(_0x1f51('0x0'));var qs=require(_0x1f51('0x1'));var logger=require('../../config/logger')(_0x1f51('0x2'));var config=require('../../config/environment');var db=require(_0x1f51('0x3'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0x1f51('0x4'),'port':0x18eb});var socket=require(_0x1f51('0x5'))(new Redis(config['redis']));require(_0x1f51('0x6'))[_0x1f51('0x7')](socket);function respondWithStatusCode(_0x103154,_0x445ad5){_0x445ad5=_0x445ad5||0xcc;return function(_0x58caaa){if(_0x58caaa){return _0x103154[_0x1f51('0x8')](_0x445ad5);}return _0x103154[_0x1f51('0x9')](_0x445ad5)[_0x1f51('0xa')]();};}function respondWithResult(_0x1e31d7,_0x4d81c6){_0x4d81c6=_0x4d81c6||0xc8;return function(_0x295175){if(_0x295175){return _0x1e31d7[_0x1f51('0x9')](_0x4d81c6)[_0x1f51('0xb')](_0x295175);}};}function respondWithFilteredResult(_0x27606b,_0xce593e){return function(_0x79dc33){if(_0x79dc33){var _0x316399=typeof _0xce593e[_0x1f51('0xc')]===_0x1f51('0xd')&&typeof _0xce593e[_0x1f51('0xe')]==='undefined';var _0x4debdc=_0x79dc33[_0x1f51('0xf')];var _0x1399b6=_0x316399?0x0:_0xce593e[_0x1f51('0xc')];var _0x4d9962=_0x316399?_0x79dc33[_0x1f51('0xf')]:_0xce593e[_0x1f51('0xc')]+_0xce593e[_0x1f51('0xe')];var _0x5ecf86;if(_0x4d9962>=_0x4debdc){_0x4d9962=_0x4debdc;_0x5ecf86=0xc8;}else{_0x5ecf86=0xce;}_0x27606b[_0x1f51('0x9')](_0x5ecf86);return _0x27606b[_0x1f51('0x10')]('Content-Range',_0x1399b6+'-'+_0x4d9962+'/'+_0x4debdc)[_0x1f51('0xb')](_0x79dc33);}return null;};}function removeEntity(_0x5243f2){return function(_0x304341){if(_0x304341){return _0x304341[_0x1f51('0x11')]()['then'](function(){var _0x557738=_0x304341[_0x1f51('0x12')]({'plain':!![]});var _0x4e9191=[{'name':_0x1f51('0x13'),'value':'inbound','ignore':![]},{'name':_0x1f51('0x14'),'value':_0x1f51('0x15'),'ignore':![]},{'name':'InternalRoutes','value':'internal','ignore':![]}];var _0x928a61=_(_0x4e9191)[_0x1f51('0x16')](_0x1f51('0x17'))[_0x1f51('0x18')]('value')[_0x1f51('0x19')]();if(_[_0x1f51('0x1a')](_0x928a61,_0x557738[_0x1f51('0x1b')])){return;}var _0x28f329=_[_0x1f51('0x1c')](_0x4e9191,[_0x1f51('0x19'),_0x557738['type']])[_0x1f51('0x1d')];return db[_0x1f51('0x1e')][_0x1f51('0x11')]({'where':{'type':_0x28f329,'resourceId':_0x557738['id']}})[_0x1f51('0x1f')](function(){return _0x304341;});})['then'](function(){_0x5243f2[_0x1f51('0x9')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1c93f0){return function(_0x4c2979){if(!_0x4c2979){_0x1c93f0[_0x1f51('0x8')](0x194);}return _0x4c2979;};}function handleError(_0x3afe03,_0x341c2e){_0x341c2e=_0x341c2e||0x1f4;return function(_0x1ad95b){logger[_0x1f51('0x20')](_0x1ad95b[_0x1f51('0x21')]);if(_0x1ad95b[_0x1f51('0x1d')]){delete _0x1ad95b[_0x1f51('0x1d')];}_0x3afe03[_0x1f51('0x9')](_0x341c2e)[_0x1f51('0x22')](_0x1ad95b);};}exports[_0x1f51('0x23')]=function(_0x3ba6b3,_0x7a4c6){var _0x4b3cd7={},_0xb94dc6={},_0x5739fb={'count':0x0,'rows':[]};var _0x78c4be=_[_0x1f51('0x18')](db[_0x1f51('0x24')][_0x1f51('0x25')],function(_0x230e1d){return{'name':_0x230e1d[_0x1f51('0x26')],'type':_0x230e1d[_0x1f51('0x1b')][_0x1f51('0x27')]};});_0xb94dc6[_0x1f51('0x28')]=_['map'](_0x78c4be,_0x1f51('0x1d'));_0xb94dc6[_0x1f51('0x29')]=_[_0x1f51('0x2a')](_0x3ba6b3[_0x1f51('0x29')]);_0xb94dc6[_0x1f51('0x2b')]=_[_0x1f51('0x2c')](_0xb94dc6['model'],_0xb94dc6[_0x1f51('0x29')]);_0x4b3cd7[_0x1f51('0x2d')]=_['intersection'](_0xb94dc6['model'],qs[_0x1f51('0x2e')](_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0x2e')]));_0x4b3cd7[_0x1f51('0x2d')]=_0x4b3cd7[_0x1f51('0x2d')][_0x1f51('0x2f')]?_0x4b3cd7[_0x1f51('0x2d')]:_0xb94dc6[_0x1f51('0x28')];if(!_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0x30')]('nolimit')){_0x4b3cd7[_0x1f51('0xe')]=qs[_0x1f51('0xe')](_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0xe')]);_0x4b3cd7[_0x1f51('0xc')]=qs[_0x1f51('0xc')](_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0xc')]);}_0x4b3cd7[_0x1f51('0x31')]=qs['sort'](_0x3ba6b3['query'][_0x1f51('0x32')]);_0x4b3cd7[_0x1f51('0x33')]=qs[_0x1f51('0x2b')](_['pick'](_0x3ba6b3['query'],_0xb94dc6[_0x1f51('0x2b')]),_0x78c4be);if(_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0x16')]){_0x4b3cd7[_0x1f51('0x33')]=_[_0x1f51('0x34')](_0x4b3cd7[_0x1f51('0x33')],{'$or':_[_0x1f51('0x18')](_0x78c4be,function(_0x4fbf73){if(_0x4fbf73['type']!==_0x1f51('0x35')){var _0x54c520={};_0x54c520[_0x4fbf73[_0x1f51('0x1d')]]={'$like':'%'+_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0x16')]+'%'};return _0x54c520;}})});}_0x4b3cd7=_['merge']({},_0x4b3cd7,_0x3ba6b3[_0x1f51('0x36')]);var _0x2c08af={'where':_0x4b3cd7[_0x1f51('0x33')]};return db[_0x1f51('0x24')][_0x1f51('0xf')](_0x2c08af)[_0x1f51('0x1f')](function(_0xddde10){_0x5739fb[_0x1f51('0xf')]=_0xddde10;if(_0x3ba6b3[_0x1f51('0x29')][_0x1f51('0x37')]){_0x4b3cd7[_0x1f51('0x38')]=[{'all':!![]}];}return db[_0x1f51('0x24')][_0x1f51('0x39')](_0x4b3cd7);})[_0x1f51('0x1f')](function(_0x2ac746){_0x5739fb['rows']=_0x2ac746;return _0x5739fb;})[_0x1f51('0x1f')](respondWithFilteredResult(_0x7a4c6,_0x4b3cd7))[_0x1f51('0x3a')](handleError(_0x7a4c6,null));};exports[_0x1f51('0x3b')]=function(_0xe43d17,_0x312ebb){var _0x5d3967={'raw':![],'where':{'id':_0xe43d17[_0x1f51('0x3c')]['id']}},_0x26b00c={};_0x26b00c[_0x1f51('0x28')]=_[_0x1f51('0x2a')](db[_0x1f51('0x24')]['rawAttributes']);_0x26b00c['query']=_['keys'](_0xe43d17[_0x1f51('0x29')]);_0x26b00c['filters']=_[_0x1f51('0x2c')](_0x26b00c[_0x1f51('0x28')],_0x26b00c[_0x1f51('0x29')]);_0x5d3967['attributes']=_[_0x1f51('0x2c')](_0x26b00c[_0x1f51('0x28')],qs[_0x1f51('0x2e')](_0xe43d17[_0x1f51('0x29')][_0x1f51('0x2e')]));_0x5d3967[_0x1f51('0x2d')]=_0x5d3967[_0x1f51('0x2d')][_0x1f51('0x2f')]?_0x5d3967[_0x1f51('0x2d')]:_0x26b00c[_0x1f51('0x28')];if(_0xe43d17[_0x1f51('0x29')]['includeAll']){_0x5d3967[_0x1f51('0x38')]=[{'all':!![]}];}_0x5d3967=_[_0x1f51('0x34')]({},_0x5d3967,_0xe43d17['options']);return db[_0x1f51('0x24')][_0x1f51('0x1c')](_0x5d3967)[_0x1f51('0x1f')](handleEntityNotFound(_0x312ebb,null))[_0x1f51('0x1f')](respondWithResult(_0x312ebb,null))['catch'](handleError(_0x312ebb,null));};exports['destroy']=function(_0x506195,_0x13e977){return db[_0x1f51('0x24')][_0x1f51('0x1c')]({'where':{'id':_0x506195[_0x1f51('0x3c')]['id']}})[_0x1f51('0x1f')](handleEntityNotFound(_0x13e977,null))[_0x1f51('0x1f')](removeEntity(_0x13e977,null))[_0x1f51('0x3a')](handleError(_0x13e977,null));};exports[_0x1f51('0x3d')]=function(_0x5d88fe,_0x4ac150){if(_0x5d88fe[_0x1f51('0x3e')][_0x1f51('0x1b')]==='outbound'&&!_['startsWith'](_0x5d88fe['body'][_0x1f51('0x3f')],'_')){_0x5d88fe[_0x1f51('0x3e')]['exten']='_'[_0x1f51('0x40')](_0x5d88fe['body'][_0x1f51('0x3f')]);}return db['VoiceExtension'][_0x1f51('0x3d')](_0x5d88fe['body'],{'raw':![]})[_0x1f51('0x1f')](function(_0x34786e){var _0x366997=_0x5d88fe[_0x1f51('0x41')][_0x1f51('0x12')]({'plain':!![]});if(!_0x366997)throw new Error(_0x1f51('0x42'));if(_0x366997[_0x1f51('0x43')]==='user'){var _0x4764b6=_0x34786e[_0x1f51('0x12')]({'plain':!![]});var _0x3fa348=[{'name':_0x1f51('0x13'),'value':_0x1f51('0x44')},{'name':_0x1f51('0x14'),'value':_0x1f51('0x15')},{'name':_0x1f51('0x45'),'value':_0x1f51('0x46')}];var _0x137f35=_['find'](_0x3fa348,[_0x1f51('0x19'),_0x4764b6[_0x1f51('0x1b')]])[_0x1f51('0x1d')];return db[_0x1f51('0x47')][_0x1f51('0x1c')]({'where':{'name':_0x137f35,'userProfileId':_0x366997[_0x1f51('0x48')]},'raw':!![]})[_0x1f51('0x1f')](function(_0x5a715e){if(_0x5a715e&&_0x5a715e['autoAssociation']===0x0){return db[_0x1f51('0x1e')][_0x1f51('0x3d')]({'name':_0x4764b6['name'],'resourceId':_0x4764b6['id'],'type':_0x5a715e[_0x1f51('0x1d')],'sectionId':_0x5a715e['id']},{})[_0x1f51('0x1f')](function(){return _0x34786e;});}else{return _0x34786e;}})[_0x1f51('0x3a')](function(_0x2c9190){logger[_0x1f51('0x20')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2c9190);throw _0x2c9190;});}return _0x34786e;})[_0x1f51('0x1f')](respondWithResult(_0x4ac150,0xc9))[_0x1f51('0x3a')](handleError(_0x4ac150,null));};exports['update']=function(_0x48739e,_0x366687){if(_0x48739e['body']['id']){delete _0x48739e[_0x1f51('0x3e')]['id'];}return db[_0x1f51('0x24')][_0x1f51('0x1c')]({'where':{'id':_0x48739e[_0x1f51('0x3c')]['id']}})[_0x1f51('0x1f')](handleEntityNotFound(_0x366687,null))['then'](function(_0x5ac21a){if(_0x5ac21a){return db['VoiceExtension'][_0x1f51('0x49')](_[_0x1f51('0x4a')](_0x48739e[_0x1f51('0x3e')],['exten','context',_0x1f51('0x4b'),_0x1f51('0x4c'),_0x1f51('0x4d'),_0x1f51('0x4e'),_0x1f51('0x4f')]),{'where':{'context':_0x5ac21a[_0x1f51('0x50')],'exten':_0x5ac21a['exten']},'individualHooks':!![]})[_0x1f51('0x1f')](function(_0x3fad50){return _0x3fad50;});}return null;})[_0x1f51('0x1f')](respondWithStatusCode(_0x366687,null))[_0x1f51('0x3a')](handleError(_0x366687,null));};exports['addApplications']=function(_0x6e3c76,_0x1a8dec){var _0x3ad23f=_0x6e3c76[_0x1f51('0x3c')]['id'];var _0x2e7430=_0x6e3c76[_0x1f51('0x3e')];var _0x5a4a6a=0xc8;var _0x54e3e9=null;return db[_0x1f51('0x51')][_0x1f51('0x52')]({'isolationLevel':db[_0x1f51('0x51')][_0x1f51('0x53')][_0x1f51('0x54')]['READ_COMMITTED']},function(_0x5b046f){return db[_0x1f51('0x24')][_0x1f51('0x55')]({'where':{'id':_0x3ad23f},'transaction':_0x5b046f})[_0x1f51('0x1f')](function(_0x49e4c1){if(_0x49e4c1){return db[_0x1f51('0x24')][_0x1f51('0x11')]({'where':{'VoiceExtensionId':_0x3ad23f},'transaction':_0x5b046f})['then'](function(){var _0x152f70=_[_0x1f51('0x18')](_0x2e7430,function(_0x107ee8){_0x107ee8['VoiceExtensionId']=_0x3ad23f;_0x107ee8[_0x1f51('0x56')]=!![];return _0x107ee8;});return _0x49e4c1[_0x1f51('0x57')](_0x152f70);})['then'](function(_0x5a3ff8){return db[_0x1f51('0x24')][_0x1f51('0x58')](_0x5a3ff8,{'transaction':_0x5b046f});});}else{_0x5a4a6a=0x194;_0x54e3e9=[];}});})[_0x1f51('0x1f')](function(){if(_0x5a4a6a!==0x194){return db[_0x1f51('0x24')][_0x1f51('0x59')]({'where':{'isApp':!![],'VoiceExtensionId':_0x3ad23f},'order':_0x1f51('0x5a')})['then'](function(_0x441a91){_0x54e3e9=_0x441a91;});}})[_0x1f51('0x3a')](function(_0x186299){_0x5a4a6a=0x1f4;logger[_0x1f51('0x20')](_0x186299['stack']);if(_0x186299[_0x1f51('0x1d')]){delete _0x186299[_0x1f51('0x1d')];}_0x54e3e9=_0x186299;})[_0x1f51('0x5b')](function(){if(_0x54e3e9===null){_0x1a8dec['sendStatus'](_0x5a4a6a);}else{if(_0x5a4a6a===0x1f4){_0x1a8dec['status'](_0x5a4a6a)[_0x1f51('0x22')](_0x54e3e9);}else{_0x1a8dec[_0x1f51('0x9')](_0x5a4a6a)[_0x1f51('0xb')](_0x54e3e9);}}});};
\ No newline at end of file