Built motion from commit f3da74b7.|2.5.36
[motion2.git] / server / api / voiceExtension / voiceExtension.controller.js
index ad44fe1..9b5b970 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x162a=['merge','VIRTUAL','options','include','rows','catch','params','includeAll','body','startsWith','exten','concat','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','InternalRoutes','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','recordingFormat','alias','context','transaction','VoiceExtensionId','isApp','createRouting','log','findAndCountAll','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./voiceExtension.socket','register','sendStatus','end','status','json','offset','undefined','count','limit','Content-Range','destroy','then','InboundRoutes','inbound','OutboundRoutes','outbound','internal','filter','ignore','value','includes','type','find','name','error','stack','send','index','map','VoiceExtension','rawAttributes','fieldName','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filters'];(function(_0x3d9ad1,_0x3f63a9){var _0x231f78=function(_0x4de0c3){while(--_0x4de0c3){_0x3d9ad1['push'](_0x3d9ad1['shift']());}};_0x231f78(++_0x3f63a9);}(_0x162a,0x180));var _0xa162=function(_0x46cd9f,_0x173d4c){_0x46cd9f=_0x46cd9f-0x0;var _0x528aba=_0x162a[_0x46cd9f];return _0x528aba;};'use strict';var _=require(_0xa162('0x0'));var Redis=require(_0xa162('0x1'));var qs=require(_0xa162('0x2'));var logger=require(_0xa162('0x3'))(_0xa162('0x4'));var config=require('../../config/environment');var db=require(_0xa162('0x5'))['db'];config[_0xa162('0x6')]=_[_0xa162('0x7')](config[_0xa162('0x6')],{'host':_0xa162('0x8'),'port':0x18eb});var socket=require(_0xa162('0x9'))(new Redis(config[_0xa162('0x6')]));require(_0xa162('0xa'))[_0xa162('0xb')](socket);function respondWithStatusCode(_0x51682a,_0x40b367){_0x40b367=_0x40b367||0xcc;return function(_0x458145){if(_0x458145){return _0x51682a[_0xa162('0xc')](_0x40b367);}return _0x51682a['status'](_0x40b367)[_0xa162('0xd')]();};}function respondWithResult(_0x57a2cc,_0x5329bd){_0x5329bd=_0x5329bd||0xc8;return function(_0x4eb736){if(_0x4eb736){return _0x57a2cc[_0xa162('0xe')](_0x5329bd)[_0xa162('0xf')](_0x4eb736);}};}function respondWithFilteredResult(_0x4faff4,_0x384f75){return function(_0x4c9c3f){if(_0x4c9c3f){var _0x2dc8ca=typeof _0x384f75[_0xa162('0x10')]===_0xa162('0x11')&&typeof _0x384f75['limit']===_0xa162('0x11');var _0x1331e3=_0x4c9c3f[_0xa162('0x12')];var _0x5856d1=_0x2dc8ca?0x0:_0x384f75[_0xa162('0x10')];var _0x17f31b=_0x2dc8ca?_0x4c9c3f[_0xa162('0x12')]:_0x384f75[_0xa162('0x10')]+_0x384f75[_0xa162('0x13')];var _0x251716;if(_0x17f31b>=_0x1331e3){_0x17f31b=_0x1331e3;_0x251716=0xc8;}else{_0x251716=0xce;}_0x4faff4[_0xa162('0xe')](_0x251716);return _0x4faff4['set'](_0xa162('0x14'),_0x5856d1+'-'+_0x17f31b+'/'+_0x1331e3)['json'](_0x4c9c3f);}return null;};}function removeEntity(_0x119341){return function(_0x3d645a){if(_0x3d645a){return _0x3d645a[_0xa162('0x15')]()[_0xa162('0x16')](function(){var _0x41ffd5=_0x3d645a['get']({'plain':!![]});var _0x5baf45=[{'name':_0xa162('0x17'),'value':_0xa162('0x18'),'ignore':![]},{'name':_0xa162('0x19'),'value':_0xa162('0x1a'),'ignore':![]},{'name':'InternalRoutes','value':_0xa162('0x1b'),'ignore':![]}];var _0x3c4c52=_(_0x5baf45)[_0xa162('0x1c')](_0xa162('0x1d'))['map'](_0xa162('0x1e'))['value']();if(_[_0xa162('0x1f')](_0x3c4c52,_0x41ffd5[_0xa162('0x20')])){return;}var _0x4ce6c3=_[_0xa162('0x21')](_0x5baf45,[_0xa162('0x1e'),_0x41ffd5['type']])[_0xa162('0x22')];return db['UserProfileResource'][_0xa162('0x15')]({'where':{'type':_0x4ce6c3,'resourceId':_0x41ffd5['id']}})[_0xa162('0x16')](function(){return _0x3d645a;});})[_0xa162('0x16')](function(){_0x119341[_0xa162('0xe')](0xcc)[_0xa162('0xd')]();});}};}function handleEntityNotFound(_0x39c92c){return function(_0x256109){if(!_0x256109){_0x39c92c[_0xa162('0xc')](0x194);}return _0x256109;};}function handleError(_0xf9f8d7,_0x3fe43e){_0x3fe43e=_0x3fe43e||0x1f4;return function(_0x4e820a){logger[_0xa162('0x23')](_0x4e820a[_0xa162('0x24')]);if(_0x4e820a[_0xa162('0x22')]){delete _0x4e820a[_0xa162('0x22')];}_0xf9f8d7[_0xa162('0xe')](_0x3fe43e)[_0xa162('0x25')](_0x4e820a);};}exports[_0xa162('0x26')]=function(_0x1d3e41,_0x263dce){var _0x49c968={},_0x566e50={},_0x3dd2ac={'count':0x0,'rows':[]};var _0x3ce1c6=_[_0xa162('0x27')](db[_0xa162('0x28')][_0xa162('0x29')],function(_0x1c5678){return{'name':_0x1c5678[_0xa162('0x2a')],'type':_0x1c5678[_0xa162('0x20')]['key']};});_0x566e50[_0xa162('0x2b')]=_[_0xa162('0x27')](_0x3ce1c6,_0xa162('0x22'));_0x566e50[_0xa162('0x2c')]=_[_0xa162('0x2d')](_0x1d3e41[_0xa162('0x2c')]);_0x566e50['filters']=_[_0xa162('0x2e')](_0x566e50['model'],_0x566e50['query']);_0x49c968[_0xa162('0x2f')]=_[_0xa162('0x2e')](_0x566e50[_0xa162('0x2b')],qs[_0xa162('0x30')](_0x1d3e41[_0xa162('0x2c')][_0xa162('0x30')]));_0x49c968['attributes']=_0x49c968[_0xa162('0x2f')][_0xa162('0x31')]?_0x49c968['attributes']:_0x566e50['model'];if(!_0x1d3e41[_0xa162('0x2c')]['hasOwnProperty'](_0xa162('0x32'))){_0x49c968[_0xa162('0x13')]=qs[_0xa162('0x13')](_0x1d3e41[_0xa162('0x2c')]['limit']);_0x49c968['offset']=qs[_0xa162('0x10')](_0x1d3e41[_0xa162('0x2c')][_0xa162('0x10')]);}_0x49c968[_0xa162('0x33')]=qs[_0xa162('0x34')](_0x1d3e41[_0xa162('0x2c')][_0xa162('0x34')]);_0x49c968[_0xa162('0x35')]=qs['filters'](_[_0xa162('0x36')](_0x1d3e41[_0xa162('0x2c')],_0x566e50[_0xa162('0x37')]),_0x3ce1c6);if(_0x1d3e41['query'][_0xa162('0x1c')]){_0x49c968[_0xa162('0x35')]=_[_0xa162('0x38')](_0x49c968[_0xa162('0x35')],{'$or':_[_0xa162('0x27')](_0x3ce1c6,function(_0xfbefb3){if(_0xfbefb3[_0xa162('0x20')]!==_0xa162('0x39')){var _0x49094f={};_0x49094f[_0xfbefb3[_0xa162('0x22')]]={'$like':'%'+_0x1d3e41[_0xa162('0x2c')][_0xa162('0x1c')]+'%'};return _0x49094f;}})});}_0x49c968=_[_0xa162('0x38')]({},_0x49c968,_0x1d3e41[_0xa162('0x3a')]);var _0x24c0d1={'where':_0x49c968[_0xa162('0x35')]};return db[_0xa162('0x28')]['count'](_0x24c0d1)['then'](function(_0x32c12b){_0x3dd2ac[_0xa162('0x12')]=_0x32c12b;if(_0x1d3e41[_0xa162('0x2c')]['includeAll']){_0x49c968[_0xa162('0x3b')]=[{'all':!![]}];}return db[_0xa162('0x28')]['findAll'](_0x49c968);})[_0xa162('0x16')](function(_0x263fbf){_0x3dd2ac[_0xa162('0x3c')]=_0x263fbf;return _0x3dd2ac;})[_0xa162('0x16')](respondWithFilteredResult(_0x263dce,_0x49c968))[_0xa162('0x3d')](handleError(_0x263dce,null));};exports['show']=function(_0x3835f4,_0x1a966f){var _0x2685c3={'raw':![],'where':{'id':_0x3835f4[_0xa162('0x3e')]['id']}},_0x183023={};_0x183023[_0xa162('0x2b')]=_[_0xa162('0x2d')](db[_0xa162('0x28')][_0xa162('0x29')]);_0x183023[_0xa162('0x2c')]=_[_0xa162('0x2d')](_0x3835f4[_0xa162('0x2c')]);_0x183023[_0xa162('0x37')]=_[_0xa162('0x2e')](_0x183023[_0xa162('0x2b')],_0x183023[_0xa162('0x2c')]);_0x2685c3[_0xa162('0x2f')]=_[_0xa162('0x2e')](_0x183023[_0xa162('0x2b')],qs[_0xa162('0x30')](_0x3835f4[_0xa162('0x2c')]['fields']));_0x2685c3[_0xa162('0x2f')]=_0x2685c3[_0xa162('0x2f')][_0xa162('0x31')]?_0x2685c3['attributes']:_0x183023['model'];if(_0x3835f4[_0xa162('0x2c')][_0xa162('0x3f')]){_0x2685c3[_0xa162('0x3b')]=[{'all':!![]}];}_0x2685c3=_['merge']({},_0x2685c3,_0x3835f4['options']);return db[_0xa162('0x28')][_0xa162('0x21')](_0x2685c3)[_0xa162('0x16')](handleEntityNotFound(_0x1a966f,null))['then'](respondWithResult(_0x1a966f,null))[_0xa162('0x3d')](handleError(_0x1a966f,null));};exports[_0xa162('0x15')]=function(_0x5b42cb,_0x47436d){return db[_0xa162('0x28')]['find']({'where':{'id':_0x5b42cb[_0xa162('0x3e')]['id']}})[_0xa162('0x16')](handleEntityNotFound(_0x47436d,null))[_0xa162('0x16')](removeEntity(_0x47436d,null))[_0xa162('0x3d')](handleError(_0x47436d,null));};exports['create']=function(_0x5afd98,_0x2ae35d){if(_0x5afd98[_0xa162('0x40')][_0xa162('0x20')]==='outbound'&&!_[_0xa162('0x41')](_0x5afd98[_0xa162('0x40')][_0xa162('0x42')],'_')){_0x5afd98[_0xa162('0x40')][_0xa162('0x42')]='_'[_0xa162('0x43')](_0x5afd98['body'][_0xa162('0x42')]);}return db[_0xa162('0x28')][_0xa162('0x44')](_0x5afd98[_0xa162('0x40')],{'raw':![]})[_0xa162('0x16')](function(_0x45d64d){var _0x18772d=_0x5afd98[_0xa162('0x45')][_0xa162('0x46')]({'plain':!![]});if(!_0x18772d)throw new Error(_0xa162('0x47'));if(_0x18772d[_0xa162('0x48')]===_0xa162('0x45')){var _0x2a4d6c=_0x45d64d[_0xa162('0x46')]({'plain':!![]});var _0x38f1cc=[{'name':_0xa162('0x17'),'value':'inbound'},{'name':'OutboundRoutes','value':_0xa162('0x1a')},{'name':_0xa162('0x49'),'value':_0xa162('0x1b')}];var _0x5e2945=_[_0xa162('0x21')](_0x38f1cc,['value',_0x2a4d6c[_0xa162('0x20')]])[_0xa162('0x22')];return db[_0xa162('0x4a')][_0xa162('0x21')]({'where':{'name':_0x5e2945,'userProfileId':_0x18772d['userProfileId']},'raw':!![]})[_0xa162('0x16')](function(_0x109f8b){if(_0x109f8b&&_0x109f8b[_0xa162('0x4b')]===0x0){return db[_0xa162('0x4c')]['create']({'name':_0x2a4d6c[_0xa162('0x22')],'resourceId':_0x2a4d6c['id'],'type':_0x109f8b[_0xa162('0x22')],'sectionId':_0x109f8b['id']},{})[_0xa162('0x16')](function(){return _0x45d64d;});}else{return _0x45d64d;}})['catch'](function(_0xd1b318){logger['error'](_0xa162('0x4d'),_0xd1b318);throw _0xd1b318;});}return _0x45d64d;})[_0xa162('0x16')](respondWithResult(_0x2ae35d,0xc9))['catch'](handleError(_0x2ae35d,null));};exports[_0xa162('0x4e')]=function(_0x1f60ef,_0x53728d){if(_0x1f60ef[_0xa162('0x40')]['id']){delete _0x1f60ef[_0xa162('0x40')]['id'];}return db['VoiceExtension'][_0xa162('0x21')]({'where':{'id':_0x1f60ef[_0xa162('0x3e')]['id']}})[_0xa162('0x16')](handleEntityNotFound(_0x53728d,null))['then'](function(_0x205ee3){if(_0x205ee3){return db[_0xa162('0x28')][_0xa162('0x4e')](_[_0xa162('0x36')](_0x1f60ef['body'],[_0xa162('0x42'),'context','description',_0xa162('0x4f'),'cutdigits','mandatoryDisposition',_0xa162('0x50')]),{'where':{'context':_0x205ee3[_0xa162('0x51')],'exten':_0x205ee3['exten']},'individualHooks':!![]})[_0xa162('0x16')](function(_0x115371){return _0x115371;});}return null;})[_0xa162('0x16')](respondWithStatusCode(_0x53728d,null))['catch'](handleError(_0x53728d,null));};exports['addApplications']=function(_0x218264,_0x2c7979){return db[_0xa162('0x28')]['findOne']({'where':{'id':_0x218264[_0xa162('0x3e')]['id']}})[_0xa162('0x16')](function(_0x1751c7){if(_0x1751c7){return db['sequelize'][_0xa162('0x52')](function(_0x2638f5){return db['VoiceExtension'][_0xa162('0x15')]({'where':{'VoiceExtensionId':_0x218264[_0xa162('0x3e')]['id']},'transaction':_0x2638f5})[_0xa162('0x16')](function(){var _0x27ea84=_['map'](_0x218264['body'],function(_0x11ebb1){_0x11ebb1[_0xa162('0x53')]=_0x218264['params']['id'];_0x11ebb1[_0xa162('0x54')]=!![];return _0x11ebb1;});return _0x1751c7[_0xa162('0x55')](_0x27ea84);})['then'](function(_0x42813c){console[_0xa162('0x56')]('LOG\x20~\x20.then\x20~\x20routing',_0x42813c);return db[_0xa162('0x28')]['bulkCreate'](_0x42813c,{'transaction':_0x2638f5});});})[_0xa162('0x16')](function(){return db['VoiceExtension'][_0xa162('0x57')]({'where':{'isApp':!![],'VoiceExtensionId':_0x218264[_0xa162('0x3e')]['id']},'order':'cast(priority\x20as\x20unsigned)'});});}})[_0xa162('0x16')](respondWithResult(_0x2c7979,null))['catch'](handleError(_0x2c7979,null));};
\ No newline at end of file
+var _0x0bb5=['type','find','UserProfileResource','then','error','name','send','VoiceExtension','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','where','options','includeAll','include','findAll','catch','show','merge','params','create','startsWith','body','exten','concat','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','inbound','internal','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','context','description','recordingFormat','cutdigits','alias','addApplications','findOne','sequelize','VoiceExtensionId','createRouting','LOG\x20~\x20.then\x20~\x20routing','bulkCreate','findAndCountAll','cast(priority\x20as\x20unsigned)','lodash','ioredis','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','end','json','offset','undefined','count','limit','status','Content-Range','destroy','get','InboundRoutes','OutboundRoutes','outbound','filter','ignore','map','value','includes'];(function(_0x4b369d,_0x265eb8){var _0x571a98=function(_0x56341a){while(--_0x56341a){_0x4b369d['push'](_0x4b369d['shift']());}};_0x571a98(++_0x265eb8);}(_0x0bb5,0x148));var _0x50bb=function(_0x379e09,_0x199026){_0x379e09=_0x379e09-0x0;var _0x32a654=_0x0bb5[_0x379e09];return _0x32a654;};'use strict';var _=require(_0x50bb('0x0'));var Redis=require(_0x50bb('0x1'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0x50bb('0x2'));var config=require(_0x50bb('0x3'));var db=require(_0x50bb('0x4'))['db'];config[_0x50bb('0x5')]=_[_0x50bb('0x6')](config[_0x50bb('0x5')],{'host':_0x50bb('0x7'),'port':0x18eb});var socket=require(_0x50bb('0x8'))(new Redis(config['redis']));require('./voiceExtension.socket')[_0x50bb('0x9')](socket);function respondWithStatusCode(_0x35de5d,_0x2e5463){_0x2e5463=_0x2e5463||0xcc;return function(_0x33ff54){if(_0x33ff54){return _0x35de5d['sendStatus'](_0x2e5463);}return _0x35de5d['status'](_0x2e5463)[_0x50bb('0xa')]();};}function respondWithResult(_0x1c2174,_0x3ae598){_0x3ae598=_0x3ae598||0xc8;return function(_0x239a89){if(_0x239a89){return _0x1c2174['status'](_0x3ae598)[_0x50bb('0xb')](_0x239a89);}};}function respondWithFilteredResult(_0x2edeeb,_0x184d06){return function(_0x41055d){if(_0x41055d){var _0x346422=typeof _0x184d06[_0x50bb('0xc')]===_0x50bb('0xd')&&typeof _0x184d06['limit']===_0x50bb('0xd');var _0x58837d=_0x41055d[_0x50bb('0xe')];var _0xd8ab27=_0x346422?0x0:_0x184d06[_0x50bb('0xc')];var _0x502250=_0x346422?_0x41055d[_0x50bb('0xe')]:_0x184d06[_0x50bb('0xc')]+_0x184d06[_0x50bb('0xf')];var _0x5244b0;if(_0x502250>=_0x58837d){_0x502250=_0x58837d;_0x5244b0=0xc8;}else{_0x5244b0=0xce;}_0x2edeeb[_0x50bb('0x10')](_0x5244b0);return _0x2edeeb['set'](_0x50bb('0x11'),_0xd8ab27+'-'+_0x502250+'/'+_0x58837d)[_0x50bb('0xb')](_0x41055d);}return null;};}function removeEntity(_0x253073){return function(_0x42ffab){if(_0x42ffab){return _0x42ffab[_0x50bb('0x12')]()['then'](function(){var _0x10a191=_0x42ffab[_0x50bb('0x13')]({'plain':!![]});var _0x4b1f5f=[{'name':_0x50bb('0x14'),'value':'inbound','ignore':![]},{'name':_0x50bb('0x15'),'value':_0x50bb('0x16'),'ignore':![]},{'name':'InternalRoutes','value':'internal','ignore':![]}];var _0x43465b=_(_0x4b1f5f)[_0x50bb('0x17')](_0x50bb('0x18'))[_0x50bb('0x19')]('value')[_0x50bb('0x1a')]();if(_[_0x50bb('0x1b')](_0x43465b,_0x10a191[_0x50bb('0x1c')])){return;}var _0x597e95=_[_0x50bb('0x1d')](_0x4b1f5f,[_0x50bb('0x1a'),_0x10a191[_0x50bb('0x1c')]])['name'];return db[_0x50bb('0x1e')]['destroy']({'where':{'type':_0x597e95,'resourceId':_0x10a191['id']}})[_0x50bb('0x1f')](function(){return _0x42ffab;});})[_0x50bb('0x1f')](function(){_0x253073[_0x50bb('0x10')](0xcc)[_0x50bb('0xa')]();});}};}function handleEntityNotFound(_0x846311){return function(_0x342078){if(!_0x342078){_0x846311['sendStatus'](0x194);}return _0x342078;};}function handleError(_0xad17ac,_0xee0af0){_0xee0af0=_0xee0af0||0x1f4;return function(_0x284a76){logger[_0x50bb('0x20')](_0x284a76['stack']);if(_0x284a76[_0x50bb('0x21')]){delete _0x284a76['name'];}_0xad17ac['status'](_0xee0af0)[_0x50bb('0x22')](_0x284a76);};}exports['index']=function(_0x5cfe4b,_0x41fd89){var _0x12ee2c={},_0x3004a3={},_0x1b74f9={'count':0x0,'rows':[]};var _0x17c158=_[_0x50bb('0x19')](db[_0x50bb('0x23')][_0x50bb('0x24')],function(_0x4f7514){return{'name':_0x4f7514[_0x50bb('0x25')],'type':_0x4f7514[_0x50bb('0x1c')][_0x50bb('0x26')]};});_0x3004a3[_0x50bb('0x27')]=_['map'](_0x17c158,_0x50bb('0x21'));_0x3004a3[_0x50bb('0x28')]=_[_0x50bb('0x29')](_0x5cfe4b[_0x50bb('0x28')]);_0x3004a3[_0x50bb('0x2a')]=_[_0x50bb('0x2b')](_0x3004a3[_0x50bb('0x27')],_0x3004a3[_0x50bb('0x28')]);_0x12ee2c[_0x50bb('0x2c')]=_[_0x50bb('0x2b')](_0x3004a3[_0x50bb('0x27')],qs[_0x50bb('0x2d')](_0x5cfe4b['query'][_0x50bb('0x2d')]));_0x12ee2c[_0x50bb('0x2c')]=_0x12ee2c[_0x50bb('0x2c')][_0x50bb('0x2e')]?_0x12ee2c[_0x50bb('0x2c')]:_0x3004a3[_0x50bb('0x27')];if(!_0x5cfe4b[_0x50bb('0x28')][_0x50bb('0x2f')](_0x50bb('0x30'))){_0x12ee2c[_0x50bb('0xf')]=qs[_0x50bb('0xf')](_0x5cfe4b['query'][_0x50bb('0xf')]);_0x12ee2c[_0x50bb('0xc')]=qs[_0x50bb('0xc')](_0x5cfe4b[_0x50bb('0x28')][_0x50bb('0xc')]);}_0x12ee2c[_0x50bb('0x31')]=qs['sort'](_0x5cfe4b['query'][_0x50bb('0x32')]);_0x12ee2c['where']=qs[_0x50bb('0x2a')](_[_0x50bb('0x33')](_0x5cfe4b[_0x50bb('0x28')],_0x3004a3[_0x50bb('0x2a')]),_0x17c158);if(_0x5cfe4b[_0x50bb('0x28')]['filter']){_0x12ee2c[_0x50bb('0x34')]=_['merge'](_0x12ee2c[_0x50bb('0x34')],{'$or':_[_0x50bb('0x19')](_0x17c158,function(_0x280e5a){if(_0x280e5a['type']!=='VIRTUAL'){var _0x1df163={};_0x1df163[_0x280e5a[_0x50bb('0x21')]]={'$like':'%'+_0x5cfe4b[_0x50bb('0x28')][_0x50bb('0x17')]+'%'};return _0x1df163;}})});}_0x12ee2c=_['merge']({},_0x12ee2c,_0x5cfe4b[_0x50bb('0x35')]);var _0x4b75dc={'where':_0x12ee2c['where']};return db[_0x50bb('0x23')]['count'](_0x4b75dc)[_0x50bb('0x1f')](function(_0x3d94b8){_0x1b74f9[_0x50bb('0xe')]=_0x3d94b8;if(_0x5cfe4b[_0x50bb('0x28')][_0x50bb('0x36')]){_0x12ee2c[_0x50bb('0x37')]=[{'all':!![]}];}return db[_0x50bb('0x23')][_0x50bb('0x38')](_0x12ee2c);})[_0x50bb('0x1f')](function(_0x718128){_0x1b74f9['rows']=_0x718128;return _0x1b74f9;})['then'](respondWithFilteredResult(_0x41fd89,_0x12ee2c))[_0x50bb('0x39')](handleError(_0x41fd89,null));};exports[_0x50bb('0x3a')]=function(_0x1cf062,_0x1d929d){var _0x5e8085={'raw':![],'where':{'id':_0x1cf062['params']['id']}},_0x41243a={};_0x41243a[_0x50bb('0x27')]=_[_0x50bb('0x29')](db[_0x50bb('0x23')][_0x50bb('0x24')]);_0x41243a[_0x50bb('0x28')]=_[_0x50bb('0x29')](_0x1cf062[_0x50bb('0x28')]);_0x41243a[_0x50bb('0x2a')]=_[_0x50bb('0x2b')](_0x41243a[_0x50bb('0x27')],_0x41243a[_0x50bb('0x28')]);_0x5e8085[_0x50bb('0x2c')]=_[_0x50bb('0x2b')](_0x41243a[_0x50bb('0x27')],qs[_0x50bb('0x2d')](_0x1cf062[_0x50bb('0x28')]['fields']));_0x5e8085[_0x50bb('0x2c')]=_0x5e8085['attributes'][_0x50bb('0x2e')]?_0x5e8085[_0x50bb('0x2c')]:_0x41243a[_0x50bb('0x27')];if(_0x1cf062[_0x50bb('0x28')][_0x50bb('0x36')]){_0x5e8085[_0x50bb('0x37')]=[{'all':!![]}];}_0x5e8085=_[_0x50bb('0x3b')]({},_0x5e8085,_0x1cf062[_0x50bb('0x35')]);return db[_0x50bb('0x23')][_0x50bb('0x1d')](_0x5e8085)[_0x50bb('0x1f')](handleEntityNotFound(_0x1d929d,null))[_0x50bb('0x1f')](respondWithResult(_0x1d929d,null))[_0x50bb('0x39')](handleError(_0x1d929d,null));};exports[_0x50bb('0x12')]=function(_0x5880df,_0x3eb429){return db['VoiceExtension'][_0x50bb('0x1d')]({'where':{'id':_0x5880df[_0x50bb('0x3c')]['id']}})[_0x50bb('0x1f')](handleEntityNotFound(_0x3eb429,null))[_0x50bb('0x1f')](removeEntity(_0x3eb429,null))[_0x50bb('0x39')](handleError(_0x3eb429,null));};exports[_0x50bb('0x3d')]=function(_0x133dd9,_0x358b3a){if(_0x133dd9['body'][_0x50bb('0x1c')]===_0x50bb('0x16')&&!_[_0x50bb('0x3e')](_0x133dd9[_0x50bb('0x3f')][_0x50bb('0x40')],'_')){_0x133dd9['body'][_0x50bb('0x40')]='_'[_0x50bb('0x41')](_0x133dd9[_0x50bb('0x3f')][_0x50bb('0x40')]);}return db[_0x50bb('0x23')]['create'](_0x133dd9['body'],{'raw':![]})[_0x50bb('0x1f')](function(_0x49ed8d){var _0x357d08=_0x133dd9['user'][_0x50bb('0x13')]({'plain':!![]});if(!_0x357d08)throw new Error(_0x50bb('0x42'));if(_0x357d08[_0x50bb('0x43')]==='user'){var _0x2ce0a9=_0x49ed8d[_0x50bb('0x13')]({'plain':!![]});var _0x588dfe=[{'name':_0x50bb('0x14'),'value':_0x50bb('0x44')},{'name':_0x50bb('0x15'),'value':_0x50bb('0x16')},{'name':'InternalRoutes','value':_0x50bb('0x45')}];var _0x46b51e=_[_0x50bb('0x1d')](_0x588dfe,[_0x50bb('0x1a'),_0x2ce0a9[_0x50bb('0x1c')]])['name'];return db[_0x50bb('0x46')]['find']({'where':{'name':_0x46b51e,'userProfileId':_0x357d08[_0x50bb('0x47')]},'raw':!![]})['then'](function(_0x52ea86){if(_0x52ea86&&_0x52ea86[_0x50bb('0x48')]===0x0){return db['UserProfileResource']['create']({'name':_0x2ce0a9[_0x50bb('0x21')],'resourceId':_0x2ce0a9['id'],'type':_0x52ea86[_0x50bb('0x21')],'sectionId':_0x52ea86['id']},{})[_0x50bb('0x1f')](function(){return _0x49ed8d;});}else{return _0x49ed8d;}})[_0x50bb('0x39')](function(_0x3ef5d8){logger[_0x50bb('0x20')](_0x50bb('0x49'),_0x3ef5d8);throw _0x3ef5d8;});}return _0x49ed8d;})[_0x50bb('0x1f')](respondWithResult(_0x358b3a,0xc9))['catch'](handleError(_0x358b3a,null));};exports['update']=function(_0x372a06,_0x345bb5){if(_0x372a06[_0x50bb('0x3f')]['id']){delete _0x372a06[_0x50bb('0x3f')]['id'];}return db[_0x50bb('0x23')][_0x50bb('0x1d')]({'where':{'id':_0x372a06[_0x50bb('0x3c')]['id']}})['then'](handleEntityNotFound(_0x345bb5,null))[_0x50bb('0x1f')](function(_0x31cfca){if(_0x31cfca){return db[_0x50bb('0x23')][_0x50bb('0x4a')](_[_0x50bb('0x33')](_0x372a06['body'],[_0x50bb('0x40'),_0x50bb('0x4b'),_0x50bb('0x4c'),_0x50bb('0x4d'),_0x50bb('0x4e'),'mandatoryDisposition',_0x50bb('0x4f')]),{'where':{'context':_0x31cfca['context'],'exten':_0x31cfca['exten']},'individualHooks':!![]})[_0x50bb('0x1f')](function(_0x3057f2){return _0x3057f2;});}return null;})[_0x50bb('0x1f')](respondWithStatusCode(_0x345bb5,null))[_0x50bb('0x39')](handleError(_0x345bb5,null));};exports[_0x50bb('0x50')]=function(_0x20e35a,_0x15aaf8){return db[_0x50bb('0x23')][_0x50bb('0x51')]({'where':{'id':_0x20e35a[_0x50bb('0x3c')]['id']}})[_0x50bb('0x1f')](function(_0x534ebc){if(_0x534ebc){return db[_0x50bb('0x52')]['transaction'](function(_0x44b19d){return db[_0x50bb('0x23')]['destroy']({'where':{'VoiceExtensionId':_0x20e35a[_0x50bb('0x3c')]['id']},'transaction':_0x44b19d})[_0x50bb('0x1f')](function(){var _0xafa1b7=_[_0x50bb('0x19')](_0x20e35a[_0x50bb('0x3f')],function(_0x26d188){_0x26d188[_0x50bb('0x53')]=_0x20e35a[_0x50bb('0x3c')]['id'];_0x26d188['isApp']=!![];return _0x26d188;});return _0x534ebc[_0x50bb('0x54')](_0xafa1b7);})[_0x50bb('0x1f')](function(_0x3b17c8){console['log'](_0x50bb('0x55'),_0x3b17c8);return db[_0x50bb('0x23')][_0x50bb('0x56')](_0x3b17c8,{'transaction':_0x44b19d});});})[_0x50bb('0x1f')](function(){return db[_0x50bb('0x23')][_0x50bb('0x57')]({'where':{'isApp':!![],'VoiceExtensionId':_0x20e35a['params']['id']},'order':_0x50bb('0x58')});});}})[_0x50bb('0x1f')](respondWithResult(_0x15aaf8,null))[_0x50bb('0x39')](handleError(_0x15aaf8,null));};
\ No newline at end of file