Built motion from commit 459747fdfe53bbf13fbede61eeaffea1f1438f86. Version 3.0.0...
[motion-next.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 77b0dca..485faaf 100644 (file)
@@ -1 +1 @@
-const a742_0x3d14=['type','keys','save_name','key','Content-Range','MusicOnHolds','mkdirSync','status','user','api','../../config/logger','Unable\x20to\x20retrieve\x20the\x20current\x20user','model','%s.%s','Sound','undefined','nolimit','fields','directory','merge','sendStatus','then','index','create','map','sequelize','destroy','count','root','get','params','intersection','join','update','path','limit','name','end','getSounds','catch','server/files/moh','format','converted_format','pick','autoAssociation','show','createdAt','include','unlinkSync','filter','VoiceMusicOnHold','addSound','body','attributes','extname','userProfileId','rawAttributes','mode','fieldName','sort','lodash','role','findAll','UserProfileSection','length','id2','order','UserProfileResource','basename','0777','findOne','json','symlinkSync','query','options','where','rows','offset','files','VIRTUAL','removeSound','filters','includeAll','like','transaction'];(function(_0x2dfd2f,_0x3d1411){const _0x445290=function(_0x5dd91c){while(--_0x5dd91c){_0x2dfd2f['push'](_0x2dfd2f['shift']());}};_0x445290(++_0x3d1411);}(a742_0x3d14,0x192));const a742_0x4452=function(_0x2dfd2f,_0x3d1411){_0x2dfd2f=_0x2dfd2f-0x0;let _0x445290=a742_0x3d14[_0x2dfd2f];return _0x445290;};const _0x1f7261=a742_0x4452;'use strict';const util=require('util'),path=require(_0x1f7261('0x39')),fs=require('fs'),_=require(_0x1f7261('0x53')),qs=require('../../components/parsers/qs'),logger=require(_0x1f7261('0x21'))(_0x1f7261('0x20')),config=require('../../config/environment'),db=require('../../mysqldb')['db'],{Op,ValidationError}=require('sequelize');function respondWithStatusCode(_0x5dd91c,_0x35c0e8){return _0x35c0e8=_0x35c0e8||0xcc,function(_0x2feac4){const _0x2d3e6a=a742_0x4452;if(_0x2feac4)return _0x5dd91c[_0x2d3e6a('0x2b')](_0x35c0e8);return _0x5dd91c['status'](_0x35c0e8)[_0x2d3e6a('0x3c')]();};}function respondWithResult(_0x4408e3,_0x5c1fc9){return _0x5c1fc9=_0x5c1fc9||0xc8,function(_0x1c22d2){const _0x5022af=a742_0x4452;if(_0x1c22d2)return _0x4408e3[_0x5022af('0x1e')](_0x5c1fc9)[_0x5022af('0x9')](_0x1c22d2);};}function respondWithFilteredResult(_0x3b7f7f,_0x482ae6){return function(_0xbc3c1d){const _0x56d1e0=a742_0x4452;if(_0xbc3c1d){const _0x641659=_0xbc3c1d[_0x56d1e0('0x32')],_0x266a2e=_0x482ae6[_0x56d1e0('0xf')];let _0x70e9f4=_0x482ae6[_0x56d1e0('0xf')]+_0x482ae6[_0x56d1e0('0x3a')],_0x5e82b3;return _0x70e9f4>=_0x641659?(_0x70e9f4=_0x641659,_0x5e82b3=0xc8):_0x5e82b3=0xce,_0x3b7f7f['status'](_0x5e82b3),_0x3b7f7f['set'](_0x56d1e0('0x1b'),_0x266a2e+'-'+_0x70e9f4+'/'+_0x641659)[_0x56d1e0('0x9')](_0xbc3c1d);}return null;};}function saveUpdates(_0x45bb21){return function(_0x50fb27){const _0x1ea9e7=a742_0x4452;if(_0x50fb27)return _0x50fb27['update'](_0x45bb21)[_0x1ea9e7('0x2c')](function(_0x20e169){return _0x20e169;});return null;};}function removeEntity(_0x24eb68){return function(_0x123b5a){const _0x27cc92=a742_0x4452;if(_0x123b5a)return _0x123b5a[_0x27cc92('0x31')]()[_0x27cc92('0x2c')](function(){const _0x11a0ef=_0x27cc92,_0x12f342=_0x123b5a[_0x11a0ef('0x34')]({'plain':!![]}),_0x1038df=_0x11a0ef('0x1c');return db[_0x11a0ef('0x5')]['destroy']({'where':{'type':_0x1038df,'resourceId':_0x12f342['id']}})['then'](function(){return _0x123b5a;});})[_0x27cc92('0x2c')](function(){const _0x3117da=_0x27cc92;_0x24eb68[_0x3117da('0x1e')](0xcc)[_0x3117da('0x3c')]();});};}function handleEntityNotFound(_0x414bd5){return function(_0x5b101f){const _0x5ceb78=a742_0x4452;return!_0x5b101f&&_0x414bd5[_0x5ceb78('0x2b')](0x194),_0x5b101f;};}function handleError(_0x2bcd4d,_0x302962){return _0x302962=_0x302962||0x1f4,function(_0x50ee78){const _0x1c082e=a742_0x4452;logger['error'](_0x50ee78['stack']),_0x50ee78['name']&&delete _0x50ee78['name'],_0x2bcd4d[_0x1c082e('0x1e')](_0x302962)['send'](_0x50ee78);};}exports[_0x1f7261('0x2d')]=function(_0x1e08c0,_0x19699b){const _0xe5cdb3=_0x1f7261;let _0x509cbc={};const _0x248a80={},_0x223547={'count':0x0,'rows':[]},_0x3ccb03=_[_0xe5cdb3('0x2f')](db[_0xe5cdb3('0x49')][_0xe5cdb3('0x4f')],function(_0x552079){const _0x44ac93=_0xe5cdb3;return{'name':_0x552079[_0x44ac93('0x51')],'type':_0x552079[_0x44ac93('0x17')][_0x44ac93('0x1a')]};});_0x248a80[_0xe5cdb3('0x23')]=_[_0xe5cdb3('0x2f')](_0x3ccb03,'name'),_0x248a80[_0xe5cdb3('0xb')]=_[_0xe5cdb3('0x18')](_0x1e08c0[_0xe5cdb3('0xb')]),_0x248a80[_0xe5cdb3('0x13')]=_[_0xe5cdb3('0x36')](_0x248a80[_0xe5cdb3('0x23')],_0x248a80['query']),_0x509cbc[_0xe5cdb3('0x4c')]=_[_0xe5cdb3('0x36')](_0x248a80['model'],qs[_0xe5cdb3('0x28')](_0x1e08c0['query']['fields'])),_0x509cbc[_0xe5cdb3('0x4c')]=_0x509cbc[_0xe5cdb3('0x4c')][_0xe5cdb3('0x2')]?_0x509cbc[_0xe5cdb3('0x4c')]:_0x248a80['model'];typeof _0x1e08c0[_0xe5cdb3('0xb')][_0xe5cdb3('0x27')]==='undefined'&&(_0x509cbc[_0xe5cdb3('0x3a')]=qs[_0xe5cdb3('0x3a')](_0x1e08c0[_0xe5cdb3('0xb')][_0xe5cdb3('0x3a')]),_0x509cbc[_0xe5cdb3('0xf')]=qs[_0xe5cdb3('0xf')](_0x1e08c0[_0xe5cdb3('0xb')][_0xe5cdb3('0xf')]));_0x509cbc[_0xe5cdb3('0x4')]=qs['sort'](_0x1e08c0[_0xe5cdb3('0xb')][_0xe5cdb3('0x52')]),_0x509cbc['where']=qs[_0xe5cdb3('0x13')](_[_0xe5cdb3('0x42')](_0x1e08c0[_0xe5cdb3('0xb')],_0x248a80[_0xe5cdb3('0x13')]),_0x3ccb03);_0x1e08c0[_0xe5cdb3('0xb')]['filter']&&(_0x509cbc[_0xe5cdb3('0xd')]=_[_0xe5cdb3('0x2a')](_0x509cbc['where'],{[Op['or']]:_[_0xe5cdb3('0x2f')](_0x3ccb03,function(_0x415a61){const _0xb14061=_0xe5cdb3;if(_0x415a61[_0xb14061('0x17')]!==_0xb14061('0x11')){const _0x236542={};return _0x236542[_0x415a61[_0xb14061('0x3b')]]={[Op[_0xb14061('0x15')]]:'%'+_0x1e08c0[_0xb14061('0xb')][_0xb14061('0x48')]+'%'},_0x236542;}})}));_0x509cbc=_[_0xe5cdb3('0x2a')]({},_0x509cbc,_0x1e08c0[_0xe5cdb3('0xc')]);const _0xd43400={'where':_0x509cbc[_0xe5cdb3('0xd')]};return db[_0xe5cdb3('0x49')][_0xe5cdb3('0x32')](_0xd43400)['then'](function(_0xad5257){const _0x41a655=_0xe5cdb3;return _0x223547['count']=_0xad5257,_0x1e08c0[_0x41a655('0xb')][_0x41a655('0x14')]&&(_0x509cbc[_0x41a655('0x46')]=[{'all':!![]}]),db['VoiceMusicOnHold'][_0x41a655('0x0')](_0x509cbc);})['then'](function(_0x1bb58b){const _0xa1d248=_0xe5cdb3;return _0x223547[_0xa1d248('0xe')]=_0x1bb58b,_0x223547;})[_0xe5cdb3('0x2c')](respondWithFilteredResult(_0x19699b,_0x509cbc))[_0xe5cdb3('0x3e')](handleError(_0x19699b,null));},exports[_0x1f7261('0x44')]=function(_0x5ed9bb,_0x2860c1){const _0x4b4014=_0x1f7261;let _0x488d90={'raw':![],'where':{'id':_0x5ed9bb[_0x4b4014('0x35')]['id']}};const _0xe5cb21={};return _0xe5cb21[_0x4b4014('0x23')]=_['keys'](db['VoiceMusicOnHold']['rawAttributes']),_0xe5cb21[_0x4b4014('0xb')]=_[_0x4b4014('0x18')](_0x5ed9bb[_0x4b4014('0xb')]),_0xe5cb21[_0x4b4014('0x13')]=_['intersection'](_0xe5cb21['model'],_0xe5cb21['query']),_0x488d90[_0x4b4014('0x4c')]=_[_0x4b4014('0x36')](_0xe5cb21[_0x4b4014('0x23')],qs['fields'](_0x5ed9bb[_0x4b4014('0xb')]['fields'])),_0x488d90[_0x4b4014('0x4c')]=_0x488d90[_0x4b4014('0x4c')][_0x4b4014('0x2')]?_0x488d90[_0x4b4014('0x4c')]:_0xe5cb21['model'],_0x5ed9bb[_0x4b4014('0xb')][_0x4b4014('0x14')]&&(_0x488d90[_0x4b4014('0x46')]=[{'all':!![]}]),_0x488d90=_[_0x4b4014('0x2a')]({},_0x488d90,_0x5ed9bb[_0x4b4014('0xc')]),db['VoiceMusicOnHold'][_0x4b4014('0x8')](_0x488d90)['then'](handleEntityNotFound(_0x2860c1,null))['then'](respondWithResult(_0x2860c1,null))[_0x4b4014('0x3e')](handleError(_0x2860c1,null));},exports[_0x1f7261('0x38')]=function(_0x444123,_0x506a49){const _0x4c61cd=_0x1f7261;return _0x444123[_0x4c61cd('0x4b')]['id']&&delete _0x444123[_0x4c61cd('0x4b')]['id'],db[_0x4c61cd('0x49')][_0x4c61cd('0x8')]({'where':{'id':_0x444123['params']['id']}})[_0x4c61cd('0x2c')](handleEntityNotFound(_0x506a49,null))['then'](saveUpdates(_0x444123['body'],null))[_0x4c61cd('0x2c')](respondWithResult(_0x506a49,null))[_0x4c61cd('0x3e')](handleError(_0x506a49,null));},exports[_0x1f7261('0x2e')]=function(_0x431ae5,_0x4b2c30){const _0x39f73b=_0x1f7261;return db[_0x39f73b('0x30')]['transaction'](function(_0x325269){const _0x1bb6b7=_0x39f73b;return _0x431ae5['body'][_0x1bb6b7('0x50')]===_0x1bb6b7('0x10')&&(_0x431ae5['body']['directory']=path[_0x1bb6b7('0x37')](config[_0x1bb6b7('0x33')],_0x1bb6b7('0x3f'),_0x431ae5[_0x1bb6b7('0x4b')][_0x1bb6b7('0x3b')])),db[_0x1bb6b7('0x49')][_0x1bb6b7('0x2e')](_0x431ae5[_0x1bb6b7('0x4b')],{'transaction':_0x325269})[_0x1bb6b7('0x2c')](function(_0x2a65d3){const _0x4e3a61=_0x1bb6b7;_0x431ae5[_0x4e3a61('0x4b')][_0x4e3a61('0x50')]==='files'&&fs[_0x4e3a61('0x1d')](_0x2a65d3[_0x4e3a61('0x29')],parseInt(_0x4e3a61('0x7'),0x8));const _0x17befc=_0x431ae5['user']['get']({'plain':!![]});if(!_0x17befc)throw new Error(_0x4e3a61('0x22'));if(_0x17befc[_0x4e3a61('0x54')]===_0x4e3a61('0x1f')){const _0x287640=_0x2a65d3[_0x4e3a61('0x34')]({'plain':!![]});return db[_0x4e3a61('0x1')][_0x4e3a61('0x8')]({'where':{'name':'MusicOnHolds','userProfileId':_0x17befc[_0x4e3a61('0x4e')]},'raw':!![]})['then'](function(_0x2f1ac1){const _0x21eec4=_0x4e3a61;return _0x2f1ac1&&_0x2f1ac1[_0x21eec4('0x43')]===0x0?db['UserProfileResource'][_0x21eec4('0x2e')]({'name':_0x287640[_0x21eec4('0x3b')],'resourceId':_0x287640['id'],'type':_0x2f1ac1[_0x21eec4('0x3b')],'sectionId':_0x2f1ac1['id']},{})['then'](function(){return _0x2a65d3;}):_0x2a65d3;})[_0x4e3a61('0x3e')](function(_0x38f1e0){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x38f1e0);});}return _0x2a65d3;});})[_0x39f73b('0x2c')](respondWithResult(_0x4b2c30,0xc9))['catch'](handleError(_0x4b2c30,null));},exports['destroy']=function(_0x27c604,_0x4003cc){const _0x2fa88c=_0x1f7261;return db['VoiceMusicOnHold'][_0x2fa88c('0x8')]({'where':{'id':_0x27c604[_0x2fa88c('0x35')]['id']}})['then'](function(_0x5b11cc){const _0x9a0755=_0x2fa88c;if(_0x5b11cc)return db['sequelize'][_0x9a0755('0x16')](function(_0x5d593e){const _0x13c144=_0x9a0755;return _0x5b11cc['destroy']({'transaction':_0x5d593e,'raw':!![]})[_0x13c144('0x2c')](function(_0x5657a9){const _0x459ff2=_0x13c144;return _0x5657a9[_0x459ff2('0x29')]&&(fs['readdirSync'](_0x5657a9['directory'])['forEach'](function(_0x54a3dc){const _0x3aad7a=_0x459ff2;fs[_0x3aad7a('0x47')](path['join'](_0x5657a9[_0x3aad7a('0x29')],_0x54a3dc));}),fs['rmdirSync'](_0x5657a9['directory'])),_0x5657a9;});})['catch'](function(_0x550b05){throw new ValidationError(_0x550b05['message']);});})[_0x2fa88c('0x2c')](handleEntityNotFound(_0x4003cc,null))[_0x2fa88c('0x2c')](removeEntity(_0x4003cc,null))['catch'](handleError(_0x4003cc,null));},exports[_0x1f7261('0x4a')]=function(_0xa1351c,_0x5a1b31){const _0x4724ad=_0x1f7261;return db['sequelize'][_0x4724ad('0x16')](function(_0x2c012f){const _0x22ca25=_0x4724ad;let _0x281e3c;return db[_0x22ca25('0x49')][_0x22ca25('0x8')]({'where':{'id':_0xa1351c['params']['id']}})[_0x22ca25('0x2c')](function(_0x3e89a2){const _0x1f6456=_0x22ca25;if(_0x3e89a2)return _0x281e3c=_0x3e89a2,_0x3e89a2[_0x1f6456('0x4a')](_0xa1351c['body']['id'],{'transaction':_0x2c012f});})[_0x22ca25('0x2c')](function(_0x45fb64){const _0x1f971a=_0x22ca25;if(_0x45fb64)return db['Sound'][_0x1f971a('0x8')]({'where':{'id':_0xa1351c[_0x1f971a('0x4b')]['id']},'attributes':['id',_0x1f971a('0x3b'),'save_name',_0x1f971a('0x41'),_0x1f971a('0x45')],'raw':!![]});})['then'](function(_0xda0e8b){const _0x4d6065=_0x22ca25;if(_0xda0e8b){const _0xbaa12f=path[_0x4d6065('0x37')](config[_0x4d6065('0x33')],'server/files/sounds/converted',util['format']('%s.%s',path[_0x4d6065('0x6')](_0xda0e8b[_0x4d6065('0x19')],path[_0x4d6065('0x4d')](_0xda0e8b[_0x4d6065('0x19')])),_0xda0e8b[_0x4d6065('0x41')])),_0x4437ff=path[_0x4d6065('0x37')](config[_0x4d6065('0x33')],_0x4d6065('0x3f'),_0x281e3c[_0x4d6065('0x3b')],util['format'](_0x4d6065('0x24'),_0xda0e8b['name'],_0xda0e8b[_0x4d6065('0x41')]));return fs[_0x4d6065('0xa')](_0xbaa12f,_0x4437ff),_0xda0e8b;}})[_0x22ca25('0x3e')](function(_0x534bf2){throw new ValidationError(_0x534bf2['message']);});})[_0x4724ad('0x2c')](handleEntityNotFound(_0x5a1b31,null))['then'](respondWithResult(_0x5a1b31,0xc9))[_0x4724ad('0x3e')](handleError(_0x5a1b31,null));},exports[_0x1f7261('0x12')]=function(_0x44691b,_0x574c16){const _0x3b50c5=_0x1f7261;return db['sequelize'][_0x3b50c5('0x16')](function(){const _0x4c7593=_0x3b50c5;let _0x282155;return db[_0x4c7593('0x49')]['findOne']({'where':{'id':_0x44691b[_0x4c7593('0x35')]['id']}})[_0x4c7593('0x2c')](handleEntityNotFound(_0x574c16,null))['then'](function(_0x4f9115){const _0x11e1d5=_0x4c7593;if(_0x4f9115)return _0x282155=_0x4f9115,_0x4f9115['removeSound'](_0x44691b['params'][_0x11e1d5('0x3')]);})[_0x4c7593('0x2c')](function(_0x550704){const _0x3c2a55=_0x4c7593;if(_0x550704)return db[_0x3c2a55('0x25')][_0x3c2a55('0x8')]({'where':{'id':_0x44691b[_0x3c2a55('0x35')][_0x3c2a55('0x3')]},'attributes':['id',_0x3c2a55('0x3b'),'save_name','converted_format',_0x3c2a55('0x45')],'raw':!![]});})[_0x4c7593('0x2c')](function(_0x30aac5){const _0x4f654c=_0x4c7593;if(_0x30aac5)return fs[_0x4f654c('0x47')](path['join'](_0x282155[_0x4f654c('0x29')],util[_0x4f654c('0x40')]('%s.%s',_0x30aac5[_0x4f654c('0x3b')],_0x30aac5[_0x4f654c('0x41')]))),_0x30aac5;})['catch'](function(_0x3bd69d){throw new ValidationError(_0x3bd69d['message']);});})['then'](handleEntityNotFound(_0x574c16,null))['then'](respondWithStatusCode(_0x574c16,0xcc))[_0x3b50c5('0x3e')](handleError(_0x574c16,null));},exports[_0x1f7261('0x3d')]=function(_0x185628,_0x4c658f){const _0x2dfe3a=_0x1f7261;let _0x4905ba={};const _0x5068c2={};let _0x42fd62,_0x4b7136;return db[_0x2dfe3a('0x49')][_0x2dfe3a('0x8')]({'where':{'id':_0x185628[_0x2dfe3a('0x35')]['id']}})[_0x2dfe3a('0x2c')](handleEntityNotFound(_0x4c658f,null))[_0x2dfe3a('0x2c')](function(_0x23c39a){const _0x2776c9=_0x2dfe3a;if(_0x23c39a)return _0x42fd62=_0x23c39a,_0x5068c2[_0x2776c9('0x23')]=_[_0x2776c9('0x18')](db[_0x2776c9('0x25')][_0x2776c9('0x4f')]),_0x5068c2[_0x2776c9('0xb')]=_[_0x2776c9('0x18')](_0x185628['query']),_0x5068c2[_0x2776c9('0x13')]=_[_0x2776c9('0x36')](_0x5068c2['model'],_0x5068c2[_0x2776c9('0xb')]),_0x4905ba[_0x2776c9('0x4c')]=_[_0x2776c9('0x36')](_0x5068c2['model'],qs[_0x2776c9('0x28')](_0x185628[_0x2776c9('0xb')][_0x2776c9('0x28')])),_0x4905ba[_0x2776c9('0x4c')]=_0x4905ba['attributes'][_0x2776c9('0x2')]?_0x4905ba[_0x2776c9('0x4c')]:_0x5068c2['model'],_0x4905ba[_0x2776c9('0x4')]=qs[_0x2776c9('0x52')](_0x185628[_0x2776c9('0xb')][_0x2776c9('0x52')]),_0x4905ba[_0x2776c9('0xd')]=qs['filters'](_[_0x2776c9('0x42')](_0x185628['query'],_0x5068c2[_0x2776c9('0x13')])),_0x185628[_0x2776c9('0xb')][_0x2776c9('0x48')]&&(_0x4905ba[_0x2776c9('0xd')]=_[_0x2776c9('0x2a')](_0x4905ba['where'],{[Op['or']]:_['map'](_0x4905ba['attributes'],function(_0x4d76dd){const _0x5e74f2=_0x2776c9,_0x27a000={};return _0x27a000[_0x4d76dd]={[Op[_0x5e74f2('0x15')]]:'%'+_0x185628[_0x5e74f2('0xb')][_0x5e74f2('0x48')]+'%'},_0x27a000;})})),_0x4905ba=_[_0x2776c9('0x2a')]({},_0x4905ba,_0x185628[_0x2776c9('0xc')]),_0x42fd62[_0x2776c9('0x3d')](_0x4905ba);})[_0x2dfe3a('0x2c')](function(_0x331c1b){const _0x4185bd=_0x2dfe3a;if(_0x331c1b)return _0x4b7136=_0x331c1b[_0x4185bd('0x2')],typeof _0x185628['query']['nolimit']===_0x4185bd('0x26')&&(_0x4905ba[_0x4185bd('0x3a')]=qs[_0x4185bd('0x3a')](_0x185628[_0x4185bd('0xb')]['limit']),_0x4905ba[_0x4185bd('0xf')]=qs[_0x4185bd('0xf')](_0x185628[_0x4185bd('0xb')][_0x4185bd('0xf')])),_0x42fd62[_0x4185bd('0x3d')](_0x4905ba);})[_0x2dfe3a('0x2c')](function(_0x6e686e){if(_0x6e686e)return _0x6e686e?{'count':_0x4b7136,'rows':_0x6e686e}:null;})['then'](respondWithResult(_0x4c658f,null))[_0x2dfe3a('0x3e')](handleError(_0x4c658f,null));};
\ No newline at end of file
+const a742_0x151b=['../../components/parsers/qs','destroy','findOne','save_name','options','limit','join','getSounds','create','unlinkSync','mkdirSync','then','autoAssociation','MusicOnHolds','converted_format','directory','include','model','UserProfileSection','addSound','sendStatus','merge','keys','VoiceMusicOnHold','filters','nolimit','name','root','error','rawAttributes','like','length','stack','UserProfileResource','userProfileId','rmdirSync','path','rows','where','message','%s.%s','symlinkSync','lodash','id2','transaction','Sound','update','get','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Unable\x20to\x20retrieve\x20the\x20current\x20user','end','role','Content-Range','createdAt','util','user','key','server/files/moh','filter','json','mode','includeAll','fields','api','removeSound','catch','status','count','attributes','set','intersection','params','body','format','sequelize','offset','basename','undefined','sort','map','query'];(function(_0x22ce5d,_0x151b0a){const _0x3f468b=function(_0x4beb88){while(--_0x4beb88){_0x22ce5d['push'](_0x22ce5d['shift']());}};_0x3f468b(++_0x151b0a);}(a742_0x151b,0x1a6));const a742_0x3f46=function(_0x22ce5d,_0x151b0a){_0x22ce5d=_0x22ce5d-0x0;let _0x3f468b=a742_0x151b[_0x22ce5d];return _0x3f468b;};const _0x21cb13=a742_0x3f46;'use strict';const util=require(_0x21cb13('0x25')),path=require(_0x21cb13('0x13')),fs=require('fs'),_=require(_0x21cb13('0x19')),qs=require(_0x21cb13('0x40')),logger=require('../../config/logger')(_0x21cb13('0x2e')),config=require('../../config/environment'),db=require('../../mysqldb')['db'],{Op,ValidationError}=require(_0x21cb13('0x39'));function respondWithStatusCode(_0x4beb88,_0x5d9918){return _0x5d9918=_0x5d9918||0xcc,function(_0x2cbba4){const _0x208f96=a742_0x3f46;if(_0x2cbba4)return _0x4beb88[_0x208f96('0x3')](_0x5d9918);return _0x4beb88[_0x208f96('0x31')](_0x5d9918)[_0x208f96('0x21')]();};}function respondWithResult(_0x17c9f0,_0x249266){return _0x249266=_0x249266||0xc8,function(_0x4bea0d){const _0x2cd9cd=a742_0x3f46;if(_0x4bea0d)return _0x17c9f0[_0x2cd9cd('0x31')](_0x249266)[_0x2cd9cd('0x2a')](_0x4bea0d);};}function respondWithFilteredResult(_0x129f6c,_0x30ea1b){return function(_0x3477b4){const _0x176227=a742_0x3f46;if(_0x3477b4){const _0x1d4190=_0x3477b4[_0x176227('0x32')],_0x3ed40e=_0x30ea1b[_0x176227('0x3a')];let _0x5db0d8=_0x30ea1b[_0x176227('0x3a')]+_0x30ea1b['limit'],_0x5986e6;return _0x5db0d8>=_0x1d4190?(_0x5db0d8=_0x1d4190,_0x5986e6=0xc8):_0x5986e6=0xce,_0x129f6c['status'](_0x5986e6),_0x129f6c[_0x176227('0x34')](_0x176227('0x23'),_0x3ed40e+'-'+_0x5db0d8+'/'+_0x1d4190)[_0x176227('0x2a')](_0x3477b4);}return null;};}function saveUpdates(_0x3684bf){return function(_0x1d3284){const _0x531f7c=a742_0x3f46;if(_0x1d3284)return _0x1d3284['update'](_0x3684bf)[_0x531f7c('0x4b')](function(_0x4a957f){return _0x4a957f;});return null;};}function removeEntity(_0x1c08b7){return function(_0x3ac210){const _0x41a4f5=a742_0x3f46;if(_0x3ac210)return _0x3ac210[_0x41a4f5('0x41')]()[_0x41a4f5('0x4b')](function(){const _0x584c0d=_0x41a4f5,_0x3af300=_0x3ac210[_0x584c0d('0x1e')]({'plain':!![]}),_0x2db939=_0x584c0d('0x4d');return db['UserProfileResource'][_0x584c0d('0x41')]({'where':{'type':_0x2db939,'resourceId':_0x3af300['id']}})['then'](function(){return _0x3ac210;});})[_0x41a4f5('0x4b')](function(){const _0x275150=_0x41a4f5;_0x1c08b7[_0x275150('0x31')](0xcc)[_0x275150('0x21')]();});};}function handleEntityNotFound(_0x1488a2){return function(_0x324001){const _0xb9149e=a742_0x3f46;return!_0x324001&&_0x1488a2[_0xb9149e('0x3')](0x194),_0x324001;};}function handleError(_0x4eb731,_0x2af1ea){return _0x2af1ea=_0x2af1ea||0x1f4,function(_0x2742ac){const _0x1a7140=a742_0x3f46;logger['error'](_0x2742ac[_0x1a7140('0xf')]),_0x2742ac[_0x1a7140('0x9')]&&delete _0x2742ac[_0x1a7140('0x9')],_0x4eb731[_0x1a7140('0x31')](_0x2af1ea)['send'](_0x2742ac);};}exports['index']=function(_0x25d685,_0x3e7093){const _0x41fd27=_0x21cb13;let _0x36f77c={};const _0x49aa46={},_0x2ceb7a={'count':0x0,'rows':[]},_0x30d5b3=_[_0x41fd27('0x3e')](db['VoiceMusicOnHold'][_0x41fd27('0xc')],function(_0x2d5964){const _0x43f80a=_0x41fd27;return{'name':_0x2d5964['fieldName'],'type':_0x2d5964['type'][_0x43f80a('0x27')]};});_0x49aa46['model']=_[_0x41fd27('0x3e')](_0x30d5b3,_0x41fd27('0x9')),_0x49aa46['query']=_[_0x41fd27('0x5')](_0x25d685[_0x41fd27('0x3f')]),_0x49aa46[_0x41fd27('0x7')]=_[_0x41fd27('0x35')](_0x49aa46[_0x41fd27('0x0')],_0x49aa46[_0x41fd27('0x3f')]),_0x36f77c[_0x41fd27('0x33')]=_[_0x41fd27('0x35')](_0x49aa46[_0x41fd27('0x0')],qs['fields'](_0x25d685[_0x41fd27('0x3f')]['fields'])),_0x36f77c[_0x41fd27('0x33')]=_0x36f77c[_0x41fd27('0x33')][_0x41fd27('0xe')]?_0x36f77c[_0x41fd27('0x33')]:_0x49aa46[_0x41fd27('0x0')];typeof _0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x8')]===_0x41fd27('0x3c')&&(_0x36f77c['limit']=qs[_0x41fd27('0x45')](_0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x45')]),_0x36f77c['offset']=qs['offset'](_0x25d685[_0x41fd27('0x3f')]['offset']));_0x36f77c['order']=qs['sort'](_0x25d685['query'][_0x41fd27('0x3d')]),_0x36f77c[_0x41fd27('0x15')]=qs[_0x41fd27('0x7')](_['pick'](_0x25d685[_0x41fd27('0x3f')],_0x49aa46[_0x41fd27('0x7')]),_0x30d5b3);_0x25d685[_0x41fd27('0x3f')][_0x41fd27('0x29')]&&(_0x36f77c[_0x41fd27('0x15')]=_[_0x41fd27('0x4')](_0x36f77c[_0x41fd27('0x15')],{[Op['or']]:_[_0x41fd27('0x3e')](_0x30d5b3,function(_0x34cbfd){const _0x111b7f=_0x41fd27;if(_0x34cbfd['type']!=='VIRTUAL'){const _0x124a6d={};return _0x124a6d[_0x34cbfd[_0x111b7f('0x9')]]={[Op[_0x111b7f('0xd')]]:'%'+_0x25d685['query']['filter']+'%'},_0x124a6d;}})}));_0x36f77c=_[_0x41fd27('0x4')]({},_0x36f77c,_0x25d685[_0x41fd27('0x44')]);const _0x5d8ffd={'where':_0x36f77c[_0x41fd27('0x15')]};return db[_0x41fd27('0x6')]['count'](_0x5d8ffd)[_0x41fd27('0x4b')](function(_0x597230){const _0x44c843=_0x41fd27;return _0x2ceb7a[_0x44c843('0x32')]=_0x597230,_0x25d685[_0x44c843('0x3f')][_0x44c843('0x2c')]&&(_0x36f77c[_0x44c843('0x50')]=[{'all':!![]}]),db[_0x44c843('0x6')]['findAll'](_0x36f77c);})[_0x41fd27('0x4b')](function(_0x2cc5fc){const _0x9bf640=_0x41fd27;return _0x2ceb7a[_0x9bf640('0x14')]=_0x2cc5fc,_0x2ceb7a;})[_0x41fd27('0x4b')](respondWithFilteredResult(_0x3e7093,_0x36f77c))['catch'](handleError(_0x3e7093,null));},exports['show']=function(_0x1b9762,_0x4f5159){const _0x418007=_0x21cb13;let _0x14cc46={'raw':![],'where':{'id':_0x1b9762[_0x418007('0x36')]['id']}};const _0x2ee389={};return _0x2ee389[_0x418007('0x0')]=_['keys'](db[_0x418007('0x6')]['rawAttributes']),_0x2ee389['query']=_['keys'](_0x1b9762[_0x418007('0x3f')]),_0x2ee389[_0x418007('0x7')]=_[_0x418007('0x35')](_0x2ee389['model'],_0x2ee389['query']),_0x14cc46[_0x418007('0x33')]=_['intersection'](_0x2ee389['model'],qs[_0x418007('0x2d')](_0x1b9762[_0x418007('0x3f')][_0x418007('0x2d')])),_0x14cc46[_0x418007('0x33')]=_0x14cc46['attributes'][_0x418007('0xe')]?_0x14cc46['attributes']:_0x2ee389['model'],_0x1b9762['query'][_0x418007('0x2c')]&&(_0x14cc46[_0x418007('0x50')]=[{'all':!![]}]),_0x14cc46=_['merge']({},_0x14cc46,_0x1b9762[_0x418007('0x44')]),db[_0x418007('0x6')][_0x418007('0x42')](_0x14cc46)[_0x418007('0x4b')](handleEntityNotFound(_0x4f5159,null))['then'](respondWithResult(_0x4f5159,null))['catch'](handleError(_0x4f5159,null));},exports[_0x21cb13('0x1d')]=function(_0x193843,_0x1e20d0){const _0x242627=_0x21cb13;return _0x193843['body']['id']&&delete _0x193843[_0x242627('0x37')]['id'],db['VoiceMusicOnHold']['findOne']({'where':{'id':_0x193843[_0x242627('0x36')]['id']}})[_0x242627('0x4b')](handleEntityNotFound(_0x1e20d0,null))['then'](saveUpdates(_0x193843['body'],null))['then'](respondWithResult(_0x1e20d0,null))[_0x242627('0x30')](handleError(_0x1e20d0,null));},exports[_0x21cb13('0x48')]=function(_0x57dc37,_0x206a3c){const _0x380534=_0x21cb13;return db['sequelize'][_0x380534('0x1b')](function(_0x63a93e){const _0x48094b=_0x380534;return _0x57dc37[_0x48094b('0x37')]['mode']==='files'&&(_0x57dc37[_0x48094b('0x37')][_0x48094b('0x4f')]=path[_0x48094b('0x46')](config[_0x48094b('0xa')],_0x48094b('0x28'),_0x57dc37[_0x48094b('0x37')][_0x48094b('0x9')])),db['VoiceMusicOnHold'][_0x48094b('0x48')](_0x57dc37[_0x48094b('0x37')],{'transaction':_0x63a93e})[_0x48094b('0x4b')](function(_0x16c7f9){const _0x16a699=_0x48094b;_0x57dc37[_0x16a699('0x37')][_0x16a699('0x2b')]==='files'&&fs[_0x16a699('0x4a')](_0x16c7f9[_0x16a699('0x4f')],parseInt('0777',0x8));const _0x469d88=_0x57dc37[_0x16a699('0x26')][_0x16a699('0x1e')]({'plain':!![]});if(!_0x469d88)throw new Error(_0x16a699('0x20'));if(_0x469d88[_0x16a699('0x22')]===_0x16a699('0x26')){const _0x5c39c8=_0x16c7f9[_0x16a699('0x1e')]({'plain':!![]});return db[_0x16a699('0x1')]['findOne']({'where':{'name':_0x16a699('0x4d'),'userProfileId':_0x469d88[_0x16a699('0x11')]},'raw':!![]})['then'](function(_0x59ab01){const _0x299882=_0x16a699;return _0x59ab01&&_0x59ab01[_0x299882('0x4c')]===0x0?db[_0x299882('0x10')][_0x299882('0x48')]({'name':_0x5c39c8['name'],'resourceId':_0x5c39c8['id'],'type':_0x59ab01[_0x299882('0x9')],'sectionId':_0x59ab01['id']},{})[_0x299882('0x4b')](function(){return _0x16c7f9;}):_0x16c7f9;})[_0x16a699('0x30')](function(_0x21fd8e){const _0x2e50b2=_0x16a699;logger[_0x2e50b2('0xb')](_0x2e50b2('0x1f'),_0x21fd8e);});}return _0x16c7f9;});})[_0x380534('0x4b')](respondWithResult(_0x206a3c,0xc9))[_0x380534('0x30')](handleError(_0x206a3c,null));},exports[_0x21cb13('0x41')]=function(_0x39222c,_0x4681eb){const _0x50fba8=_0x21cb13;return db[_0x50fba8('0x6')][_0x50fba8('0x42')]({'where':{'id':_0x39222c[_0x50fba8('0x36')]['id']}})['then'](function(_0x4d8cf2){const _0x2c064b=_0x50fba8;if(_0x4d8cf2)return db[_0x2c064b('0x39')][_0x2c064b('0x1b')](function(_0x3c5922){const _0x5a2764=_0x2c064b;return _0x4d8cf2[_0x5a2764('0x41')]({'transaction':_0x3c5922,'raw':!![]})[_0x5a2764('0x4b')](function(_0x3060af){const _0x1ec8c9=_0x5a2764;return _0x3060af[_0x1ec8c9('0x4f')]&&(fs['readdirSync'](_0x3060af[_0x1ec8c9('0x4f')])['forEach'](function(_0x13d5ab){const _0x3bb30d=_0x1ec8c9;fs[_0x3bb30d('0x49')](path['join'](_0x3060af[_0x3bb30d('0x4f')],_0x13d5ab));}),fs[_0x1ec8c9('0x12')](_0x3060af[_0x1ec8c9('0x4f')])),_0x3060af;});})[_0x2c064b('0x30')](function(_0xfeb197){const _0xae6a9a=_0x2c064b;throw new ValidationError(_0xfeb197[_0xae6a9a('0x16')]);});})[_0x50fba8('0x4b')](handleEntityNotFound(_0x4681eb,null))[_0x50fba8('0x4b')](removeEntity(_0x4681eb,null))[_0x50fba8('0x30')](handleError(_0x4681eb,null));},exports['addSound']=function(_0x28e80b,_0x1fabbf){const _0x418e0f=_0x21cb13;return db[_0x418e0f('0x39')][_0x418e0f('0x1b')](function(_0x73ff9e){const _0x5d9a79=_0x418e0f;let _0x1be6d7;return db[_0x5d9a79('0x6')][_0x5d9a79('0x42')]({'where':{'id':_0x28e80b[_0x5d9a79('0x36')]['id']}})[_0x5d9a79('0x4b')](function(_0x19fb81){const _0x49f686=_0x5d9a79;if(_0x19fb81)return _0x1be6d7=_0x19fb81,_0x19fb81[_0x49f686('0x2')](_0x28e80b[_0x49f686('0x37')]['id'],{'transaction':_0x73ff9e});})['then'](function(_0x16471f){const _0x1d492a=_0x5d9a79;if(_0x16471f)return db['Sound'][_0x1d492a('0x42')]({'where':{'id':_0x28e80b[_0x1d492a('0x37')]['id']},'attributes':['id','name','save_name','converted_format',_0x1d492a('0x24')],'raw':!![]});})[_0x5d9a79('0x4b')](function(_0x26cbc2){const _0x34ecda=_0x5d9a79;if(_0x26cbc2){const _0x16823a=path[_0x34ecda('0x46')](config[_0x34ecda('0xa')],'server/files/sounds/converted',util['format']('%s.%s',path[_0x34ecda('0x3b')](_0x26cbc2[_0x34ecda('0x43')],path['extname'](_0x26cbc2[_0x34ecda('0x43')])),_0x26cbc2[_0x34ecda('0x4e')])),_0x14b603=path['join'](config[_0x34ecda('0xa')],_0x34ecda('0x28'),_0x1be6d7['name'],util[_0x34ecda('0x38')](_0x34ecda('0x17'),_0x26cbc2[_0x34ecda('0x9')],_0x26cbc2[_0x34ecda('0x4e')]));return fs[_0x34ecda('0x18')](_0x16823a,_0x14b603),_0x26cbc2;}})[_0x5d9a79('0x30')](function(_0x1ea02b){const _0x185a7a=_0x5d9a79;throw new ValidationError(_0x1ea02b[_0x185a7a('0x16')]);});})[_0x418e0f('0x4b')](handleEntityNotFound(_0x1fabbf,null))['then'](respondWithResult(_0x1fabbf,0xc9))['catch'](handleError(_0x1fabbf,null));},exports[_0x21cb13('0x2f')]=function(_0x43acd6,_0x28d361){const _0x561d78=_0x21cb13;return db[_0x561d78('0x39')][_0x561d78('0x1b')](function(){const _0x10ec49=_0x561d78;let _0x457920;return db[_0x10ec49('0x6')]['findOne']({'where':{'id':_0x43acd6['params']['id']}})[_0x10ec49('0x4b')](handleEntityNotFound(_0x28d361,null))[_0x10ec49('0x4b')](function(_0x151553){const _0x18bd99=_0x10ec49;if(_0x151553)return _0x457920=_0x151553,_0x151553[_0x18bd99('0x2f')](_0x43acd6['params'][_0x18bd99('0x1a')]);})[_0x10ec49('0x4b')](function(_0xcb62a3){const _0x5ab6e5=_0x10ec49;if(_0xcb62a3)return db[_0x5ab6e5('0x1c')][_0x5ab6e5('0x42')]({'where':{'id':_0x43acd6['params'][_0x5ab6e5('0x1a')]},'attributes':['id',_0x5ab6e5('0x9'),_0x5ab6e5('0x43'),'converted_format',_0x5ab6e5('0x24')],'raw':!![]});})[_0x10ec49('0x4b')](function(_0x8645c0){const _0x262a43=_0x10ec49;if(_0x8645c0)return fs[_0x262a43('0x49')](path[_0x262a43('0x46')](_0x457920[_0x262a43('0x4f')],util[_0x262a43('0x38')](_0x262a43('0x17'),_0x8645c0[_0x262a43('0x9')],_0x8645c0[_0x262a43('0x4e')]))),_0x8645c0;})[_0x10ec49('0x30')](function(_0x4eb561){const _0x4bb625=_0x10ec49;throw new ValidationError(_0x4eb561[_0x4bb625('0x16')]);});})['then'](handleEntityNotFound(_0x28d361,null))[_0x561d78('0x4b')](respondWithStatusCode(_0x28d361,0xcc))[_0x561d78('0x30')](handleError(_0x28d361,null));},exports[_0x21cb13('0x47')]=function(_0x20d693,_0x5c62d1){const _0x2bef27=_0x21cb13;let _0x36cffa={};const _0x141f15={};let _0xb48ec7,_0x2294ce;return db['VoiceMusicOnHold'][_0x2bef27('0x42')]({'where':{'id':_0x20d693[_0x2bef27('0x36')]['id']}})[_0x2bef27('0x4b')](handleEntityNotFound(_0x5c62d1,null))[_0x2bef27('0x4b')](function(_0x50f316){const _0x119698=_0x2bef27;if(_0x50f316)return _0xb48ec7=_0x50f316,_0x141f15[_0x119698('0x0')]=_[_0x119698('0x5')](db[_0x119698('0x1c')]['rawAttributes']),_0x141f15[_0x119698('0x3f')]=_['keys'](_0x20d693['query']),_0x141f15[_0x119698('0x7')]=_[_0x119698('0x35')](_0x141f15[_0x119698('0x0')],_0x141f15[_0x119698('0x3f')]),_0x36cffa[_0x119698('0x33')]=_[_0x119698('0x35')](_0x141f15[_0x119698('0x0')],qs['fields'](_0x20d693['query']['fields'])),_0x36cffa[_0x119698('0x33')]=_0x36cffa[_0x119698('0x33')][_0x119698('0xe')]?_0x36cffa[_0x119698('0x33')]:_0x141f15[_0x119698('0x0')],_0x36cffa['order']=qs[_0x119698('0x3d')](_0x20d693[_0x119698('0x3f')][_0x119698('0x3d')]),_0x36cffa[_0x119698('0x15')]=qs[_0x119698('0x7')](_['pick'](_0x20d693[_0x119698('0x3f')],_0x141f15[_0x119698('0x7')])),_0x20d693[_0x119698('0x3f')][_0x119698('0x29')]&&(_0x36cffa[_0x119698('0x15')]=_['merge'](_0x36cffa[_0x119698('0x15')],{[Op['or']]:_[_0x119698('0x3e')](_0x36cffa[_0x119698('0x33')],function(_0xf0379a){const _0x146a96=_0x119698,_0x362d97={};return _0x362d97[_0xf0379a]={[Op[_0x146a96('0xd')]]:'%'+_0x20d693['query'][_0x146a96('0x29')]+'%'},_0x362d97;})})),_0x36cffa=_[_0x119698('0x4')]({},_0x36cffa,_0x20d693['options']),_0xb48ec7[_0x119698('0x47')](_0x36cffa);})[_0x2bef27('0x4b')](function(_0x5b680f){const _0x422776=_0x2bef27;if(_0x5b680f)return _0x2294ce=_0x5b680f['length'],typeof _0x20d693[_0x422776('0x3f')][_0x422776('0x8')]===_0x422776('0x3c')&&(_0x36cffa[_0x422776('0x45')]=qs['limit'](_0x20d693[_0x422776('0x3f')]['limit']),_0x36cffa[_0x422776('0x3a')]=qs['offset'](_0x20d693[_0x422776('0x3f')]['offset'])),_0xb48ec7[_0x422776('0x47')](_0x36cffa);})[_0x2bef27('0x4b')](function(_0x5cd827){if(_0x5cd827)return _0x5cd827?{'count':_0x2294ce,'rows':_0x5cd827}:null;})[_0x2bef27('0x4b')](respondWithResult(_0x5c62d1,null))[_0x2bef27('0x30')](handleError(_0x5c62d1,null));};
\ No newline at end of file