Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / voiceExtension / voiceExtension.controller.js
index efb23d6..057eb6e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa9e0=['util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','redis','defaults','localhost','./voiceExtension.socket','register','status','count','offset','limit','set','Content-Range','update','destroy','then','InboundRoutes','inbound','OutboundRoutes','outbound','internal','filter','map','value','includes','type','find','name','UserProfileResource','end','sendStatus','stack','send','index','VoiceExtension','rawAttributes','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','keys','body','startsWith','exten','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','pick','context','description','cutdigits','mandatoryDisposition','addApplications','sequelize','VoiceExtensionId','bulkCreate','findAndCountAll','cast(priority\x20as\x20unsigned)','catch','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache'];(function(_0x41f6b3,_0x3cf8fc){var _0x29f886=function(_0x4618b3){while(--_0x4618b3){_0x41f6b3['push'](_0x41f6b3['shift']());}};_0x29f886(++_0x3cf8fc);}(_0xa9e0,0x123));var _0x0a9e=function(_0x4cf98e,_0xba4b79){_0x4cf98e=_0x4cf98e-0x0;var _0x1623ac=_0xa9e0[_0x4cf98e];return _0x1623ac;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];config[_0x0a9e('0x15')]=_[_0x0a9e('0x16')](config[_0x0a9e('0x15')],{'host':_0x0a9e('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0a9e('0x15')]));require(_0x0a9e('0x18'))[_0x0a9e('0x19')](socket);function respondWithStatusCode(_0x281129,_0x44dcfd){_0x44dcfd=_0x44dcfd||0xcc;return function(_0x4d5611){if(_0x4d5611){return _0x281129['sendStatus'](_0x44dcfd);}return _0x281129[_0x0a9e('0x1a')](_0x44dcfd)['end']();};}function respondWithResult(_0x1985b6,_0x519dfd){_0x519dfd=_0x519dfd||0xc8;return function(_0x16033c){if(_0x16033c){return _0x1985b6[_0x0a9e('0x1a')](_0x519dfd)['json'](_0x16033c);}};}function respondWithFilteredResult(_0x225616,_0x5a0a06){return function(_0x459eb1){if(_0x459eb1){var _0x478723=_0x459eb1[_0x0a9e('0x1b')],_0x106033=_0x5a0a06[_0x0a9e('0x1c')],_0x205fd6=_0x5a0a06[_0x0a9e('0x1c')]+_0x5a0a06[_0x0a9e('0x1d')],_0x31b1ca;if(_0x205fd6>=_0x478723){_0x205fd6=_0x478723;_0x31b1ca=0xc8;}else{_0x31b1ca=0xce;}_0x225616[_0x0a9e('0x1a')](_0x31b1ca);return _0x225616[_0x0a9e('0x1e')](_0x0a9e('0x1f'),_0x106033+'-'+_0x205fd6+'/'+_0x478723)['json'](_0x459eb1);}return null;};}function patchUpdates(_0x2c3407){return function(_0x155cce){try{jsonpatch['apply'](_0x155cce,_0x2c3407,!![]);}catch(_0x20f109){return BPromise['reject'](_0x20f109);}return _0x155cce['save']();};}function saveUpdates(_0x3a02e1,_0x432e56){return function(_0x38e7c4){if(_0x38e7c4){return _0x38e7c4[_0x0a9e('0x20')](_0x3a02e1)['then'](function(_0xfb6e48){return _0xfb6e48;});}return null;};}function removeEntity(_0x2fb0e4,_0x3b45bc){return function(_0x4d00e6){if(_0x4d00e6){return _0x4d00e6[_0x0a9e('0x21')]()[_0x0a9e('0x22')](function(){var _0x16b1ca=_0x4d00e6['get']({'plain':!![]});var _0x59181e=[{'name':_0x0a9e('0x23'),'value':_0x0a9e('0x24'),'ignore':![]},{'name':_0x0a9e('0x25'),'value':_0x0a9e('0x26'),'ignore':![]},{'name':'InternalRoutes','value':_0x0a9e('0x27'),'ignore':![]}];var _0x479bc4=_(_0x59181e)[_0x0a9e('0x28')]('ignore')[_0x0a9e('0x29')](_0x0a9e('0x2a'))[_0x0a9e('0x2a')]();if(_[_0x0a9e('0x2b')](_0x479bc4,_0x16b1ca[_0x0a9e('0x2c')])){return;}var _0x1538a4=_[_0x0a9e('0x2d')](_0x59181e,[_0x0a9e('0x2a'),_0x16b1ca['type']])[_0x0a9e('0x2e')];return db[_0x0a9e('0x2f')][_0x0a9e('0x21')]({'where':{'type':_0x1538a4,'resourceId':_0x16b1ca['id']}})[_0x0a9e('0x22')](function(){return _0x4d00e6;});})['then'](function(){_0x2fb0e4[_0x0a9e('0x1a')](0xcc)[_0x0a9e('0x30')]();});}};}function handleEntityNotFound(_0x1843b2,_0x824a4f){return function(_0x58b06f){if(!_0x58b06f){_0x1843b2[_0x0a9e('0x31')](0x194);}return _0x58b06f;};}function handleError(_0x296f41,_0x2e8759){_0x2e8759=_0x2e8759||0x1f4;return function(_0x1dbde2){logger['error'](_0x1dbde2[_0x0a9e('0x32')]);if(_0x1dbde2['name']){delete _0x1dbde2[_0x0a9e('0x2e')];}_0x296f41[_0x0a9e('0x1a')](_0x2e8759)[_0x0a9e('0x33')](_0x1dbde2);};}exports[_0x0a9e('0x34')]=function(_0x25ce3a,_0x5180f1){var _0x66c1d2={},_0x46f0a5={},_0x40cb85={'count':0x0,'rows':[]};var _0x2da5c0=_[_0x0a9e('0x29')](db[_0x0a9e('0x35')][_0x0a9e('0x36')],function(_0x39e565){return{'name':_0x39e565['fieldName'],'type':_0x39e565[_0x0a9e('0x2c')]['key']};});_0x46f0a5[_0x0a9e('0x37')]=_[_0x0a9e('0x29')](_0x2da5c0,_0x0a9e('0x2e'));_0x46f0a5[_0x0a9e('0x38')]=_['keys'](_0x25ce3a[_0x0a9e('0x38')]);_0x46f0a5[_0x0a9e('0x39')]=_[_0x0a9e('0x3a')](_0x46f0a5[_0x0a9e('0x37')],_0x46f0a5['query']);_0x66c1d2['attributes']=_[_0x0a9e('0x3a')](_0x46f0a5['model'],qs[_0x0a9e('0x3b')](_0x25ce3a[_0x0a9e('0x38')][_0x0a9e('0x3b')]));_0x66c1d2[_0x0a9e('0x3c')]=_0x66c1d2['attributes'][_0x0a9e('0x3d')]?_0x66c1d2[_0x0a9e('0x3c')]:_0x46f0a5[_0x0a9e('0x37')];if(!_0x25ce3a['query'][_0x0a9e('0x3e')](_0x0a9e('0x3f'))){_0x66c1d2[_0x0a9e('0x1d')]=qs['limit'](_0x25ce3a['query'][_0x0a9e('0x1d')]);_0x66c1d2[_0x0a9e('0x1c')]=qs['offset'](_0x25ce3a[_0x0a9e('0x38')][_0x0a9e('0x1c')]);}_0x66c1d2[_0x0a9e('0x40')]=qs[_0x0a9e('0x41')](_0x25ce3a['query']['sort']);_0x66c1d2[_0x0a9e('0x42')]=qs[_0x0a9e('0x39')](_['pick'](_0x25ce3a[_0x0a9e('0x38')],_0x46f0a5[_0x0a9e('0x39')]),_0x2da5c0);if(_0x25ce3a[_0x0a9e('0x38')]['filter']){_0x66c1d2[_0x0a9e('0x42')]=_[_0x0a9e('0x43')](_0x66c1d2[_0x0a9e('0x42')],{'$or':_[_0x0a9e('0x29')](_0x2da5c0,function(_0x13cb1f){if(_0x13cb1f[_0x0a9e('0x2c')]!==_0x0a9e('0x44')){var _0x45a9b8={};_0x45a9b8[_0x13cb1f[_0x0a9e('0x2e')]]={'$like':'%'+_0x25ce3a[_0x0a9e('0x38')][_0x0a9e('0x28')]+'%'};return _0x45a9b8;}})});}_0x66c1d2=_[_0x0a9e('0x43')]({},_0x66c1d2,_0x25ce3a[_0x0a9e('0x45')]);var _0x11ca30={'where':_0x66c1d2[_0x0a9e('0x42')]};return db['VoiceExtension']['count'](_0x11ca30)[_0x0a9e('0x22')](function(_0xb3795a){_0x40cb85[_0x0a9e('0x1b')]=_0xb3795a;if(_0x25ce3a[_0x0a9e('0x38')][_0x0a9e('0x46')]){_0x66c1d2[_0x0a9e('0x47')]=[{'all':!![]}];}return db[_0x0a9e('0x35')][_0x0a9e('0x48')](_0x66c1d2);})[_0x0a9e('0x22')](function(_0x25c6e6){_0x40cb85[_0x0a9e('0x49')]=_0x25c6e6;return _0x40cb85;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x5180f1,_0x66c1d2))['catch'](handleError(_0x5180f1,null));};exports[_0x0a9e('0x4a')]=function(_0x138b8b,_0xdd268f){var _0xfbd5ad={'raw':![],'where':{'id':_0x138b8b[_0x0a9e('0x4b')]['id']}},_0x2e8caf={};_0x2e8caf[_0x0a9e('0x37')]=_[_0x0a9e('0x4c')](db['VoiceExtension'][_0x0a9e('0x36')]);_0x2e8caf['query']=_[_0x0a9e('0x4c')](_0x138b8b[_0x0a9e('0x38')]);_0x2e8caf[_0x0a9e('0x39')]=_['intersection'](_0x2e8caf[_0x0a9e('0x37')],_0x2e8caf[_0x0a9e('0x38')]);_0xfbd5ad[_0x0a9e('0x3c')]=_[_0x0a9e('0x3a')](_0x2e8caf[_0x0a9e('0x37')],qs[_0x0a9e('0x3b')](_0x138b8b[_0x0a9e('0x38')]['fields']));_0xfbd5ad[_0x0a9e('0x3c')]=_0xfbd5ad[_0x0a9e('0x3c')][_0x0a9e('0x3d')]?_0xfbd5ad[_0x0a9e('0x3c')]:_0x2e8caf[_0x0a9e('0x37')];if(_0x138b8b[_0x0a9e('0x38')][_0x0a9e('0x46')]){_0xfbd5ad[_0x0a9e('0x47')]=[{'all':!![]}];}_0xfbd5ad=_[_0x0a9e('0x43')]({},_0xfbd5ad,_0x138b8b['options']);return db[_0x0a9e('0x35')][_0x0a9e('0x2d')](_0xfbd5ad)['then'](handleEntityNotFound(_0xdd268f,null))['then'](respondWithResult(_0xdd268f,null))['catch'](handleError(_0xdd268f,null));};exports[_0x0a9e('0x21')]=function(_0x4317e3,_0x37edaa){return db[_0x0a9e('0x35')][_0x0a9e('0x2d')]({'where':{'id':_0x4317e3[_0x0a9e('0x4b')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x37edaa,null))[_0x0a9e('0x22')](removeEntity(_0x37edaa,null))['catch'](handleError(_0x37edaa,null));};exports['create']=function(_0x53975a,_0x39d77d){if(_0x53975a[_0x0a9e('0x4d')][_0x0a9e('0x2c')]==='outbound'&&!_[_0x0a9e('0x4e')](_0x53975a[_0x0a9e('0x4d')]['exten'],'_')){_0x53975a['body'][_0x0a9e('0x4f')]='_'['concat'](_0x53975a[_0x0a9e('0x4d')]['exten']);}return db[_0x0a9e('0x35')][_0x0a9e('0x50')](_0x53975a[_0x0a9e('0x4d')],{'raw':![]})['then'](function(_0x2f82da){var _0x1bf38a=_0x53975a['user']['get']({'plain':!![]});if(!_0x1bf38a)throw new Error(_0x0a9e('0x51'));if(_0x1bf38a[_0x0a9e('0x52')]==='user'){var _0x145931=_0x2f82da['get']({'plain':!![]});var _0x211ef9=[{'name':'InboundRoutes','value':_0x0a9e('0x24')},{'name':'OutboundRoutes','value':'outbound'},{'name':'InternalRoutes','value':_0x0a9e('0x27')}];var _0x47de4c=_[_0x0a9e('0x2d')](_0x211ef9,[_0x0a9e('0x2a'),_0x145931[_0x0a9e('0x2c')]])[_0x0a9e('0x2e')];return db[_0x0a9e('0x53')][_0x0a9e('0x2d')]({'where':{'name':_0x47de4c,'userProfileId':_0x1bf38a[_0x0a9e('0x54')]},'raw':!![]})[_0x0a9e('0x22')](function(_0x4e67ab){if(_0x4e67ab&&_0x4e67ab[_0x0a9e('0x55')]===0x0){return db[_0x0a9e('0x2f')][_0x0a9e('0x50')]({'name':_0x145931[_0x0a9e('0x2e')],'resourceId':_0x145931['id'],'type':_0x4e67ab[_0x0a9e('0x2e')],'sectionId':_0x4e67ab['id']},{})[_0x0a9e('0x22')](function(){return _0x2f82da;});}else{return _0x2f82da;}})['catch'](function(_0x956fbe){logger[_0x0a9e('0x56')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x956fbe);throw _0x956fbe;});}return _0x2f82da;})[_0x0a9e('0x22')](respondWithResult(_0x39d77d,0xc9))['catch'](handleError(_0x39d77d,null));};exports[_0x0a9e('0x20')]=function(_0x5ba1f9,_0x4b3c1a){if(_0x5ba1f9['body']['id']){delete _0x5ba1f9[_0x0a9e('0x4d')]['id'];}return db['VoiceExtension'][_0x0a9e('0x2d')]({'where':{'id':_0x5ba1f9[_0x0a9e('0x4b')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x4b3c1a,null))[_0x0a9e('0x22')](function(_0x1cca9f){if(_0x1cca9f){return db[_0x0a9e('0x35')]['update'](_[_0x0a9e('0x57')](_0x5ba1f9['body'],[_0x0a9e('0x4f'),_0x0a9e('0x58'),_0x0a9e('0x59'),'recordingFormat',_0x0a9e('0x5a'),_0x0a9e('0x5b')]),{'where':{'context':_0x1cca9f[_0x0a9e('0x58')],'exten':_0x1cca9f[_0x0a9e('0x4f')]},'individualHooks':!![]})['then'](function(_0x1d0dc8){return _0x1d0dc8;});}return null;})[_0x0a9e('0x22')](respondWithStatusCode(_0x4b3c1a,null))['catch'](handleError(_0x4b3c1a,null));};exports[_0x0a9e('0x5c')]=function(_0x17e88c,_0x88dcbf,_0x409b29){return db[_0x0a9e('0x35')]['findOne']({'where':{'id':_0x17e88c[_0x0a9e('0x4b')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x88dcbf,null))[_0x0a9e('0x22')](function(_0x47bb43){if(_0x47bb43){return db[_0x0a9e('0x5d')]['transaction'](function(_0x5211e3){return db[_0x0a9e('0x35')][_0x0a9e('0x21')]({'where':{'VoiceExtensionId':_0x17e88c[_0x0a9e('0x4b')]['id']},'transaction':_0x5211e3})[_0x0a9e('0x22')](function(_0x186f39){var _0xc8c264=_[_0x0a9e('0x29')](_0x17e88c[_0x0a9e('0x4d')],function(_0x2d7205){_0x2d7205[_0x0a9e('0x5e')]=_0x17e88c[_0x0a9e('0x4b')]['id'];return _0x2d7205;});return db[_0x0a9e('0x35')][_0x0a9e('0x5f')](_0xc8c264,{'transaction':_0x5211e3});});})[_0x0a9e('0x22')](function(){return db[_0x0a9e('0x35')][_0x0a9e('0x60')]({'where':{'isApp':!![],'VoiceExtensionId':_0x17e88c[_0x0a9e('0x4b')]['id']},'order':_0x0a9e('0x61')});});}})['then'](respondWithResult(_0x88dcbf,null))[_0x0a9e('0x62')](handleError(_0x88dcbf,null));};
\ No newline at end of file
+var _0xe8c9=['InternalRoutes','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','context','description','recordingFormat','cutdigits','mandatoryDisposition','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findOne','VoiceExtensionId','isApp','createRouting','bulkCreate','findAndCountAll','cast(priority\x20as\x20unsigned)','finally','send','lodash','ioredis','../../components/parsers/qs','api','../../config/environment','../../mysqldb','defaults','localhost','./voiceExtension.socket','register','status','offset','undefined','limit','count','set','Content-Range','json','get','InboundRoutes','OutboundRoutes','outbound','internal','ignore','map','value','includes','type','find','name','destroy','then','end','sendStatus','error','stack','fieldName','key','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','VoiceExtension','includeAll','include','findAll','rows','catch','rawAttributes','params','body','exten','concat','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','inbound'];(function(_0x3f3f06,_0x581e5b){var _0x140feb=function(_0x4cc383){while(--_0x4cc383){_0x3f3f06['push'](_0x3f3f06['shift']());}};_0x140feb(++_0x581e5b);}(_0xe8c9,0x134));var _0x9e8c=function(_0x50788d,_0x2049b8){_0x50788d=_0x50788d-0x0;var _0x21622f=_0xe8c9[_0x50788d];return _0x21622f;};'use strict';var _=require(_0x9e8c('0x0'));var Redis=require(_0x9e8c('0x1'));var qs=require(_0x9e8c('0x2'));var logger=require('../../config/logger')(_0x9e8c('0x3'));var config=require(_0x9e8c('0x4'));var db=require(_0x9e8c('0x5'))['db'];config['redis']=_[_0x9e8c('0x6')](config['redis'],{'host':_0x9e8c('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x9e8c('0x8'))[_0x9e8c('0x9')](socket);function respondWithStatusCode(_0x51ba70,_0x1c02d3){_0x1c02d3=_0x1c02d3||0xcc;return function(_0xb5dba3){if(_0xb5dba3){return _0x51ba70['sendStatus'](_0x1c02d3);}return _0x51ba70[_0x9e8c('0xa')](_0x1c02d3)['end']();};}function respondWithResult(_0x3ed875,_0x50c85e){_0x50c85e=_0x50c85e||0xc8;return function(_0x38ed96){if(_0x38ed96){return _0x3ed875[_0x9e8c('0xa')](_0x50c85e)['json'](_0x38ed96);}};}function respondWithFilteredResult(_0x66c0f1,_0x4aae85){return function(_0x16c5e9){if(_0x16c5e9){var _0x14cccd=typeof _0x4aae85[_0x9e8c('0xb')]===_0x9e8c('0xc')&&typeof _0x4aae85[_0x9e8c('0xd')]===_0x9e8c('0xc');var _0x53cc6e=_0x16c5e9['count'];var _0x2f97f4=_0x14cccd?0x0:_0x4aae85[_0x9e8c('0xb')];var _0x23ec63=_0x14cccd?_0x16c5e9[_0x9e8c('0xe')]:_0x4aae85[_0x9e8c('0xb')]+_0x4aae85['limit'];var _0x206558;if(_0x23ec63>=_0x53cc6e){_0x23ec63=_0x53cc6e;_0x206558=0xc8;}else{_0x206558=0xce;}_0x66c0f1['status'](_0x206558);return _0x66c0f1[_0x9e8c('0xf')](_0x9e8c('0x10'),_0x2f97f4+'-'+_0x23ec63+'/'+_0x53cc6e)[_0x9e8c('0x11')](_0x16c5e9);}return null;};}function removeEntity(_0x4c1d5c){return function(_0x39c52c){if(_0x39c52c){return _0x39c52c['destroy']()['then'](function(){var _0x27c218=_0x39c52c[_0x9e8c('0x12')]({'plain':!![]});var _0x4df19a=[{'name':_0x9e8c('0x13'),'value':'inbound','ignore':![]},{'name':_0x9e8c('0x14'),'value':_0x9e8c('0x15'),'ignore':![]},{'name':'InternalRoutes','value':_0x9e8c('0x16'),'ignore':![]}];var _0x3dd64c=_(_0x4df19a)['filter'](_0x9e8c('0x17'))[_0x9e8c('0x18')]('value')[_0x9e8c('0x19')]();if(_[_0x9e8c('0x1a')](_0x3dd64c,_0x27c218[_0x9e8c('0x1b')])){return;}var _0x1c3ff1=_[_0x9e8c('0x1c')](_0x4df19a,['value',_0x27c218[_0x9e8c('0x1b')]])[_0x9e8c('0x1d')];return db['UserProfileResource'][_0x9e8c('0x1e')]({'where':{'type':_0x1c3ff1,'resourceId':_0x27c218['id']}})[_0x9e8c('0x1f')](function(){return _0x39c52c;});})[_0x9e8c('0x1f')](function(){_0x4c1d5c['status'](0xcc)[_0x9e8c('0x20')]();});}};}function handleEntityNotFound(_0x39e0d0){return function(_0x498438){if(!_0x498438){_0x39e0d0[_0x9e8c('0x21')](0x194);}return _0x498438;};}function handleError(_0x4ffaf5,_0x3438d2){_0x3438d2=_0x3438d2||0x1f4;return function(_0x4b3cb5){logger[_0x9e8c('0x22')](_0x4b3cb5[_0x9e8c('0x23')]);if(_0x4b3cb5[_0x9e8c('0x1d')]){delete _0x4b3cb5[_0x9e8c('0x1d')];}_0x4ffaf5[_0x9e8c('0xa')](_0x3438d2)['send'](_0x4b3cb5);};}exports['index']=function(_0x5aa2f3,_0x5f492c){var _0x23738b={},_0x435b64={},_0x336014={'count':0x0,'rows':[]};var _0x20d9b5=_[_0x9e8c('0x18')](db['VoiceExtension']['rawAttributes'],function(_0xf62647){return{'name':_0xf62647[_0x9e8c('0x24')],'type':_0xf62647[_0x9e8c('0x1b')][_0x9e8c('0x25')]};});_0x435b64[_0x9e8c('0x26')]=_[_0x9e8c('0x18')](_0x20d9b5,_0x9e8c('0x1d'));_0x435b64['query']=_[_0x9e8c('0x27')](_0x5aa2f3[_0x9e8c('0x28')]);_0x435b64[_0x9e8c('0x29')]=_[_0x9e8c('0x2a')](_0x435b64[_0x9e8c('0x26')],_0x435b64[_0x9e8c('0x28')]);_0x23738b[_0x9e8c('0x2b')]=_[_0x9e8c('0x2a')](_0x435b64[_0x9e8c('0x26')],qs[_0x9e8c('0x2c')](_0x5aa2f3[_0x9e8c('0x28')]['fields']));_0x23738b[_0x9e8c('0x2b')]=_0x23738b[_0x9e8c('0x2b')]['length']?_0x23738b[_0x9e8c('0x2b')]:_0x435b64[_0x9e8c('0x26')];if(!_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0x2d')]('nolimit')){_0x23738b[_0x9e8c('0xd')]=qs[_0x9e8c('0xd')](_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0xd')]);_0x23738b[_0x9e8c('0xb')]=qs['offset'](_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0xb')]);}_0x23738b[_0x9e8c('0x2e')]=qs[_0x9e8c('0x2f')](_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0x2f')]);_0x23738b[_0x9e8c('0x30')]=qs[_0x9e8c('0x29')](_[_0x9e8c('0x31')](_0x5aa2f3[_0x9e8c('0x28')],_0x435b64[_0x9e8c('0x29')]),_0x20d9b5);if(_0x5aa2f3['query'][_0x9e8c('0x32')]){_0x23738b[_0x9e8c('0x30')]=_[_0x9e8c('0x33')](_0x23738b[_0x9e8c('0x30')],{'$or':_[_0x9e8c('0x18')](_0x20d9b5,function(_0x1a184a){if(_0x1a184a['type']!==_0x9e8c('0x34')){var _0x235bef={};_0x235bef[_0x1a184a[_0x9e8c('0x1d')]]={'$like':'%'+_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0x32')]+'%'};return _0x235bef;}})});}_0x23738b=_['merge']({},_0x23738b,_0x5aa2f3['options']);var _0x1f861c={'where':_0x23738b[_0x9e8c('0x30')]};return db[_0x9e8c('0x35')]['count'](_0x1f861c)[_0x9e8c('0x1f')](function(_0xed7ad7){_0x336014[_0x9e8c('0xe')]=_0xed7ad7;if(_0x5aa2f3[_0x9e8c('0x28')][_0x9e8c('0x36')]){_0x23738b[_0x9e8c('0x37')]=[{'all':!![]}];}return db[_0x9e8c('0x35')][_0x9e8c('0x38')](_0x23738b);})['then'](function(_0x56d217){_0x336014[_0x9e8c('0x39')]=_0x56d217;return _0x336014;})[_0x9e8c('0x1f')](respondWithFilteredResult(_0x5f492c,_0x23738b))[_0x9e8c('0x3a')](handleError(_0x5f492c,null));};exports['show']=function(_0x2bd076,_0x250381){var _0x5d2a21={'raw':![],'where':{'id':_0x2bd076['params']['id']}},_0x5af7db={};_0x5af7db[_0x9e8c('0x26')]=_[_0x9e8c('0x27')](db[_0x9e8c('0x35')][_0x9e8c('0x3b')]);_0x5af7db['query']=_['keys'](_0x2bd076['query']);_0x5af7db[_0x9e8c('0x29')]=_[_0x9e8c('0x2a')](_0x5af7db[_0x9e8c('0x26')],_0x5af7db[_0x9e8c('0x28')]);_0x5d2a21[_0x9e8c('0x2b')]=_[_0x9e8c('0x2a')](_0x5af7db[_0x9e8c('0x26')],qs[_0x9e8c('0x2c')](_0x2bd076[_0x9e8c('0x28')][_0x9e8c('0x2c')]));_0x5d2a21[_0x9e8c('0x2b')]=_0x5d2a21[_0x9e8c('0x2b')]['length']?_0x5d2a21[_0x9e8c('0x2b')]:_0x5af7db[_0x9e8c('0x26')];if(_0x2bd076[_0x9e8c('0x28')][_0x9e8c('0x36')]){_0x5d2a21['include']=[{'all':!![]}];}_0x5d2a21=_[_0x9e8c('0x33')]({},_0x5d2a21,_0x2bd076['options']);return db[_0x9e8c('0x35')][_0x9e8c('0x1c')](_0x5d2a21)['then'](handleEntityNotFound(_0x250381,null))[_0x9e8c('0x1f')](respondWithResult(_0x250381,null))['catch'](handleError(_0x250381,null));};exports[_0x9e8c('0x1e')]=function(_0x4845c8,_0x468c26){return db['VoiceExtension'][_0x9e8c('0x1c')]({'where':{'id':_0x4845c8[_0x9e8c('0x3c')]['id']}})[_0x9e8c('0x1f')](handleEntityNotFound(_0x468c26,null))[_0x9e8c('0x1f')](removeEntity(_0x468c26,null))[_0x9e8c('0x3a')](handleError(_0x468c26,null));};exports['create']=function(_0x5d12e5,_0x423e5e){if(_0x5d12e5[_0x9e8c('0x3d')]['type']==='outbound'&&!_['startsWith'](_0x5d12e5['body'][_0x9e8c('0x3e')],'_')){_0x5d12e5[_0x9e8c('0x3d')]['exten']='_'[_0x9e8c('0x3f')](_0x5d12e5[_0x9e8c('0x3d')][_0x9e8c('0x3e')]);}return db[_0x9e8c('0x35')][_0x9e8c('0x40')](_0x5d12e5[_0x9e8c('0x3d')],{'raw':![]})[_0x9e8c('0x1f')](function(_0x2f1cef){var _0x90639d=_0x5d12e5[_0x9e8c('0x41')][_0x9e8c('0x12')]({'plain':!![]});if(!_0x90639d)throw new Error(_0x9e8c('0x42'));if(_0x90639d['role']===_0x9e8c('0x41')){var _0x42bcac=_0x2f1cef[_0x9e8c('0x12')]({'plain':!![]});var _0x4992fe=[{'name':_0x9e8c('0x13'),'value':_0x9e8c('0x43')},{'name':_0x9e8c('0x14'),'value':_0x9e8c('0x15')},{'name':_0x9e8c('0x44'),'value':_0x9e8c('0x16')}];var _0x5deeac=_[_0x9e8c('0x1c')](_0x4992fe,[_0x9e8c('0x19'),_0x42bcac[_0x9e8c('0x1b')]])[_0x9e8c('0x1d')];return db['UserProfileSection'][_0x9e8c('0x1c')]({'where':{'name':_0x5deeac,'userProfileId':_0x90639d[_0x9e8c('0x45')]},'raw':!![]})[_0x9e8c('0x1f')](function(_0x283d66){if(_0x283d66&&_0x283d66[_0x9e8c('0x46')]===0x0){return db[_0x9e8c('0x47')][_0x9e8c('0x40')]({'name':_0x42bcac[_0x9e8c('0x1d')],'resourceId':_0x42bcac['id'],'type':_0x283d66['name'],'sectionId':_0x283d66['id']},{})[_0x9e8c('0x1f')](function(){return _0x2f1cef;});}else{return _0x2f1cef;}})['catch'](function(_0x5d739f){logger['error'](_0x9e8c('0x48'),_0x5d739f);throw _0x5d739f;});}return _0x2f1cef;})[_0x9e8c('0x1f')](respondWithResult(_0x423e5e,0xc9))[_0x9e8c('0x3a')](handleError(_0x423e5e,null));};exports['update']=function(_0x18fc64,_0x3f488f){if(_0x18fc64[_0x9e8c('0x3d')]['id']){delete _0x18fc64['body']['id'];}return db[_0x9e8c('0x35')][_0x9e8c('0x1c')]({'where':{'id':_0x18fc64[_0x9e8c('0x3c')]['id']}})[_0x9e8c('0x1f')](handleEntityNotFound(_0x3f488f,null))[_0x9e8c('0x1f')](function(_0x4f3ad1){if(_0x4f3ad1){return db[_0x9e8c('0x35')][_0x9e8c('0x49')](_[_0x9e8c('0x31')](_0x18fc64[_0x9e8c('0x3d')],[_0x9e8c('0x3e'),_0x9e8c('0x4a'),_0x9e8c('0x4b'),_0x9e8c('0x4c'),_0x9e8c('0x4d'),_0x9e8c('0x4e'),'alias']),{'where':{'context':_0x4f3ad1[_0x9e8c('0x4a')],'exten':_0x4f3ad1[_0x9e8c('0x3e')]},'individualHooks':!![]})[_0x9e8c('0x1f')](function(_0xca7eda){return _0xca7eda;});}return null;})[_0x9e8c('0x1f')](respondWithStatusCode(_0x3f488f,null))[_0x9e8c('0x3a')](handleError(_0x3f488f,null));};exports[_0x9e8c('0x4f')]=function(_0x4cbb6b,_0x209016){var _0x13d8d3=_0x4cbb6b[_0x9e8c('0x3c')]['id'];var _0x4e6ea9=_0x4cbb6b['body'];var _0x4faa85=0xc8;var _0x5b409b=null;return db[_0x9e8c('0x50')][_0x9e8c('0x51')]({'isolationLevel':db[_0x9e8c('0x50')][_0x9e8c('0x52')][_0x9e8c('0x53')][_0x9e8c('0x54')]},function(_0x6e34db){return db[_0x9e8c('0x35')][_0x9e8c('0x55')]({'where':{'id':_0x13d8d3},'transaction':_0x6e34db})['then'](function(_0x51dd5d){if(_0x51dd5d){return db[_0x9e8c('0x35')][_0x9e8c('0x1e')]({'where':{'VoiceExtensionId':_0x13d8d3},'transaction':_0x6e34db})[_0x9e8c('0x1f')](function(){var _0x4d3c02=_[_0x9e8c('0x18')](_0x4e6ea9,function(_0xc0dd67){_0xc0dd67[_0x9e8c('0x56')]=_0x13d8d3;_0xc0dd67[_0x9e8c('0x57')]=!![];return _0xc0dd67;});return _0x51dd5d[_0x9e8c('0x58')](_0x4d3c02);})[_0x9e8c('0x1f')](function(_0x2bd247){return db['VoiceExtension'][_0x9e8c('0x59')](_0x2bd247,{'transaction':_0x6e34db});});}else{_0x4faa85=0x194;_0x5b409b=[];}});})[_0x9e8c('0x1f')](function(){if(_0x4faa85!==0x194){return db[_0x9e8c('0x35')][_0x9e8c('0x5a')]({'where':{'isApp':!![],'VoiceExtensionId':_0x13d8d3},'order':_0x9e8c('0x5b')})['then'](function(_0x221b44){_0x5b409b=_0x221b44;});}})[_0x9e8c('0x3a')](function(_0x1e8b45){_0x4faa85=0x1f4;logger[_0x9e8c('0x22')](_0x1e8b45[_0x9e8c('0x23')]);if(_0x1e8b45[_0x9e8c('0x1d')]){delete _0x1e8b45[_0x9e8c('0x1d')];}_0x5b409b=_0x1e8b45;})[_0x9e8c('0x5c')](function(){if(_0x5b409b===null){_0x209016[_0x9e8c('0x21')](_0x4faa85);}else{if(_0x4faa85===0x1f4){_0x209016[_0x9e8c('0xa')](_0x4faa85)[_0x9e8c('0x5d')](_0x5b409b);}else{_0x209016[_0x9e8c('0xa')](_0x4faa85)['json'](_0x5b409b);}}});};
\ No newline at end of file