Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / sound / sound.controller.js
index 43c7b87..e953cec 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa9e0=['format','%s.%s','file','originalname','extname','filename','server/files/sounds/original','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','wav','unlinkSync','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','duration','converted_sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','get','UserProfileSection','autoAssociation','error','start','pick','description','delete','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','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','sendStatus','end','status','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','Sounds','UserProfileResource','stack','name','send','index','map','Sound','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','filters','filter','merge','where','VIRTUAL','count','include','findAll','rows','catch','show','params','includeAll','options','download','find','save_name','converted_format','existsSync','join','root','server/files/sounds/converted','Sequelize','Sound\x20not\x20found'];(function(_0xb0042f,_0x5a4655){var _0x38dc3b=function(_0x5d9f4f){while(--_0x5d9f4f){_0xb0042f['push'](_0xb0042f['shift']());}};_0x38dc3b(++_0x5a4655);}(_0xa9e0,0x123));var _0x0a9e=function(_0xf50820,_0x56f041){_0xf50820=_0xf50820-0x0;var _0x2a9b10=_0xa9e0[_0xf50820];return _0x2a9b10;};'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'];function respondWithStatusCode(_0xd5b662,_0x26d672){_0x26d672=_0x26d672||0xcc;return function(_0x32d742){if(_0x32d742){return _0xd5b662[_0x0a9e('0x15')](_0x26d672);}return _0xd5b662['status'](_0x26d672)[_0x0a9e('0x16')]();};}function respondWithResult(_0x239b12,_0x2b4227){_0x2b4227=_0x2b4227||0xc8;return function(_0x281129){if(_0x281129){return _0x239b12[_0x0a9e('0x17')](_0x2b4227)[_0x0a9e('0x18')](_0x281129);}};}function respondWithFilteredResult(_0x52a03d,_0x22dccb){return function(_0x5d0880){if(_0x5d0880){var _0x1985b6=_0x5d0880['count'],_0x519dfd=_0x22dccb[_0x0a9e('0x19')],_0x16033c=_0x22dccb['offset']+_0x22dccb[_0x0a9e('0x1a')],_0x12066b;if(_0x16033c>=_0x1985b6){_0x16033c=_0x1985b6;_0x12066b=0xc8;}else{_0x12066b=0xce;}_0x52a03d[_0x0a9e('0x17')](_0x12066b);return _0x52a03d[_0x0a9e('0x1b')](_0x0a9e('0x1c'),_0x519dfd+'-'+_0x16033c+'/'+_0x1985b6)[_0x0a9e('0x18')](_0x5d0880);}return null;};}function patchUpdates(_0x2eb11f){return function(_0x530eb7){try{jsonpatch[_0x0a9e('0x1d')](_0x530eb7,_0x2eb11f,!![]);}catch(_0x1314ae){return BPromise[_0x0a9e('0x1e')](_0x1314ae);}return _0x530eb7[_0x0a9e('0x1f')]();};}function saveUpdates(_0x105080,_0x4bb1e3){return function(_0x2c3407){if(_0x2c3407){return _0x2c3407[_0x0a9e('0x20')](_0x105080)['then'](function(_0x20f109){return _0x20f109;});}return null;};}function removeEntity(_0x5a09ef,_0x588269){return function(_0x3a02e1){if(_0x3a02e1){return _0x3a02e1[_0x0a9e('0x21')]()[_0x0a9e('0x22')](function(){var _0x30bae6=_0x3a02e1['get']({'plain':!![]});var _0xfb6e48=_0x0a9e('0x23');return db[_0x0a9e('0x24')][_0x0a9e('0x21')]({'where':{'type':_0xfb6e48,'resourceId':_0x30bae6['id']}})[_0x0a9e('0x22')](function(){return _0x3a02e1;});})[_0x0a9e('0x22')](function(){_0x5a09ef[_0x0a9e('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59181e,_0x197ec0){return function(_0x3a8e58){if(!_0x3a8e58){_0x59181e[_0x0a9e('0x15')](0x194);}return _0x3a8e58;};}function handleError(_0x33161b,_0x526cf3){_0x526cf3=_0x526cf3||0x1f4;return function(_0x384319){logger['error'](_0x384319[_0x0a9e('0x25')]);if(_0x384319['name']){delete _0x384319[_0x0a9e('0x26')];}_0x33161b[_0x0a9e('0x17')](_0x526cf3)[_0x0a9e('0x27')](_0x384319);};}exports[_0x0a9e('0x28')]=function(_0x140511,_0x1538a4){var _0x11c3b6={},_0x14de77={},_0x5a101a={'count':0x0,'rows':[]};var _0x3652a7=_[_0x0a9e('0x29')](db[_0x0a9e('0x2a')][_0x0a9e('0x2b')],function(_0x5c877d){return{'name':_0x5c877d[_0x0a9e('0x2c')],'type':_0x5c877d[_0x0a9e('0x2d')][_0x0a9e('0x2e')]};});_0x14de77[_0x0a9e('0x2f')]=_[_0x0a9e('0x29')](_0x3652a7,_0x0a9e('0x26'));_0x14de77[_0x0a9e('0x30')]=_[_0x0a9e('0x31')](_0x140511[_0x0a9e('0x30')]);_0x14de77['filters']=_[_0x0a9e('0x32')](_0x14de77['model'],_0x14de77[_0x0a9e('0x30')]);_0x11c3b6[_0x0a9e('0x33')]=_[_0x0a9e('0x32')](_0x14de77[_0x0a9e('0x2f')],qs[_0x0a9e('0x34')](_0x140511['query'][_0x0a9e('0x34')]));_0x11c3b6[_0x0a9e('0x33')]=_0x11c3b6[_0x0a9e('0x33')][_0x0a9e('0x35')]?_0x11c3b6[_0x0a9e('0x33')]:_0x14de77[_0x0a9e('0x2f')];if(!_0x140511[_0x0a9e('0x30')][_0x0a9e('0x36')]('nolimit')){_0x11c3b6[_0x0a9e('0x1a')]=qs['limit'](_0x140511[_0x0a9e('0x30')][_0x0a9e('0x1a')]);_0x11c3b6[_0x0a9e('0x19')]=qs[_0x0a9e('0x19')](_0x140511['query'][_0x0a9e('0x19')]);}_0x11c3b6[_0x0a9e('0x37')]=qs[_0x0a9e('0x38')](_0x140511[_0x0a9e('0x30')]['sort']);_0x11c3b6['where']=qs[_0x0a9e('0x39')](_['pick'](_0x140511[_0x0a9e('0x30')],_0x14de77[_0x0a9e('0x39')]),_0x3652a7);if(_0x140511[_0x0a9e('0x30')][_0x0a9e('0x3a')]){_0x11c3b6['where']=_[_0x0a9e('0x3b')](_0x11c3b6[_0x0a9e('0x3c')],{'$or':_[_0x0a9e('0x29')](_0x3652a7,function(_0x533942){if(_0x533942[_0x0a9e('0x2d')]!==_0x0a9e('0x3d')){var _0x289467={};_0x289467[_0x533942['name']]={'$like':'%'+_0x140511['query'][_0x0a9e('0x3a')]+'%'};return _0x289467;}})});}_0x11c3b6=_[_0x0a9e('0x3b')]({},_0x11c3b6,_0x140511['options']);var _0x2b814e={'where':_0x11c3b6[_0x0a9e('0x3c')]};return db[_0x0a9e('0x2a')][_0x0a9e('0x3e')](_0x2b814e)['then'](function(_0x5a594b){_0x5a101a[_0x0a9e('0x3e')]=_0x5a594b;if(_0x140511[_0x0a9e('0x30')]['includeAll']){_0x11c3b6[_0x0a9e('0x3f')]=[{'all':!![]}];}return db[_0x0a9e('0x2a')][_0x0a9e('0x40')](_0x11c3b6);})['then'](function(_0x316c8f){_0x5a101a[_0x0a9e('0x41')]=_0x316c8f;return _0x5a101a;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x1538a4,_0x11c3b6))[_0x0a9e('0x42')](handleError(_0x1538a4,null));};exports[_0x0a9e('0x43')]=function(_0xeaa5e5,_0x2881b3){var _0x45a9b8={'raw':!![],'where':{'id':_0xeaa5e5[_0x0a9e('0x44')]['id']}},_0x23b089={};_0x23b089[_0x0a9e('0x2f')]=_[_0x0a9e('0x31')](db[_0x0a9e('0x2a')][_0x0a9e('0x2b')]);_0x23b089[_0x0a9e('0x30')]=_['keys'](_0xeaa5e5['query']);_0x23b089[_0x0a9e('0x39')]=_[_0x0a9e('0x32')](_0x23b089[_0x0a9e('0x2f')],_0x23b089[_0x0a9e('0x30')]);_0x45a9b8[_0x0a9e('0x33')]=_[_0x0a9e('0x32')](_0x23b089[_0x0a9e('0x2f')],qs[_0x0a9e('0x34')](_0xeaa5e5[_0x0a9e('0x30')][_0x0a9e('0x34')]));_0x45a9b8[_0x0a9e('0x33')]=_0x45a9b8[_0x0a9e('0x33')]['length']?_0x45a9b8[_0x0a9e('0x33')]:_0x23b089[_0x0a9e('0x2f')];if(_0xeaa5e5[_0x0a9e('0x30')][_0x0a9e('0x45')]){_0x45a9b8[_0x0a9e('0x3f')]=[{'all':!![]}];}_0x45a9b8=_[_0x0a9e('0x3b')]({},_0x45a9b8,_0xeaa5e5[_0x0a9e('0x46')]);return db[_0x0a9e('0x2a')]['find'](_0x45a9b8)[_0x0a9e('0x22')](handleEntityNotFound(_0x2881b3,null))['then'](respondWithResult(_0x2881b3,null))[_0x0a9e('0x42')](handleError(_0x2881b3,null));};exports[_0x0a9e('0x47')]=function(_0x8d6dd1,_0x562fb4,_0x14bec2){return db[_0x0a9e('0x2a')][_0x0a9e('0x48')]({'where':{'id':_0x8d6dd1[_0x0a9e('0x44')]['id']},'attributes':[_0x0a9e('0x26'),_0x0a9e('0x49'),_0x0a9e('0x4a')],'raw':!![]})['then'](handleEntityNotFound(_0x562fb4,null))[_0x0a9e('0x22')](function(_0x1bde3c){if(_0x1bde3c){if(!fs[_0x0a9e('0x4b')](path[_0x0a9e('0x4c')](config[_0x0a9e('0x4d')],_0x0a9e('0x4e'),_0x1bde3c[_0x0a9e('0x49')]+'.'+_0x1bde3c[_0x0a9e('0x4a')]))){throw new db[(_0x0a9e('0x4f'))]['ValidationError'](_0x0a9e('0x50'));}return _0x562fb4[_0x0a9e('0x47')](path['join'](config['root'],'server/files/sounds/converted',util[_0x0a9e('0x51')](_0x0a9e('0x52'),_0x1bde3c[_0x0a9e('0x49')],_0x1bde3c[_0x0a9e('0x4a')])),util[_0x0a9e('0x51')](_0x0a9e('0x52'),_0x1bde3c[_0x0a9e('0x26')],_0x1bde3c[_0x0a9e('0x4a')]));}return null;})['catch'](handleError(_0x562fb4,null));};exports['create']=function(_0x53975a,_0x39d77d,_0x204173){var _0x14d602={'name':path['basename'](_0x53975a[_0x0a9e('0x53')][_0x0a9e('0x54')],path['extname'](_0x53975a['file'][_0x0a9e('0x54')])),'save_name':path['basename'](_0x53975a[_0x0a9e('0x53')]['filename'],path[_0x0a9e('0x55')](_0x53975a[_0x0a9e('0x53')][_0x0a9e('0x56')])),'original_format':path['extname'](_0x53975a[_0x0a9e('0x53')][_0x0a9e('0x54')])['substring'](0x1),'converted_format':'wav'};var _0x128aa6=path[_0x0a9e('0x4c')](config['root'],_0x0a9e('0x57'),_0x53975a['file'][_0x0a9e('0x56')]);var _0x523cd2=path[_0x0a9e('0x4c')](config['root'],'server/files/sounds/converted',util['format'](_0x0a9e('0x52'),path['basename'](_0x53975a[_0x0a9e('0x53')][_0x0a9e('0x56')],path[_0x0a9e('0x55')](_0x53975a[_0x0a9e('0x53')][_0x0a9e('0x56')])),_0x14d602[_0x0a9e('0x4a')]));logger[_0x0a9e('0x58')](_0x0a9e('0x59'),_0x128aa6);logger['info'](_0x0a9e('0x5a'),_0x523cd2);try{fs[_0x0a9e('0x5b')](_0x128aa6,parseInt(_0x0a9e('0x5c'),0x8));var _0x30c491=sox[_0x0a9e('0x5d')](_0x128aa6,_0x523cd2,{'sampleRate':0x1f40,'format':_0x0a9e('0x5e'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x30c491['on']('error',function(_0x956fbe){fs[_0x0a9e('0x5f')](_0x128aa6);_0x39d77d['status'](0x1f4)[_0x0a9e('0x27')](_0x956fbe);});_0x30c491['on']('src',function(_0x20c668){_0x14d602['original_duration']=isNaN(_0x20c668['duration'])?null:_0x20c668['duration']*0x3e8;_0x14d602[_0x0a9e('0x60')]=isNaN(_0x20c668['sampleCount'])?null:_0x20c668[_0x0a9e('0x61')];_0x14d602[_0x0a9e('0x62')]=isNaN(_0x20c668[_0x0a9e('0x63')])?null:_0x20c668[_0x0a9e('0x63')];_0x14d602[_0x0a9e('0x64')]=isNaN(_0x20c668[_0x0a9e('0x65')])?null:_0x20c668['bitRate'];_0x14d602[_0x0a9e('0x66')]=isNaN(_0x20c668['sampleRate'])?null:_0x20c668[_0x0a9e('0x67')];});_0x30c491['on'](_0x0a9e('0x68'),function(_0x51aaf7){_0x14d602['converted_duration']=isNaN(_0x51aaf7[_0x0a9e('0x69')])?null:_0x51aaf7[_0x0a9e('0x69')]*0x3e8;_0x14d602[_0x0a9e('0x6a')]=isNaN(_0x51aaf7[_0x0a9e('0x61')])?null:_0x51aaf7['sampleCount'];_0x14d602[_0x0a9e('0x6b')]=isNaN(_0x51aaf7[_0x0a9e('0x63')])?null:_0x51aaf7['channelCount'];_0x14d602[_0x0a9e('0x6c')]=isNaN(_0x51aaf7[_0x0a9e('0x65')])?null:_0x51aaf7[_0x0a9e('0x65')];_0x14d602[_0x0a9e('0x6d')]=isNaN(_0x51aaf7[_0x0a9e('0x67')])?null:_0x51aaf7['sampleRate'];});_0x30c491['on'](_0x0a9e('0x16'),function(){fs[_0x0a9e('0x5b')](_0x523cd2,parseInt(_0x0a9e('0x5c'),0x8));return db['Sound'][_0x0a9e('0x6e')](_0x14d602)['then'](function(_0x5211e3){var _0x242745={'role':_0x53975a[_0x0a9e('0x6f')][_0x0a9e('0x70')],'userProfileId':_0x53975a[_0x0a9e('0x6f')][_0x0a9e('0x71')]};if(!_0x242745)throw new Error(_0x0a9e('0x72'));if(_0x242745[_0x0a9e('0x70')]===_0x0a9e('0x73')){var _0x2d7205=_0x5211e3[_0x0a9e('0x74')]({'plain':!![]});return db[_0x0a9e('0x75')][_0x0a9e('0x48')]({'where':{'name':_0x0a9e('0x23'),'userProfileId':_0x242745[_0x0a9e('0x71')]},'raw':!![]})[_0x0a9e('0x22')](function(_0x412a72){if(_0x412a72&&_0x412a72[_0x0a9e('0x76')]===0x0){return db[_0x0a9e('0x24')]['create']({'name':_0x2d7205[_0x0a9e('0x26')],'resourceId':_0x2d7205['id'],'type':_0x412a72[_0x0a9e('0x26')],'sectionId':_0x412a72['id']},{})[_0x0a9e('0x22')](function(){return _0x5211e3;});}else{return _0x5211e3;}})['catch'](function(_0x1148a1){logger[_0x0a9e('0x77')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1148a1);throw _0x1148a1;});}return _0x5211e3;})[_0x0a9e('0x22')](respondWithResult(_0x39d77d,null))[_0x0a9e('0x42')](handleError(_0x39d77d,null));});_0x30c491[_0x0a9e('0x78')]();}catch(_0x427946){_0x39d77d[_0x0a9e('0x17')](0x1f4)['send'](_0x427946);}};exports['update']=function(_0x4a2438,_0x40fb85,_0x18bf5d){return db[_0x0a9e('0x2a')][_0x0a9e('0x48')]({'where':{'id':_0x4a2438[_0x0a9e('0x44')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x40fb85,null))[_0x0a9e('0x22')](saveUpdates(_[_0x0a9e('0x79')](_0x4a2438['body'],[_0x0a9e('0x26'),_0x0a9e('0x7a')]),null))[_0x0a9e('0x22')](respondWithResult(_0x40fb85,null))['catch'](handleError(_0x40fb85,null));};exports[_0x0a9e('0x7b')]=function(_0x583b2e,_0x4437ff,_0x44351d){return db['Sound'][_0x0a9e('0x48')]({'where':{'id':_0x583b2e[_0x0a9e('0x44')]['id']}})[_0x0a9e('0x22')](function(_0x317c0c){if(_0x317c0c){return _0x317c0c['destroy']();}})[_0x0a9e('0x22')](function(_0x2e9552){var _0x371533=path[_0x0a9e('0x4c')](config['root'],_0x0a9e('0x57'),util[_0x0a9e('0x51')](_0x0a9e('0x52'),_0x2e9552[_0x0a9e('0x49')],_0x2e9552['original_format']));var _0x290d43=path[_0x0a9e('0x4c')](config[_0x0a9e('0x4d')],_0x0a9e('0x4e'),util[_0x0a9e('0x51')](_0x0a9e('0x52'),_0x2e9552[_0x0a9e('0x49')],_0x2e9552[_0x0a9e('0x4a')]));fs[_0x0a9e('0x5f')](_0x371533);fs[_0x0a9e('0x5f')](_0x290d43);return _0x2e9552;})[_0x0a9e('0x22')](function(_0x1f10ef){if(_0x1f10ef){return _0x4437ff[_0x0a9e('0x17')](0xcc)[_0x0a9e('0x16')]();}})['then'](handleEntityNotFound(_0x4437ff,null))[_0x0a9e('0x42')](handleError(_0x4437ff,null));};
\ No newline at end of file
+var _0x0211=['moment','bluebird','mustache','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','apply','reject','save','update','then','destroy','get','Sounds','stack','name','index','map','rawAttributes','key','model','keys','intersection','query','fields','attributes','length','order','sort','filters','pick','filter','where','type','VIRTUAL','merge','options','Sound','includeAll','include','findAll','rows','catch','show','params','download','save_name','converted_format','existsSync','join','root','ValidationError','Sound\x20not\x20found','server/files/sounds/converted','format','%s.%s','create','basename','file','filename','extname','wav','server/files/sounds/original','info','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','send','src','original_duration','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_channelCount','converted_bitRate','converted_sampleRate','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','description','delete','original_format','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x257a28,_0x2cd00d){var _0x13bccc=function(_0x32c46f){while(--_0x32c46f){_0x257a28['push'](_0x257a28['shift']());}};_0x13bccc(++_0x2cd00d);}(_0x0211,0x1f0));var _0x1021=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0x0211[_0x432682];return _0x463d05;};'use strict';var emlformat=require(_0x1021('0x0'));var rimraf=require(_0x1021('0x1'));var zipdir=require(_0x1021('0x2'));var jsonpatch=require(_0x1021('0x3'));var rp=require('request-promise');var moment=require(_0x1021('0x4'));var BPromise=require(_0x1021('0x5'));var Mustache=require(_0x1021('0x6'));var util=require('util');var path=require('path');var sox=require(_0x1021('0x7'));var csv=require('to-csv');var ejs=require(_0x1021('0x8'));var fs=require('fs');var fs_extra=require(_0x1021('0x9'));var _=require(_0x1021('0xa'));var squel=require(_0x1021('0xb'));var crypto=require(_0x1021('0xc'));var jsforce=require(_0x1021('0xd'));var deskjs=require(_0x1021('0xe'));var toCsv=require('to-csv');var querystring=require(_0x1021('0xf'));var Papa=require('papaparse');var Redis=require(_0x1021('0x10'));var authService=require(_0x1021('0x11'));var qs=require(_0x1021('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1021('0x13'));var logger=require('../../config/logger')(_0x1021('0x14'));var utils=require(_0x1021('0x15'));var config=require(_0x1021('0x16'));var licenseUtil=require(_0x1021('0x17'));var db=require(_0x1021('0x18'))['db'];function respondWithStatusCode(_0x280b4e,_0x42ef62){_0x42ef62=_0x42ef62||0xcc;return function(_0x2fc97d){if(_0x2fc97d){return _0x280b4e[_0x1021('0x19')](_0x42ef62);}return _0x280b4e[_0x1021('0x1a')](_0x42ef62)[_0x1021('0x1b')]();};}function respondWithResult(_0x37e1dc,_0x4e5b04){_0x4e5b04=_0x4e5b04||0xc8;return function(_0x44f4b2){if(_0x44f4b2){return _0x37e1dc[_0x1021('0x1a')](_0x4e5b04)[_0x1021('0x1c')](_0x44f4b2);}};}function respondWithFilteredResult(_0x5014d0,_0x4cbf0e){return function(_0xc08349){if(_0xc08349){var _0x3a2625=typeof _0x4cbf0e[_0x1021('0x1d')]===_0x1021('0x1e')&&typeof _0x4cbf0e[_0x1021('0x1f')]==='undefined';var _0x10ff53=_0xc08349['count'];var _0xc4af52=_0x3a2625?0x0:_0x4cbf0e['offset'];var _0x323aaf=_0x3a2625?_0xc08349[_0x1021('0x20')]:_0x4cbf0e['offset']+_0x4cbf0e[_0x1021('0x1f')];var _0x50810a;if(_0x323aaf>=_0x10ff53){_0x323aaf=_0x10ff53;_0x50810a=0xc8;}else{_0x50810a=0xce;}_0x5014d0['status'](_0x50810a);return _0x5014d0['set']('Content-Range',_0xc4af52+'-'+_0x323aaf+'/'+_0x10ff53)['json'](_0xc08349);}return null;};}function patchUpdates(_0x5d8eca){return function(_0x1e27a4){try{jsonpatch[_0x1021('0x21')](_0x1e27a4,_0x5d8eca,!![]);}catch(_0x3f47e3){return BPromise[_0x1021('0x22')](_0x3f47e3);}return _0x1e27a4[_0x1021('0x23')]();};}function saveUpdates(_0x5b93a0,_0x3a526a){return function(_0x52e424){if(_0x52e424){return _0x52e424[_0x1021('0x24')](_0x5b93a0)[_0x1021('0x25')](function(_0x35d0c2){return _0x35d0c2;});}return null;};}function removeEntity(_0x2b0771,_0x26eacc){return function(_0xd3d444){if(_0xd3d444){return _0xd3d444[_0x1021('0x26')]()['then'](function(){var _0x34c16b=_0xd3d444[_0x1021('0x27')]({'plain':!![]});var _0x3653b9=_0x1021('0x28');return db['UserProfileResource'][_0x1021('0x26')]({'where':{'type':_0x3653b9,'resourceId':_0x34c16b['id']}})[_0x1021('0x25')](function(){return _0xd3d444;});})[_0x1021('0x25')](function(){_0x2b0771[_0x1021('0x1a')](0xcc)[_0x1021('0x1b')]();});}};}function handleEntityNotFound(_0x2053c2,_0x38ec08){return function(_0x3b0fc6){if(!_0x3b0fc6){_0x2053c2[_0x1021('0x19')](0x194);}return _0x3b0fc6;};}function handleError(_0x37e0d8,_0x150d5b){_0x150d5b=_0x150d5b||0x1f4;return function(_0x5cfb4b){logger['error'](_0x5cfb4b[_0x1021('0x29')]);if(_0x5cfb4b[_0x1021('0x2a')]){delete _0x5cfb4b['name'];}_0x37e0d8[_0x1021('0x1a')](_0x150d5b)['send'](_0x5cfb4b);};}exports[_0x1021('0x2b')]=function(_0x3a33d9,_0x3e9de8){var _0x31cd96={},_0x210e2a={},_0x51de17={'count':0x0,'rows':[]};var _0x1d12df=_[_0x1021('0x2c')](db['Sound'][_0x1021('0x2d')],function(_0xd7746b){return{'name':_0xd7746b['fieldName'],'type':_0xd7746b['type'][_0x1021('0x2e')]};});_0x210e2a[_0x1021('0x2f')]=_['map'](_0x1d12df,_0x1021('0x2a'));_0x210e2a['query']=_[_0x1021('0x30')](_0x3a33d9['query']);_0x210e2a['filters']=_[_0x1021('0x31')](_0x210e2a[_0x1021('0x2f')],_0x210e2a[_0x1021('0x32')]);_0x31cd96['attributes']=_[_0x1021('0x31')](_0x210e2a[_0x1021('0x2f')],qs[_0x1021('0x33')](_0x3a33d9[_0x1021('0x32')]['fields']));_0x31cd96['attributes']=_0x31cd96[_0x1021('0x34')][_0x1021('0x35')]?_0x31cd96[_0x1021('0x34')]:_0x210e2a['model'];if(!_0x3a33d9[_0x1021('0x32')]['hasOwnProperty']('nolimit')){_0x31cd96[_0x1021('0x1f')]=qs[_0x1021('0x1f')](_0x3a33d9['query'][_0x1021('0x1f')]);_0x31cd96[_0x1021('0x1d')]=qs[_0x1021('0x1d')](_0x3a33d9[_0x1021('0x32')][_0x1021('0x1d')]);}_0x31cd96[_0x1021('0x36')]=qs[_0x1021('0x37')](_0x3a33d9[_0x1021('0x32')][_0x1021('0x37')]);_0x31cd96['where']=qs[_0x1021('0x38')](_[_0x1021('0x39')](_0x3a33d9[_0x1021('0x32')],_0x210e2a[_0x1021('0x38')]),_0x1d12df);if(_0x3a33d9[_0x1021('0x32')][_0x1021('0x3a')]){_0x31cd96[_0x1021('0x3b')]=_['merge'](_0x31cd96['where'],{'$or':_[_0x1021('0x2c')](_0x1d12df,function(_0x4a871f){if(_0x4a871f[_0x1021('0x3c')]!==_0x1021('0x3d')){var _0x4f4568={};_0x4f4568[_0x4a871f[_0x1021('0x2a')]]={'$like':'%'+_0x3a33d9[_0x1021('0x32')][_0x1021('0x3a')]+'%'};return _0x4f4568;}})});}_0x31cd96=_[_0x1021('0x3e')]({},_0x31cd96,_0x3a33d9[_0x1021('0x3f')]);var _0x371c24={'where':_0x31cd96[_0x1021('0x3b')]};return db[_0x1021('0x40')][_0x1021('0x20')](_0x371c24)['then'](function(_0x15a481){_0x51de17[_0x1021('0x20')]=_0x15a481;if(_0x3a33d9['query'][_0x1021('0x41')]){_0x31cd96[_0x1021('0x42')]=[{'all':!![]}];}return db['Sound'][_0x1021('0x43')](_0x31cd96);})[_0x1021('0x25')](function(_0x1ab08e){_0x51de17[_0x1021('0x44')]=_0x1ab08e;return _0x51de17;})[_0x1021('0x25')](respondWithFilteredResult(_0x3e9de8,_0x31cd96))[_0x1021('0x45')](handleError(_0x3e9de8,null));};exports[_0x1021('0x46')]=function(_0x269638,_0x33c892){var _0x4b95ae={'raw':!![],'where':{'id':_0x269638[_0x1021('0x47')]['id']}},_0x28b45c={};_0x28b45c[_0x1021('0x2f')]=_[_0x1021('0x30')](db[_0x1021('0x40')][_0x1021('0x2d')]);_0x28b45c[_0x1021('0x32')]=_['keys'](_0x269638[_0x1021('0x32')]);_0x28b45c[_0x1021('0x38')]=_[_0x1021('0x31')](_0x28b45c['model'],_0x28b45c[_0x1021('0x32')]);_0x4b95ae['attributes']=_[_0x1021('0x31')](_0x28b45c[_0x1021('0x2f')],qs[_0x1021('0x33')](_0x269638['query'][_0x1021('0x33')]));_0x4b95ae[_0x1021('0x34')]=_0x4b95ae[_0x1021('0x34')][_0x1021('0x35')]?_0x4b95ae['attributes']:_0x28b45c['model'];if(_0x269638[_0x1021('0x32')][_0x1021('0x41')]){_0x4b95ae[_0x1021('0x42')]=[{'all':!![]}];}_0x4b95ae=_[_0x1021('0x3e')]({},_0x4b95ae,_0x269638['options']);return db['Sound']['find'](_0x4b95ae)['then'](handleEntityNotFound(_0x33c892,null))[_0x1021('0x25')](respondWithResult(_0x33c892,null))[_0x1021('0x45')](handleError(_0x33c892,null));};exports[_0x1021('0x48')]=function(_0x1edb61,_0x5c5a83,_0x3ef281){return db[_0x1021('0x40')]['find']({'where':{'id':_0x1edb61['params']['id']},'attributes':['name',_0x1021('0x49'),_0x1021('0x4a')],'raw':!![]})[_0x1021('0x25')](handleEntityNotFound(_0x5c5a83,null))[_0x1021('0x25')](function(_0x5336e8){if(_0x5336e8){if(!fs[_0x1021('0x4b')](path[_0x1021('0x4c')](config[_0x1021('0x4d')],'server/files/sounds/converted',_0x5336e8[_0x1021('0x49')]+'.'+_0x5336e8['converted_format']))){throw new db['Sequelize'][(_0x1021('0x4e'))](_0x1021('0x4f'));}return _0x5c5a83[_0x1021('0x48')](path[_0x1021('0x4c')](config['root'],_0x1021('0x50'),util[_0x1021('0x51')](_0x1021('0x52'),_0x5336e8[_0x1021('0x49')],_0x5336e8['converted_format'])),util[_0x1021('0x51')](_0x1021('0x52'),_0x5336e8[_0x1021('0x2a')],_0x5336e8[_0x1021('0x4a')]));}return null;})['catch'](handleError(_0x5c5a83,null));};exports[_0x1021('0x53')]=function(_0x181b3f,_0x5106f8,_0x50ba79){var _0x4120bd={'name':path[_0x1021('0x54')](_0x181b3f[_0x1021('0x55')]['originalname'],path['extname'](_0x181b3f[_0x1021('0x55')]['originalname'])),'save_name':path[_0x1021('0x54')](_0x181b3f[_0x1021('0x55')][_0x1021('0x56')],path[_0x1021('0x57')](_0x181b3f[_0x1021('0x55')]['filename'])),'original_format':path[_0x1021('0x57')](_0x181b3f['file']['originalname'])['substring'](0x1),'converted_format':_0x1021('0x58')};var _0x51b941=path[_0x1021('0x4c')](config[_0x1021('0x4d')],_0x1021('0x59'),_0x181b3f['file'][_0x1021('0x56')]);var _0x55a531=path[_0x1021('0x4c')](config[_0x1021('0x4d')],_0x1021('0x50'),util[_0x1021('0x51')]('%s.%s',path[_0x1021('0x54')](_0x181b3f[_0x1021('0x55')][_0x1021('0x56')],path['extname'](_0x181b3f[_0x1021('0x55')][_0x1021('0x56')])),_0x4120bd['converted_format']));logger[_0x1021('0x5a')]('Sound\x20upload\x20filepath:\x20%s',_0x51b941);logger['info'](_0x1021('0x5b'),_0x55a531);try{fs[_0x1021('0x5c')](_0x51b941,parseInt(_0x1021('0x5d'),0x8));var _0x4fdc02=sox[_0x1021('0x5e')](_0x51b941,_0x55a531,{'sampleRate':0x1f40,'format':'wav','channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x4fdc02['on']('error',function(_0xa8e685){fs['unlinkSync'](_0x51b941);_0x5106f8['status'](0x1f4)[_0x1021('0x5f')](_0xa8e685);});_0x4fdc02['on'](_0x1021('0x60'),function(_0x3a210c){_0x4120bd[_0x1021('0x61')]=isNaN(_0x3a210c['duration'])?null:_0x3a210c[_0x1021('0x62')]*0x3e8;_0x4120bd[_0x1021('0x63')]=isNaN(_0x3a210c['sampleCount'])?null:_0x3a210c[_0x1021('0x64')];_0x4120bd[_0x1021('0x65')]=isNaN(_0x3a210c[_0x1021('0x66')])?null:_0x3a210c[_0x1021('0x66')];_0x4120bd[_0x1021('0x67')]=isNaN(_0x3a210c[_0x1021('0x68')])?null:_0x3a210c[_0x1021('0x68')];_0x4120bd[_0x1021('0x69')]=isNaN(_0x3a210c[_0x1021('0x6a')])?null:_0x3a210c[_0x1021('0x6a')];});_0x4fdc02['on'](_0x1021('0x6b'),function(_0x4532de){_0x4120bd[_0x1021('0x6c')]=isNaN(_0x4532de[_0x1021('0x62')])?null:_0x4532de[_0x1021('0x62')]*0x3e8;_0x4120bd['converted_sampleCount']=isNaN(_0x4532de[_0x1021('0x64')])?null:_0x4532de[_0x1021('0x64')];_0x4120bd[_0x1021('0x6d')]=isNaN(_0x4532de[_0x1021('0x66')])?null:_0x4532de['channelCount'];_0x4120bd[_0x1021('0x6e')]=isNaN(_0x4532de[_0x1021('0x68')])?null:_0x4532de[_0x1021('0x68')];_0x4120bd[_0x1021('0x6f')]=isNaN(_0x4532de[_0x1021('0x6a')])?null:_0x4532de[_0x1021('0x6a')];});_0x4fdc02['on'](_0x1021('0x1b'),function(){fs[_0x1021('0x5c')](_0x55a531,parseInt(_0x1021('0x5d'),0x8));return db[_0x1021('0x40')][_0x1021('0x53')](_0x4120bd)['then'](function(_0x38e947){var _0x5d993d={'role':_0x181b3f[_0x1021('0x70')][_0x1021('0x71')],'userProfileId':_0x181b3f[_0x1021('0x70')][_0x1021('0x72')]};if(!_0x5d993d)throw new Error(_0x1021('0x73'));if(_0x5d993d[_0x1021('0x71')]==='user'){var _0x16e9cf=_0x38e947['get']({'plain':!![]});return db[_0x1021('0x74')][_0x1021('0x75')]({'where':{'name':_0x1021('0x28'),'userProfileId':_0x5d993d['userProfileId']},'raw':!![]})['then'](function(_0x21536d){if(_0x21536d&&_0x21536d[_0x1021('0x76')]===0x0){return db['UserProfileResource'][_0x1021('0x53')]({'name':_0x16e9cf[_0x1021('0x2a')],'resourceId':_0x16e9cf['id'],'type':_0x21536d[_0x1021('0x2a')],'sectionId':_0x21536d['id']},{})[_0x1021('0x25')](function(){return _0x38e947;});}else{return _0x38e947;}})[_0x1021('0x45')](function(_0x5a4d85){logger[_0x1021('0x77')](_0x1021('0x78'),_0x5a4d85);throw _0x5a4d85;});}return _0x38e947;})[_0x1021('0x25')](respondWithResult(_0x5106f8,null))[_0x1021('0x45')](handleError(_0x5106f8,null));});_0x4fdc02['start']();}catch(_0x8d75d3){_0x5106f8[_0x1021('0x1a')](0x1f4)[_0x1021('0x5f')](_0x8d75d3);}};exports['update']=function(_0x440972,_0x5d120c,_0x47b0a5){return db[_0x1021('0x40')][_0x1021('0x75')]({'where':{'id':_0x440972[_0x1021('0x47')]['id']}})[_0x1021('0x25')](handleEntityNotFound(_0x5d120c,null))[_0x1021('0x25')](saveUpdates(_[_0x1021('0x39')](_0x440972[_0x1021('0x70')],[_0x1021('0x2a'),_0x1021('0x79')]),null))[_0x1021('0x25')](respondWithResult(_0x5d120c,null))[_0x1021('0x45')](handleError(_0x5d120c,null));};exports[_0x1021('0x7a')]=function(_0x579340,_0xf42d93,_0x10730a){return db['Sound'][_0x1021('0x75')]({'where':{'id':_0x579340[_0x1021('0x47')]['id']}})['then'](function(_0x3d6d51){if(_0x3d6d51){return _0x3d6d51[_0x1021('0x26')]();}})['then'](function(_0x3edbb6){var _0x140aef=path['join'](config[_0x1021('0x4d')],'server/files/sounds/original',util[_0x1021('0x51')](_0x1021('0x52'),_0x3edbb6[_0x1021('0x49')],_0x3edbb6[_0x1021('0x7b')]));var _0x3056e3=path[_0x1021('0x4c')](config[_0x1021('0x4d')],_0x1021('0x50'),util[_0x1021('0x51')](_0x1021('0x52'),_0x3edbb6[_0x1021('0x49')],_0x3edbb6[_0x1021('0x4a')]));fs[_0x1021('0x7c')](_0x140aef);fs[_0x1021('0x7c')](_0x3056e3);return _0x3edbb6;})['then'](function(_0x3513e6){if(_0x3513e6){return _0xf42d93['status'](0xcc)[_0x1021('0x1b')]();}})[_0x1021('0x25')](handleEntityNotFound(_0xf42d93,null))[_0x1021('0x45')](handleError(_0xf42d93,null));};
\ No newline at end of file