Built motion from commit f94df7f0.|2.5.48
[motion2.git] / server / api / sound / sound.controller.js
index 0d6365b..74d648e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa18b=['sox','ejs','fs-extra','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','UserProfileResource','error','stack','name','index','map','Sound','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','pick','where','VIRTUAL','merge','options','findAll','rows','show','params','includeAll','include','find','catch','download','save_name','existsSync','join','root','ValidationError','server/files/sounds/converted','format','converted_format','create','basename','file','originalname','filename','extname','wav','%s.%s','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','send','src','original_duration','duration','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','body','userProfileId','role','UserProfileSection','Sounds','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','description','delete','eml-format','rimraf','fast-json-patch','request-promise','moment'];(function(_0x1fb7d1,_0x108781){var _0x2480d8=function(_0x9bc3d9){while(--_0x9bc3d9){_0x1fb7d1['push'](_0x1fb7d1['shift']());}};_0x2480d8(++_0x108781);}(_0xa18b,0x74));var _0xba18=function(_0x479746,_0x574758){_0x479746=_0x479746-0x0;var _0x36d2aa=_0xa18b[_0x479746];return _0x36d2aa;};'use strict';var emlformat=require(_0xba18('0x0'));var rimraf=require(_0xba18('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xba18('0x2'));var rp=require(_0xba18('0x3'));var moment=require(_0xba18('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xba18('0x5'));var csv=require('to-csv');var ejs=require(_0xba18('0x6'));var fs=require('fs');var fs_extra=require(_0xba18('0x7'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xba18('0x8'));var jsforce=require(_0xba18('0x9'));var deskjs=require('desk.js');var toCsv=require(_0xba18('0xa'));var querystring=require(_0xba18('0xb'));var Papa=require(_0xba18('0xc'));var Redis=require(_0xba18('0xd'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xba18('0xe'));var hardwareService=require(_0xba18('0xf'));var logger=require('../../config/logger')(_0xba18('0x10'));var utils=require(_0xba18('0x11'));var config=require(_0xba18('0x12'));var licenseUtil=require(_0xba18('0x13'));var db=require(_0xba18('0x14'))['db'];function respondWithStatusCode(_0x4ffca7,_0x33eaa6){_0x33eaa6=_0x33eaa6||0xcc;return function(_0x412e9f){if(_0x412e9f){return _0x4ffca7[_0xba18('0x15')](_0x33eaa6);}return _0x4ffca7[_0xba18('0x16')](_0x33eaa6)[_0xba18('0x17')]();};}function respondWithResult(_0x37564b,_0x520353){_0x520353=_0x520353||0xc8;return function(_0x56b87e){if(_0x56b87e){return _0x37564b[_0xba18('0x16')](_0x520353)[_0xba18('0x18')](_0x56b87e);}};}function respondWithFilteredResult(_0x37a8f8,_0x139796){return function(_0x1e5095){if(_0x1e5095){var _0x5849e1=typeof _0x139796[_0xba18('0x19')]===_0xba18('0x1a')&&typeof _0x139796[_0xba18('0x1b')]===_0xba18('0x1a');var _0x3a615=_0x1e5095['count'];var _0x5538ab=_0x5849e1?0x0:_0x139796[_0xba18('0x19')];var _0x457f8e=_0x5849e1?_0x1e5095[_0xba18('0x1c')]:_0x139796[_0xba18('0x19')]+_0x139796[_0xba18('0x1b')];var _0xdd3e2c;if(_0x457f8e>=_0x3a615){_0x457f8e=_0x3a615;_0xdd3e2c=0xc8;}else{_0xdd3e2c=0xce;}_0x37a8f8[_0xba18('0x16')](_0xdd3e2c);return _0x37a8f8[_0xba18('0x1d')](_0xba18('0x1e'),_0x5538ab+'-'+_0x457f8e+'/'+_0x3a615)[_0xba18('0x18')](_0x1e5095);}return null;};}function patchUpdates(_0x2abb60){return function(_0x52419f){try{jsonpatch['apply'](_0x52419f,_0x2abb60,!![]);}catch(_0x5b7ebd){return BPromise[_0xba18('0x1f')](_0x5b7ebd);}return _0x52419f[_0xba18('0x20')]();};}function saveUpdates(_0x1b5700,_0x343022){return function(_0x5db77c){if(_0x5db77c){return _0x5db77c[_0xba18('0x21')](_0x1b5700)[_0xba18('0x22')](function(_0x120d9d){return _0x120d9d;});}return null;};}function removeEntity(_0x463bae,_0x12acab){return function(_0x3e6772){if(_0x3e6772){return _0x3e6772[_0xba18('0x23')]()[_0xba18('0x22')](function(){var _0x3f09c1=_0x3e6772['get']({'plain':!![]});var _0x45bddc='Sounds';return db[_0xba18('0x24')][_0xba18('0x23')]({'where':{'type':_0x45bddc,'resourceId':_0x3f09c1['id']}})[_0xba18('0x22')](function(){return _0x3e6772;});})['then'](function(){_0x463bae[_0xba18('0x16')](0xcc)[_0xba18('0x17')]();});}};}function handleEntityNotFound(_0x1e58f2,_0x44aa0d){return function(_0x2b4b52){if(!_0x2b4b52){_0x1e58f2[_0xba18('0x15')](0x194);}return _0x2b4b52;};}function handleError(_0x190d8e,_0x1cc3aa){_0x1cc3aa=_0x1cc3aa||0x1f4;return function(_0x1f3f22){logger[_0xba18('0x25')](_0x1f3f22[_0xba18('0x26')]);if(_0x1f3f22[_0xba18('0x27')]){delete _0x1f3f22['name'];}_0x190d8e[_0xba18('0x16')](_0x1cc3aa)['send'](_0x1f3f22);};}exports[_0xba18('0x28')]=function(_0x2ad7eb,_0x2028e3){var _0x5403de={},_0x561ef3={},_0x46e453={'count':0x0,'rows':[]};var _0x3b28c7=_[_0xba18('0x29')](db[_0xba18('0x2a')][_0xba18('0x2b')],function(_0x113041){return{'name':_0x113041[_0xba18('0x2c')],'type':_0x113041[_0xba18('0x2d')]['key']};});_0x561ef3[_0xba18('0x2e')]=_[_0xba18('0x29')](_0x3b28c7,_0xba18('0x27'));_0x561ef3[_0xba18('0x2f')]=_[_0xba18('0x30')](_0x2ad7eb[_0xba18('0x2f')]);_0x561ef3[_0xba18('0x31')]=_[_0xba18('0x32')](_0x561ef3[_0xba18('0x2e')],_0x561ef3[_0xba18('0x2f')]);_0x5403de['attributes']=_[_0xba18('0x32')](_0x561ef3['model'],qs[_0xba18('0x33')](_0x2ad7eb['query'][_0xba18('0x33')]));_0x5403de[_0xba18('0x34')]=_0x5403de['attributes'][_0xba18('0x35')]?_0x5403de[_0xba18('0x34')]:_0x561ef3[_0xba18('0x2e')];if(!_0x2ad7eb[_0xba18('0x2f')][_0xba18('0x36')](_0xba18('0x37'))){_0x5403de[_0xba18('0x1b')]=qs[_0xba18('0x1b')](_0x2ad7eb[_0xba18('0x2f')][_0xba18('0x1b')]);_0x5403de[_0xba18('0x19')]=qs[_0xba18('0x19')](_0x2ad7eb[_0xba18('0x2f')][_0xba18('0x19')]);}_0x5403de[_0xba18('0x38')]=qs['sort'](_0x2ad7eb['query']['sort']);_0x5403de['where']=qs[_0xba18('0x31')](_[_0xba18('0x39')](_0x2ad7eb[_0xba18('0x2f')],_0x561ef3[_0xba18('0x31')]),_0x3b28c7);if(_0x2ad7eb[_0xba18('0x2f')]['filter']){_0x5403de[_0xba18('0x3a')]=_['merge'](_0x5403de[_0xba18('0x3a')],{'$or':_[_0xba18('0x29')](_0x3b28c7,function(_0x2f7eb9){if(_0x2f7eb9['type']!==_0xba18('0x3b')){var _0x124e3e={};_0x124e3e[_0x2f7eb9['name']]={'$like':'%'+_0x2ad7eb[_0xba18('0x2f')]['filter']+'%'};return _0x124e3e;}})});}_0x5403de=_[_0xba18('0x3c')]({},_0x5403de,_0x2ad7eb[_0xba18('0x3d')]);var _0x7ed3ad={'where':_0x5403de[_0xba18('0x3a')]};return db[_0xba18('0x2a')][_0xba18('0x1c')](_0x7ed3ad)[_0xba18('0x22')](function(_0x17a5fe){_0x46e453['count']=_0x17a5fe;if(_0x2ad7eb['query']['includeAll']){_0x5403de['include']=[{'all':!![]}];}return db[_0xba18('0x2a')][_0xba18('0x3e')](_0x5403de);})[_0xba18('0x22')](function(_0xa8a989){_0x46e453[_0xba18('0x3f')]=_0xa8a989;return _0x46e453;})['then'](respondWithFilteredResult(_0x2028e3,_0x5403de))['catch'](handleError(_0x2028e3,null));};exports[_0xba18('0x40')]=function(_0x4ab3c1,_0x25d54b){var _0x55afc3={'raw':!![],'where':{'id':_0x4ab3c1[_0xba18('0x41')]['id']}},_0x29dcec={};_0x29dcec[_0xba18('0x2e')]=_[_0xba18('0x30')](db['Sound'][_0xba18('0x2b')]);_0x29dcec[_0xba18('0x2f')]=_[_0xba18('0x30')](_0x4ab3c1[_0xba18('0x2f')]);_0x29dcec['filters']=_[_0xba18('0x32')](_0x29dcec['model'],_0x29dcec[_0xba18('0x2f')]);_0x55afc3[_0xba18('0x34')]=_[_0xba18('0x32')](_0x29dcec[_0xba18('0x2e')],qs[_0xba18('0x33')](_0x4ab3c1[_0xba18('0x2f')]['fields']));_0x55afc3['attributes']=_0x55afc3[_0xba18('0x34')][_0xba18('0x35')]?_0x55afc3[_0xba18('0x34')]:_0x29dcec['model'];if(_0x4ab3c1['query'][_0xba18('0x42')]){_0x55afc3[_0xba18('0x43')]=[{'all':!![]}];}_0x55afc3=_[_0xba18('0x3c')]({},_0x55afc3,_0x4ab3c1[_0xba18('0x3d')]);return db[_0xba18('0x2a')][_0xba18('0x44')](_0x55afc3)[_0xba18('0x22')](handleEntityNotFound(_0x25d54b,null))[_0xba18('0x22')](respondWithResult(_0x25d54b,null))[_0xba18('0x45')](handleError(_0x25d54b,null));};exports[_0xba18('0x46')]=function(_0x3bc541,_0x5f1d30,_0x30ed6d){return db['Sound'][_0xba18('0x44')]({'where':{'id':_0x3bc541[_0xba18('0x41')]['id']},'attributes':['name',_0xba18('0x47'),'converted_format'],'raw':!![]})[_0xba18('0x22')](handleEntityNotFound(_0x5f1d30,null))[_0xba18('0x22')](function(_0x432830){if(_0x432830){if(!fs[_0xba18('0x48')](path[_0xba18('0x49')](config[_0xba18('0x4a')],'server/files/sounds/converted',_0x432830['save_name']+'.'+_0x432830['converted_format']))){throw new db['Sequelize'][(_0xba18('0x4b'))]('Sound\x20not\x20found');}return _0x5f1d30['download'](path[_0xba18('0x49')](config[_0xba18('0x4a')],_0xba18('0x4c'),util[_0xba18('0x4d')]('%s.%s',_0x432830['save_name'],_0x432830[_0xba18('0x4e')])),util[_0xba18('0x4d')]('%s.%s',_0x432830[_0xba18('0x27')],_0x432830[_0xba18('0x4e')]));}return null;})[_0xba18('0x45')](handleError(_0x5f1d30,null));};exports[_0xba18('0x4f')]=function(_0x157567,_0x391032,_0x55e7fa){var _0x3c949c={'name':path[_0xba18('0x50')](_0x157567[_0xba18('0x51')][_0xba18('0x52')],path['extname'](_0x157567[_0xba18('0x51')][_0xba18('0x52')])),'save_name':path[_0xba18('0x50')](_0x157567[_0xba18('0x51')][_0xba18('0x53')],path[_0xba18('0x54')](_0x157567[_0xba18('0x51')][_0xba18('0x53')])),'original_format':path[_0xba18('0x54')](_0x157567['file'][_0xba18('0x52')])['substring'](0x1),'converted_format':_0xba18('0x55')};var _0x3b500e=path[_0xba18('0x49')](config[_0xba18('0x4a')],'server/files/sounds/original',_0x157567[_0xba18('0x51')][_0xba18('0x53')]);var _0x49f137=path[_0xba18('0x49')](config['root'],'server/files/sounds/converted',util[_0xba18('0x4d')](_0xba18('0x56'),path[_0xba18('0x50')](_0x157567[_0xba18('0x51')][_0xba18('0x53')],path[_0xba18('0x54')](_0x157567[_0xba18('0x51')][_0xba18('0x53')])),_0x3c949c['converted_format']));logger[_0xba18('0x57')](_0xba18('0x58'),_0x3b500e);logger[_0xba18('0x57')](_0xba18('0x59'),_0x49f137);try{fs[_0xba18('0x5a')](_0x3b500e,parseInt(_0xba18('0x5b'),0x8));var _0x93d9dc=sox[_0xba18('0x5c')](_0x3b500e,_0x49f137,{'sampleRate':0x1f40,'format':_0xba18('0x55'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x93d9dc['on'](_0xba18('0x25'),function(_0x283d2d){fs[_0xba18('0x5d')](_0x3b500e);_0x391032[_0xba18('0x16')](0x1f4)[_0xba18('0x5e')](_0x283d2d);});_0x93d9dc['on'](_0xba18('0x5f'),function(_0x389cda){_0x3c949c[_0xba18('0x60')]=isNaN(_0x389cda[_0xba18('0x61')])?null:_0x389cda['duration']*0x3e8;_0x3c949c['original_sampleCount']=isNaN(_0x389cda['sampleCount'])?null:_0x389cda[_0xba18('0x62')];_0x3c949c[_0xba18('0x63')]=isNaN(_0x389cda[_0xba18('0x64')])?null:_0x389cda['channelCount'];_0x3c949c[_0xba18('0x65')]=isNaN(_0x389cda[_0xba18('0x66')])?null:_0x389cda[_0xba18('0x66')];_0x3c949c[_0xba18('0x67')]=isNaN(_0x389cda[_0xba18('0x68')])?null:_0x389cda[_0xba18('0x68')];});_0x93d9dc['on'](_0xba18('0x69'),function(_0x7c1a8d){_0x3c949c[_0xba18('0x6a')]=isNaN(_0x7c1a8d[_0xba18('0x61')])?null:_0x7c1a8d[_0xba18('0x61')]*0x3e8;_0x3c949c[_0xba18('0x6b')]=isNaN(_0x7c1a8d[_0xba18('0x62')])?null:_0x7c1a8d[_0xba18('0x62')];_0x3c949c[_0xba18('0x6c')]=isNaN(_0x7c1a8d['channelCount'])?null:_0x7c1a8d[_0xba18('0x64')];_0x3c949c[_0xba18('0x6d')]=isNaN(_0x7c1a8d['bitRate'])?null:_0x7c1a8d['bitRate'];_0x3c949c[_0xba18('0x6e')]=isNaN(_0x7c1a8d[_0xba18('0x68')])?null:_0x7c1a8d[_0xba18('0x68')];});_0x93d9dc['on'](_0xba18('0x17'),function(){fs[_0xba18('0x5a')](_0x49f137,parseInt('0777',0x8));return db[_0xba18('0x2a')][_0xba18('0x4f')](_0x3c949c)[_0xba18('0x22')](function(_0x36c5d2){var _0xc12313={'role':_0x157567[_0xba18('0x6f')]['role'],'userProfileId':_0x157567[_0xba18('0x6f')][_0xba18('0x70')]};if(!_0xc12313)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xc12313[_0xba18('0x71')]==='user'){var _0x436a6d=_0x36c5d2['get']({'plain':!![]});return db[_0xba18('0x72')]['find']({'where':{'name':_0xba18('0x73'),'userProfileId':_0xc12313[_0xba18('0x70')]},'raw':!![]})[_0xba18('0x22')](function(_0x290ff7){if(_0x290ff7&&_0x290ff7[_0xba18('0x74')]===0x0){return db[_0xba18('0x24')][_0xba18('0x4f')]({'name':_0x436a6d[_0xba18('0x27')],'resourceId':_0x436a6d['id'],'type':_0x290ff7[_0xba18('0x27')],'sectionId':_0x290ff7['id']},{})[_0xba18('0x22')](function(){return _0x36c5d2;});}else{return _0x36c5d2;}})['catch'](function(_0x48ef11){logger[_0xba18('0x25')](_0xba18('0x75'),_0x48ef11);throw _0x48ef11;});}return _0x36c5d2;})[_0xba18('0x22')](respondWithResult(_0x391032,null))[_0xba18('0x45')](handleError(_0x391032,null));});_0x93d9dc[_0xba18('0x76')]();}catch(_0x25d7c7){_0x391032['status'](0x1f4)[_0xba18('0x5e')](_0x25d7c7);}};exports[_0xba18('0x21')]=function(_0x1d5f93,_0x29049c,_0x4ae395){return db['Sound']['find']({'where':{'id':_0x1d5f93[_0xba18('0x41')]['id']}})[_0xba18('0x22')](handleEntityNotFound(_0x29049c,null))[_0xba18('0x22')](saveUpdates(_[_0xba18('0x39')](_0x1d5f93[_0xba18('0x6f')],['name',_0xba18('0x77')]),null))[_0xba18('0x22')](respondWithResult(_0x29049c,null))['catch'](handleError(_0x29049c,null));};exports[_0xba18('0x78')]=function(_0x28443c,_0x41a9d0,_0x1f1e8c){return db['Sound'][_0xba18('0x44')]({'where':{'id':_0x28443c['params']['id']}})[_0xba18('0x22')](function(_0x12fd9e){if(_0x12fd9e){return _0x12fd9e[_0xba18('0x23')]();}})[_0xba18('0x22')](function(_0x5d9772){var _0x255a49=path['join'](config[_0xba18('0x4a')],'server/files/sounds/original',util['format'](_0xba18('0x56'),_0x5d9772[_0xba18('0x47')],_0x5d9772['original_format']));var _0x1aa889=path[_0xba18('0x49')](config[_0xba18('0x4a')],_0xba18('0x4c'),util[_0xba18('0x4d')](_0xba18('0x56'),_0x5d9772[_0xba18('0x47')],_0x5d9772[_0xba18('0x4e')]));fs[_0xba18('0x5d')](_0x255a49);fs[_0xba18('0x5d')](_0x1aa889);return _0x5d9772;})[_0xba18('0x22')](function(_0x15c99a){if(_0x15c99a){return _0x41a9d0[_0xba18('0x16')](0xcc)[_0xba18('0x17')]();}})['then'](handleEntityNotFound(_0x41a9d0,null))[_0xba18('0x45')](handleError(_0x41a9d0,null));};
\ No newline at end of file
+var _0x93f1=['keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','find','params','save_name','converted_format','existsSync','join','root','server/files/sounds/converted','Sequelize','ValidationError','Sound\x20not\x20found','download','format','%s.%s','create','basename','file','originalname','extname','filename','substring','wav','info','chmodSync','0777','transcode','unlinkSync','send','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','Sounds','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','delete','server/files/sounds/original','original_format','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','reject','save','update','then','destroy','get','error','name','index','map','Sound','rawAttributes','fieldName','type','model','query'];(function(_0x3d0016,_0x4a37e0){var _0x1dcb28=function(_0x57bef9){while(--_0x57bef9){_0x3d0016['push'](_0x3d0016['shift']());}};_0x1dcb28(++_0x4a37e0);}(_0x93f1,0x1c5));var _0x193f=function(_0x306a37,_0x192495){_0x306a37=_0x306a37-0x0;var _0x213407=_0x93f1[_0x306a37];return _0x213407;};'use strict';var emlformat=require(_0x193f('0x0'));var rimraf=require(_0x193f('0x1'));var zipdir=require(_0x193f('0x2'));var jsonpatch=require(_0x193f('0x3'));var rp=require('request-promise');var moment=require(_0x193f('0x4'));var BPromise=require(_0x193f('0x5'));var Mustache=require(_0x193f('0x6'));var util=require(_0x193f('0x7'));var path=require('path');var sox=require(_0x193f('0x8'));var csv=require(_0x193f('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x193f('0xa'));var _=require(_0x193f('0xb'));var squel=require(_0x193f('0xc'));var crypto=require(_0x193f('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x193f('0xe'));var toCsv=require(_0x193f('0x9'));var querystring=require(_0x193f('0xf'));var Papa=require(_0x193f('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x193f('0x11'));var as=require(_0x193f('0x12'));var hardwareService=require(_0x193f('0x13'));var logger=require(_0x193f('0x14'))(_0x193f('0x15'));var utils=require(_0x193f('0x16'));var config=require(_0x193f('0x17'));var licenseUtil=require(_0x193f('0x18'));var db=require(_0x193f('0x19'))['db'];function respondWithStatusCode(_0x54ecf0,_0x318743){_0x318743=_0x318743||0xcc;return function(_0x1ef519){if(_0x1ef519){return _0x54ecf0[_0x193f('0x1a')](_0x318743);}return _0x54ecf0['status'](_0x318743)[_0x193f('0x1b')]();};}function respondWithResult(_0x2e872d,_0x15ceff){_0x15ceff=_0x15ceff||0xc8;return function(_0x22a477){if(_0x22a477){return _0x2e872d[_0x193f('0x1c')](_0x15ceff)[_0x193f('0x1d')](_0x22a477);}};}function respondWithFilteredResult(_0x476606,_0xdb14e0){return function(_0x325e91){if(_0x325e91){var _0x1a0518=typeof _0xdb14e0[_0x193f('0x1e')]===_0x193f('0x1f')&&typeof _0xdb14e0[_0x193f('0x20')]===_0x193f('0x1f');var _0x9e73f5=_0x325e91[_0x193f('0x21')];var _0x6469d0=_0x1a0518?0x0:_0xdb14e0[_0x193f('0x1e')];var _0x478f27=_0x1a0518?_0x325e91[_0x193f('0x21')]:_0xdb14e0[_0x193f('0x1e')]+_0xdb14e0['limit'];var _0x4d9d2c;if(_0x478f27>=_0x9e73f5){_0x478f27=_0x9e73f5;_0x4d9d2c=0xc8;}else{_0x4d9d2c=0xce;}_0x476606[_0x193f('0x1c')](_0x4d9d2c);return _0x476606[_0x193f('0x22')]('Content-Range',_0x6469d0+'-'+_0x478f27+'/'+_0x9e73f5)[_0x193f('0x1d')](_0x325e91);}return null;};}function patchUpdates(_0x3ade22){return function(_0x3afc9d){try{jsonpatch['apply'](_0x3afc9d,_0x3ade22,!![]);}catch(_0x3a4692){return BPromise[_0x193f('0x23')](_0x3a4692);}return _0x3afc9d[_0x193f('0x24')]();};}function saveUpdates(_0x19d131,_0xb0af84){return function(_0xfaa622){if(_0xfaa622){return _0xfaa622[_0x193f('0x25')](_0x19d131)[_0x193f('0x26')](function(_0xdebd01){return _0xdebd01;});}return null;};}function removeEntity(_0x27e867,_0x524ad1){return function(_0x3967e9){if(_0x3967e9){return _0x3967e9[_0x193f('0x27')]()[_0x193f('0x26')](function(){var _0x3ae59a=_0x3967e9[_0x193f('0x28')]({'plain':!![]});var _0x2a9a0d='Sounds';return db['UserProfileResource'][_0x193f('0x27')]({'where':{'type':_0x2a9a0d,'resourceId':_0x3ae59a['id']}})[_0x193f('0x26')](function(){return _0x3967e9;});})[_0x193f('0x26')](function(){_0x27e867['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x149d40,_0x2dc715){return function(_0x3b81d0){if(!_0x3b81d0){_0x149d40[_0x193f('0x1a')](0x194);}return _0x3b81d0;};}function handleError(_0x4254e5,_0x27fe1d){_0x27fe1d=_0x27fe1d||0x1f4;return function(_0x114054){logger[_0x193f('0x29')](_0x114054['stack']);if(_0x114054[_0x193f('0x2a')]){delete _0x114054[_0x193f('0x2a')];}_0x4254e5['status'](_0x27fe1d)['send'](_0x114054);};}exports[_0x193f('0x2b')]=function(_0xf20c5b,_0x4d9b16){var _0x2e1055={},_0x4e08d7={},_0x36d931={'count':0x0,'rows':[]};var _0x330548=_[_0x193f('0x2c')](db[_0x193f('0x2d')][_0x193f('0x2e')],function(_0x4e4593){return{'name':_0x4e4593[_0x193f('0x2f')],'type':_0x4e4593[_0x193f('0x30')]['key']};});_0x4e08d7[_0x193f('0x31')]=_[_0x193f('0x2c')](_0x330548,_0x193f('0x2a'));_0x4e08d7[_0x193f('0x32')]=_[_0x193f('0x33')](_0xf20c5b[_0x193f('0x32')]);_0x4e08d7[_0x193f('0x34')]=_[_0x193f('0x35')](_0x4e08d7[_0x193f('0x31')],_0x4e08d7['query']);_0x2e1055[_0x193f('0x36')]=_[_0x193f('0x35')](_0x4e08d7['model'],qs[_0x193f('0x37')](_0xf20c5b[_0x193f('0x32')][_0x193f('0x37')]));_0x2e1055[_0x193f('0x36')]=_0x2e1055[_0x193f('0x36')]['length']?_0x2e1055[_0x193f('0x36')]:_0x4e08d7[_0x193f('0x31')];if(!_0xf20c5b[_0x193f('0x32')][_0x193f('0x38')]('nolimit')){_0x2e1055[_0x193f('0x20')]=qs['limit'](_0xf20c5b['query']['limit']);_0x2e1055[_0x193f('0x1e')]=qs[_0x193f('0x1e')](_0xf20c5b[_0x193f('0x32')][_0x193f('0x1e')]);}_0x2e1055[_0x193f('0x39')]=qs[_0x193f('0x3a')](_0xf20c5b[_0x193f('0x32')][_0x193f('0x3a')]);_0x2e1055[_0x193f('0x3b')]=qs['filters'](_[_0x193f('0x3c')](_0xf20c5b[_0x193f('0x32')],_0x4e08d7[_0x193f('0x34')]),_0x330548);if(_0xf20c5b['query'][_0x193f('0x3d')]){_0x2e1055[_0x193f('0x3b')]=_[_0x193f('0x3e')](_0x2e1055[_0x193f('0x3b')],{'$or':_[_0x193f('0x2c')](_0x330548,function(_0x3b943f){if(_0x3b943f['type']!==_0x193f('0x3f')){var _0x8e6071={};_0x8e6071[_0x3b943f[_0x193f('0x2a')]]={'$like':'%'+_0xf20c5b['query'][_0x193f('0x3d')]+'%'};return _0x8e6071;}})});}_0x2e1055=_[_0x193f('0x3e')]({},_0x2e1055,_0xf20c5b[_0x193f('0x40')]);var _0x5ade1f={'where':_0x2e1055[_0x193f('0x3b')]};return db['Sound'][_0x193f('0x21')](_0x5ade1f)[_0x193f('0x26')](function(_0x110c14){_0x36d931[_0x193f('0x21')]=_0x110c14;if(_0xf20c5b[_0x193f('0x32')][_0x193f('0x41')]){_0x2e1055['include']=[{'all':!![]}];}return db[_0x193f('0x2d')][_0x193f('0x42')](_0x2e1055);})[_0x193f('0x26')](function(_0x37caa9){_0x36d931[_0x193f('0x43')]=_0x37caa9;return _0x36d931;})['then'](respondWithFilteredResult(_0x4d9b16,_0x2e1055))[_0x193f('0x44')](handleError(_0x4d9b16,null));};exports[_0x193f('0x45')]=function(_0x31946a,_0x38da9a){var _0x59145c={'raw':!![],'where':{'id':_0x31946a['params']['id']}},_0x4aeb5c={};_0x4aeb5c[_0x193f('0x31')]=_['keys'](db['Sound'][_0x193f('0x2e')]);_0x4aeb5c['query']=_[_0x193f('0x33')](_0x31946a[_0x193f('0x32')]);_0x4aeb5c['filters']=_[_0x193f('0x35')](_0x4aeb5c[_0x193f('0x31')],_0x4aeb5c['query']);_0x59145c[_0x193f('0x36')]=_[_0x193f('0x35')](_0x4aeb5c[_0x193f('0x31')],qs[_0x193f('0x37')](_0x31946a[_0x193f('0x32')][_0x193f('0x37')]));_0x59145c[_0x193f('0x36')]=_0x59145c[_0x193f('0x36')]['length']?_0x59145c[_0x193f('0x36')]:_0x4aeb5c[_0x193f('0x31')];if(_0x31946a[_0x193f('0x32')][_0x193f('0x41')]){_0x59145c['include']=[{'all':!![]}];}_0x59145c=_[_0x193f('0x3e')]({},_0x59145c,_0x31946a[_0x193f('0x40')]);return db[_0x193f('0x2d')]['find'](_0x59145c)['then'](handleEntityNotFound(_0x38da9a,null))[_0x193f('0x26')](respondWithResult(_0x38da9a,null))[_0x193f('0x44')](handleError(_0x38da9a,null));};exports['download']=function(_0x5e7a79,_0x22e208,_0xf1c9d3){return db[_0x193f('0x2d')][_0x193f('0x46')]({'where':{'id':_0x5e7a79[_0x193f('0x47')]['id']},'attributes':[_0x193f('0x2a'),_0x193f('0x48'),_0x193f('0x49')],'raw':!![]})[_0x193f('0x26')](handleEntityNotFound(_0x22e208,null))[_0x193f('0x26')](function(_0x19fa0f){if(_0x19fa0f){if(!fs[_0x193f('0x4a')](path[_0x193f('0x4b')](config[_0x193f('0x4c')],_0x193f('0x4d'),_0x19fa0f[_0x193f('0x48')]+'.'+_0x19fa0f['converted_format']))){throw new db[(_0x193f('0x4e'))][(_0x193f('0x4f'))](_0x193f('0x50'));}return _0x22e208[_0x193f('0x51')](path[_0x193f('0x4b')](config[_0x193f('0x4c')],_0x193f('0x4d'),util[_0x193f('0x52')](_0x193f('0x53'),_0x19fa0f[_0x193f('0x48')],_0x19fa0f[_0x193f('0x49')])),util[_0x193f('0x52')]('%s.%s',_0x19fa0f[_0x193f('0x2a')],_0x19fa0f[_0x193f('0x49')]));}return null;})[_0x193f('0x44')](handleError(_0x22e208,null));};exports[_0x193f('0x54')]=function(_0x81dd77,_0x19c705,_0x333661){var _0x2de4a2={'name':path[_0x193f('0x55')](_0x81dd77[_0x193f('0x56')][_0x193f('0x57')],path[_0x193f('0x58')](_0x81dd77[_0x193f('0x56')][_0x193f('0x57')])),'save_name':path[_0x193f('0x55')](_0x81dd77['file'][_0x193f('0x59')],path[_0x193f('0x58')](_0x81dd77['file']['filename'])),'original_format':path['extname'](_0x81dd77[_0x193f('0x56')][_0x193f('0x57')])[_0x193f('0x5a')](0x1),'converted_format':_0x193f('0x5b')};var _0x4faaf8=path[_0x193f('0x4b')](config[_0x193f('0x4c')],'server/files/sounds/original',_0x81dd77[_0x193f('0x56')][_0x193f('0x59')]);var _0x5e810c=path[_0x193f('0x4b')](config[_0x193f('0x4c')],'server/files/sounds/converted',util[_0x193f('0x52')]('%s.%s',path[_0x193f('0x55')](_0x81dd77[_0x193f('0x56')][_0x193f('0x59')],path['extname'](_0x81dd77[_0x193f('0x56')]['filename'])),_0x2de4a2[_0x193f('0x49')]));logger['info']('Sound\x20upload\x20filepath:\x20%s',_0x4faaf8);logger[_0x193f('0x5c')]('Sound\x20upload\x20destination:\x20%s',_0x5e810c);try{fs[_0x193f('0x5d')](_0x4faaf8,parseInt(_0x193f('0x5e'),0x8));var _0x125b47=sox[_0x193f('0x5f')](_0x4faaf8,_0x5e810c,{'sampleRate':0x1f40,'format':'wav','channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x125b47['on'](_0x193f('0x29'),function(_0x4160ea){fs[_0x193f('0x60')](_0x4faaf8);_0x19c705[_0x193f('0x1c')](0x1f4)[_0x193f('0x61')](_0x4160ea);});_0x125b47['on']('src',function(_0x330494){_0x2de4a2['original_duration']=isNaN(_0x330494[_0x193f('0x62')])?null:_0x330494[_0x193f('0x62')]*0x3e8;_0x2de4a2[_0x193f('0x63')]=isNaN(_0x330494[_0x193f('0x64')])?null:_0x330494[_0x193f('0x64')];_0x2de4a2[_0x193f('0x65')]=isNaN(_0x330494[_0x193f('0x66')])?null:_0x330494['channelCount'];_0x2de4a2[_0x193f('0x67')]=isNaN(_0x330494[_0x193f('0x68')])?null:_0x330494[_0x193f('0x68')];_0x2de4a2[_0x193f('0x69')]=isNaN(_0x330494[_0x193f('0x6a')])?null:_0x330494[_0x193f('0x6a')];});_0x125b47['on'](_0x193f('0x6b'),function(_0x377d6f){_0x2de4a2[_0x193f('0x6c')]=isNaN(_0x377d6f[_0x193f('0x62')])?null:_0x377d6f['duration']*0x3e8;_0x2de4a2[_0x193f('0x6d')]=isNaN(_0x377d6f[_0x193f('0x64')])?null:_0x377d6f[_0x193f('0x64')];_0x2de4a2[_0x193f('0x6e')]=isNaN(_0x377d6f[_0x193f('0x66')])?null:_0x377d6f[_0x193f('0x66')];_0x2de4a2[_0x193f('0x6f')]=isNaN(_0x377d6f[_0x193f('0x68')])?null:_0x377d6f['bitRate'];_0x2de4a2[_0x193f('0x70')]=isNaN(_0x377d6f[_0x193f('0x6a')])?null:_0x377d6f['sampleRate'];});_0x125b47['on'](_0x193f('0x1b'),function(){fs[_0x193f('0x5d')](_0x5e810c,parseInt('0777',0x8));return db[_0x193f('0x2d')][_0x193f('0x54')](_0x2de4a2)[_0x193f('0x26')](function(_0x428c46){var _0x4419ad={'role':_0x81dd77[_0x193f('0x71')][_0x193f('0x72')],'userProfileId':_0x81dd77[_0x193f('0x71')][_0x193f('0x73')]};if(!_0x4419ad)throw new Error(_0x193f('0x74'));if(_0x4419ad[_0x193f('0x72')]==='user'){var _0x5494c2=_0x428c46['get']({'plain':!![]});return db[_0x193f('0x75')][_0x193f('0x46')]({'where':{'name':_0x193f('0x76'),'userProfileId':_0x4419ad[_0x193f('0x73')]},'raw':!![]})[_0x193f('0x26')](function(_0x27202e){if(_0x27202e&&_0x27202e[_0x193f('0x77')]===0x0){return db[_0x193f('0x78')][_0x193f('0x54')]({'name':_0x5494c2['name'],'resourceId':_0x5494c2['id'],'type':_0x27202e[_0x193f('0x2a')],'sectionId':_0x27202e['id']},{})[_0x193f('0x26')](function(){return _0x428c46;});}else{return _0x428c46;}})[_0x193f('0x44')](function(_0x47a84b){logger[_0x193f('0x29')](_0x193f('0x79'),_0x47a84b);throw _0x47a84b;});}return _0x428c46;})[_0x193f('0x26')](respondWithResult(_0x19c705,null))['catch'](handleError(_0x19c705,null));});_0x125b47[_0x193f('0x7a')]();}catch(_0x234079){_0x19c705[_0x193f('0x1c')](0x1f4)[_0x193f('0x61')](_0x234079);}};exports['update']=function(_0x582823,_0x1bbe5d,_0x279b28){return db[_0x193f('0x2d')]['find']({'where':{'id':_0x582823['params']['id']}})[_0x193f('0x26')](handleEntityNotFound(_0x1bbe5d,null))[_0x193f('0x26')](saveUpdates(_[_0x193f('0x3c')](_0x582823[_0x193f('0x71')],[_0x193f('0x2a'),'description']),null))[_0x193f('0x26')](respondWithResult(_0x1bbe5d,null))[_0x193f('0x44')](handleError(_0x1bbe5d,null));};exports[_0x193f('0x7b')]=function(_0xce0825,_0x34f4cc,_0x21a8d1){return db[_0x193f('0x2d')]['find']({'where':{'id':_0xce0825[_0x193f('0x47')]['id']}})[_0x193f('0x26')](function(_0x53d3bf){if(_0x53d3bf){return _0x53d3bf[_0x193f('0x27')]();}})['then'](function(_0x36aa68){var _0x387411=path[_0x193f('0x4b')](config[_0x193f('0x4c')],_0x193f('0x7c'),util[_0x193f('0x52')](_0x193f('0x53'),_0x36aa68[_0x193f('0x48')],_0x36aa68[_0x193f('0x7d')]));var _0x5bbe58=path[_0x193f('0x4b')](config[_0x193f('0x4c')],_0x193f('0x4d'),util[_0x193f('0x52')](_0x193f('0x53'),_0x36aa68[_0x193f('0x48')],_0x36aa68[_0x193f('0x49')]));fs[_0x193f('0x60')](_0x387411);fs[_0x193f('0x60')](_0x5bbe58);return _0x36aa68;})[_0x193f('0x26')](function(_0xe1dc11){if(_0xe1dc11){return _0x34f4cc[_0x193f('0x1c')](0xcc)[_0x193f('0x1b')]();}})['then'](handleEntityNotFound(_0x34f4cc,null))[_0x193f('0x44')](handleError(_0x34f4cc,null));};
\ No newline at end of file