Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / sound / sound.controller.js
index d4a372a..e953cec 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8fc0=['UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','pick','description','delete','original_format','html-pdf','eml-format','rimraf','request-promise','moment','mustache','path','ejs','lodash','squel','crypto','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','status','end','json','count','offset','limit','set','apply','save','update','destroy','then','Sounds','UserProfileResource','error','name','map','Sound','type','key','model','query','keys','intersection','fields','attributes','hasOwnProperty','order','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','include','rows','catch','show','params','rawAttributes','length','find','download','save_name','converted_format','server/files/sounds/converted','Sequelize','ValidationError','Sound\x20not\x20found','root','format','%s.%s','basename','file','originalname','filename','extname','wav','join','Sound\x20upload\x20filepath:\x20%s','info','unlinkSync','send','src','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_channelCount','converted_bitRate','converted_sampleRate','0777','create','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user'];(function(_0x2da3ec,_0x13b6a5){var _0x3758f1=function(_0x5af356){while(--_0x5af356){_0x2da3ec['push'](_0x2da3ec['shift']());}};_0x3758f1(++_0x13b6a5);}(_0x8fc0,0x1d5));var _0x08fc=function(_0x49b207,_0x408ade){_0x49b207=_0x49b207-0x0;var _0x2dc8fa=_0x8fc0[_0x49b207];return _0x2dc8fa;};'use strict';var pdf=require(_0x08fc('0x0'));var emlformat=require(_0x08fc('0x1'));var rimraf=require(_0x08fc('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x08fc('0x3'));var moment=require(_0x08fc('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x08fc('0x5'));var util=require('util');var path=require(_0x08fc('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x08fc('0x7'));var fs=require('fs');var _=require(_0x08fc('0x8'));var squel=require(_0x08fc('0x9'));var crypto=require(_0x08fc('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x08fc('0xb'));var toCsv=require(_0x08fc('0xc'));var querystring=require('querystring');var Papa=require(_0x08fc('0xd'));var Redis=require('ioredis');var authService=require(_0x08fc('0xe'));var qs=require(_0x08fc('0xf'));var as=require(_0x08fc('0x10'));var hardwareService=require(_0x08fc('0x11'));var logger=require(_0x08fc('0x12'))('api');var utils=require('../../config/utils');var config=require(_0x08fc('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x08fc('0x14'))['db'];function respondWithStatusCode(_0x58efd1,_0x4e1e48){_0x4e1e48=_0x4e1e48||0xcc;return function(_0x31021c){if(_0x31021c){return _0x58efd1['sendStatus'](_0x4e1e48);}return _0x58efd1[_0x08fc('0x15')](_0x4e1e48)[_0x08fc('0x16')]();};}function respondWithResult(_0x482f18,_0x9422d8){_0x9422d8=_0x9422d8||0xc8;return function(_0x373ba3){if(_0x373ba3){return _0x482f18[_0x08fc('0x15')](_0x9422d8)[_0x08fc('0x17')](_0x373ba3);}};}function respondWithFilteredResult(_0x1566e3,_0x703a69){return function(_0x553c20){if(_0x553c20){var _0x1dbc13=_0x553c20[_0x08fc('0x18')],_0x3a54a7=_0x703a69[_0x08fc('0x19')],_0x228e3e=_0x703a69[_0x08fc('0x19')]+_0x703a69[_0x08fc('0x1a')],_0x57d4ad;if(_0x228e3e>=_0x1dbc13){_0x228e3e=_0x1dbc13;_0x57d4ad=0xc8;}else{_0x57d4ad=0xce;}_0x1566e3['status'](_0x57d4ad);return _0x1566e3[_0x08fc('0x1b')]('Content-Range',_0x3a54a7+'-'+_0x228e3e+'/'+_0x1dbc13)[_0x08fc('0x17')](_0x553c20);}return null;};}function patchUpdates(_0x1a5ddb){return function(_0x5ba9c0){try{jsonpatch[_0x08fc('0x1c')](_0x5ba9c0,_0x1a5ddb,!![]);}catch(_0x3a6a95){return BPromise['reject'](_0x3a6a95);}return _0x5ba9c0[_0x08fc('0x1d')]();};}function saveUpdates(_0x1f6c53,_0x51561b){return function(_0x2442ef){if(_0x2442ef){return _0x2442ef[_0x08fc('0x1e')](_0x1f6c53)['then'](function(_0x61b801){return _0x61b801;});}return null;};}function removeEntity(_0x4aa4c1,_0x511b52){return function(_0x156570){if(_0x156570){return _0x156570[_0x08fc('0x1f')]()[_0x08fc('0x20')](function(){var _0x3d4fca=_0x156570['get']({'plain':!![]});var _0x42c0c1=_0x08fc('0x21');return db[_0x08fc('0x22')][_0x08fc('0x1f')]({'where':{'type':_0x42c0c1,'resourceId':_0x3d4fca['id']}})['then'](function(){return _0x156570;});})['then'](function(){_0x4aa4c1[_0x08fc('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4a3576,_0x34ec40){return function(_0x2489fb){if(!_0x2489fb){_0x4a3576['sendStatus'](0x194);}return _0x2489fb;};}function handleError(_0x2139e6,_0x25bf3d){_0x25bf3d=_0x25bf3d||0x1f4;return function(_0x228890){logger[_0x08fc('0x23')](_0x228890['stack']);if(_0x228890[_0x08fc('0x24')]){delete _0x228890[_0x08fc('0x24')];}_0x2139e6['status'](_0x25bf3d)['send'](_0x228890);};}exports['index']=function(_0x18c67a,_0x49f894){var _0x49ed4e={},_0x27c2e9={},_0x350630={'count':0x0,'rows':[]};var _0x42f67c=_[_0x08fc('0x25')](db[_0x08fc('0x26')]['rawAttributes'],function(_0x52a2cb){return{'name':_0x52a2cb['fieldName'],'type':_0x52a2cb[_0x08fc('0x27')][_0x08fc('0x28')]};});_0x27c2e9[_0x08fc('0x29')]=_[_0x08fc('0x25')](_0x42f67c,_0x08fc('0x24'));_0x27c2e9[_0x08fc('0x2a')]=_[_0x08fc('0x2b')](_0x18c67a[_0x08fc('0x2a')]);_0x27c2e9['filters']=_['intersection'](_0x27c2e9['model'],_0x27c2e9[_0x08fc('0x2a')]);_0x49ed4e['attributes']=_[_0x08fc('0x2c')](_0x27c2e9[_0x08fc('0x29')],qs[_0x08fc('0x2d')](_0x18c67a[_0x08fc('0x2a')]['fields']));_0x49ed4e[_0x08fc('0x2e')]=_0x49ed4e['attributes']['length']?_0x49ed4e[_0x08fc('0x2e')]:_0x27c2e9[_0x08fc('0x29')];if(!_0x18c67a[_0x08fc('0x2a')][_0x08fc('0x2f')]('nolimit')){_0x49ed4e[_0x08fc('0x1a')]=qs['limit'](_0x18c67a[_0x08fc('0x2a')]['limit']);_0x49ed4e[_0x08fc('0x19')]=qs[_0x08fc('0x19')](_0x18c67a[_0x08fc('0x2a')][_0x08fc('0x19')]);}_0x49ed4e[_0x08fc('0x30')]=qs[_0x08fc('0x31')](_0x18c67a['query']['sort']);_0x49ed4e[_0x08fc('0x32')]=qs[_0x08fc('0x33')](_['pick'](_0x18c67a[_0x08fc('0x2a')],_0x27c2e9[_0x08fc('0x33')]),_0x42f67c);if(_0x18c67a[_0x08fc('0x2a')][_0x08fc('0x34')]){_0x49ed4e['where']=_[_0x08fc('0x35')](_0x49ed4e[_0x08fc('0x32')],{'$or':_[_0x08fc('0x25')](_0x42f67c,function(_0x20a88d){if(_0x20a88d[_0x08fc('0x27')]!==_0x08fc('0x36')){var _0x5a4ce0={};_0x5a4ce0[_0x20a88d['name']]={'$like':'%'+_0x18c67a[_0x08fc('0x2a')][_0x08fc('0x34')]+'%'};return _0x5a4ce0;}})});}_0x49ed4e=_[_0x08fc('0x35')]({},_0x49ed4e,_0x18c67a[_0x08fc('0x37')]);var _0x1e4473={'where':_0x49ed4e[_0x08fc('0x32')]};return db['Sound'][_0x08fc('0x18')](_0x1e4473)[_0x08fc('0x20')](function(_0x438697){_0x350630[_0x08fc('0x18')]=_0x438697;if(_0x18c67a[_0x08fc('0x2a')][_0x08fc('0x38')]){_0x49ed4e[_0x08fc('0x39')]=[{'all':!![]}];}return db[_0x08fc('0x26')]['findAll'](_0x49ed4e);})[_0x08fc('0x20')](function(_0x48bca1){_0x350630[_0x08fc('0x3a')]=_0x48bca1;return _0x350630;})['then'](respondWithFilteredResult(_0x49f894,_0x49ed4e))[_0x08fc('0x3b')](handleError(_0x49f894,null));};exports[_0x08fc('0x3c')]=function(_0x5a68e0,_0x34cfea){var _0x20d470={'raw':!![],'where':{'id':_0x5a68e0[_0x08fc('0x3d')]['id']}},_0x5a19fa={};_0x5a19fa['model']=_[_0x08fc('0x2b')](db[_0x08fc('0x26')][_0x08fc('0x3e')]);_0x5a19fa['query']=_[_0x08fc('0x2b')](_0x5a68e0[_0x08fc('0x2a')]);_0x5a19fa[_0x08fc('0x33')]=_[_0x08fc('0x2c')](_0x5a19fa['model'],_0x5a19fa[_0x08fc('0x2a')]);_0x20d470['attributes']=_[_0x08fc('0x2c')](_0x5a19fa[_0x08fc('0x29')],qs[_0x08fc('0x2d')](_0x5a68e0[_0x08fc('0x2a')][_0x08fc('0x2d')]));_0x20d470[_0x08fc('0x2e')]=_0x20d470[_0x08fc('0x2e')][_0x08fc('0x3f')]?_0x20d470[_0x08fc('0x2e')]:_0x5a19fa[_0x08fc('0x29')];if(_0x5a68e0[_0x08fc('0x2a')][_0x08fc('0x38')]){_0x20d470['include']=[{'all':!![]}];}_0x20d470=_[_0x08fc('0x35')]({},_0x20d470,_0x5a68e0[_0x08fc('0x37')]);return db[_0x08fc('0x26')][_0x08fc('0x40')](_0x20d470)[_0x08fc('0x20')](handleEntityNotFound(_0x34cfea,null))[_0x08fc('0x20')](respondWithResult(_0x34cfea,null))[_0x08fc('0x3b')](handleError(_0x34cfea,null));};exports[_0x08fc('0x41')]=function(_0x19161b,_0x1689d4,_0x43a145){return db[_0x08fc('0x26')][_0x08fc('0x40')]({'where':{'id':_0x19161b[_0x08fc('0x3d')]['id']},'attributes':[_0x08fc('0x24'),_0x08fc('0x42'),_0x08fc('0x43')],'raw':!![]})[_0x08fc('0x20')](handleEntityNotFound(_0x1689d4,null))['then'](function(_0x557611){if(_0x557611){if(!fs['existsSync'](path['join'](config['root'],_0x08fc('0x44'),_0x557611[_0x08fc('0x42')]+'.'+_0x557611['converted_format']))){throw new db[(_0x08fc('0x45'))][(_0x08fc('0x46'))](_0x08fc('0x47'));}return _0x1689d4['download'](path['join'](config[_0x08fc('0x48')],_0x08fc('0x44'),util[_0x08fc('0x49')](_0x08fc('0x4a'),_0x557611[_0x08fc('0x42')],_0x557611[_0x08fc('0x43')])),util['format'](_0x08fc('0x4a'),_0x557611[_0x08fc('0x24')],_0x557611[_0x08fc('0x43')]));}return null;})[_0x08fc('0x3b')](handleError(_0x1689d4,null));};exports['create']=function(_0x2be50b,_0x1484b0,_0x58f58a){var _0x198667={'name':path[_0x08fc('0x4b')](_0x2be50b[_0x08fc('0x4c')][_0x08fc('0x4d')],path['extname'](_0x2be50b[_0x08fc('0x4c')][_0x08fc('0x4d')])),'save_name':path[_0x08fc('0x4b')](_0x2be50b[_0x08fc('0x4c')][_0x08fc('0x4e')],path[_0x08fc('0x4f')](_0x2be50b[_0x08fc('0x4c')]['filename'])),'original_format':path[_0x08fc('0x4f')](_0x2be50b[_0x08fc('0x4c')][_0x08fc('0x4d')])['substring'](0x1),'converted_format':_0x08fc('0x50')};var _0x4233f2=path[_0x08fc('0x51')](config['root'],'server/files/sounds/original',_0x2be50b[_0x08fc('0x4c')]['filename']);var _0x1d8a58=path[_0x08fc('0x51')](config[_0x08fc('0x48')],'server/files/sounds/converted',util[_0x08fc('0x49')]('%s.%s',path[_0x08fc('0x4b')](_0x2be50b[_0x08fc('0x4c')]['filename'],path[_0x08fc('0x4f')](_0x2be50b[_0x08fc('0x4c')][_0x08fc('0x4e')])),_0x198667[_0x08fc('0x43')]));logger['info'](_0x08fc('0x52'),_0x4233f2);logger[_0x08fc('0x53')]('Sound\x20upload\x20destination:\x20%s',_0x1d8a58);try{fs['chmodSync'](_0x4233f2,parseInt('0777',0x8));var _0x3ff160=sox['transcode'](_0x4233f2,_0x1d8a58,{'sampleRate':0x1f40,'format':_0x08fc('0x50'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x3ff160['on'](_0x08fc('0x23'),function(_0xd88ceb){fs[_0x08fc('0x54')](_0x4233f2);_0x1484b0['status'](0x1f4)[_0x08fc('0x55')](_0xd88ceb);});_0x3ff160['on'](_0x08fc('0x56'),function(_0x89a880){_0x198667['original_duration']=isNaN(_0x89a880[_0x08fc('0x57')])?null:_0x89a880[_0x08fc('0x57')]*0x3e8;_0x198667[_0x08fc('0x58')]=isNaN(_0x89a880[_0x08fc('0x59')])?null:_0x89a880['sampleCount'];_0x198667[_0x08fc('0x5a')]=isNaN(_0x89a880[_0x08fc('0x5b')])?null:_0x89a880[_0x08fc('0x5b')];_0x198667[_0x08fc('0x5c')]=isNaN(_0x89a880[_0x08fc('0x5d')])?null:_0x89a880[_0x08fc('0x5d')];_0x198667[_0x08fc('0x5e')]=isNaN(_0x89a880[_0x08fc('0x5f')])?null:_0x89a880[_0x08fc('0x5f')];});_0x3ff160['on'](_0x08fc('0x60'),function(_0x31f520){_0x198667[_0x08fc('0x61')]=isNaN(_0x31f520[_0x08fc('0x57')])?null:_0x31f520['duration']*0x3e8;_0x198667['converted_sampleCount']=isNaN(_0x31f520[_0x08fc('0x59')])?null:_0x31f520[_0x08fc('0x59')];_0x198667[_0x08fc('0x62')]=isNaN(_0x31f520[_0x08fc('0x5b')])?null:_0x31f520[_0x08fc('0x5b')];_0x198667[_0x08fc('0x63')]=isNaN(_0x31f520[_0x08fc('0x5d')])?null:_0x31f520[_0x08fc('0x5d')];_0x198667[_0x08fc('0x64')]=isNaN(_0x31f520[_0x08fc('0x5f')])?null:_0x31f520['sampleRate'];});_0x3ff160['on'](_0x08fc('0x16'),function(){fs['chmodSync'](_0x1d8a58,parseInt(_0x08fc('0x65'),0x8));return db[_0x08fc('0x26')][_0x08fc('0x66')](_0x198667)[_0x08fc('0x20')](function(_0x1d3120){var _0x55408a={'role':_0x2be50b[_0x08fc('0x67')][_0x08fc('0x68')],'userProfileId':_0x2be50b[_0x08fc('0x67')]['userProfileId']};if(!_0x55408a)throw new Error(_0x08fc('0x69'));if(_0x55408a[_0x08fc('0x68')]==='user'){var _0x3531bd=_0x1d3120['get']({'plain':!![]});return db[_0x08fc('0x6a')][_0x08fc('0x40')]({'where':{'name':_0x08fc('0x21'),'userProfileId':_0x55408a[_0x08fc('0x6b')]},'raw':!![]})['then'](function(_0x19399c){if(_0x19399c&&_0x19399c[_0x08fc('0x6c')]===0x0){return db['UserProfileResource']['create']({'name':_0x3531bd['name'],'resourceId':_0x3531bd['id'],'type':_0x19399c['name'],'sectionId':_0x19399c['id']},{})[_0x08fc('0x20')](function(){return _0x1d3120;});}else{return _0x1d3120;}})['catch'](function(_0x309700){logger[_0x08fc('0x23')](_0x08fc('0x6d'),_0x309700);throw _0x309700;});}return _0x1d3120;})[_0x08fc('0x20')](respondWithResult(_0x1484b0,null))[_0x08fc('0x3b')](handleError(_0x1484b0,null));});_0x3ff160[_0x08fc('0x6e')]();}catch(_0x32ff34){_0x1484b0[_0x08fc('0x15')](0x1f4)[_0x08fc('0x55')](_0x32ff34);}};exports['update']=function(_0x4fd2bc,_0x38c9cd,_0x551e1b){return db[_0x08fc('0x26')][_0x08fc('0x40')]({'where':{'id':_0x4fd2bc[_0x08fc('0x3d')]['id']}})[_0x08fc('0x20')](handleEntityNotFound(_0x38c9cd,null))[_0x08fc('0x20')](saveUpdates(_[_0x08fc('0x6f')](_0x4fd2bc['body'],[_0x08fc('0x24'),_0x08fc('0x70')]),null))[_0x08fc('0x20')](respondWithResult(_0x38c9cd,null))[_0x08fc('0x3b')](handleError(_0x38c9cd,null));};exports[_0x08fc('0x71')]=function(_0x4fe490,_0x4a44a6,_0x5ddea4){return db[_0x08fc('0x26')][_0x08fc('0x40')]({'where':{'id':_0x4fe490['params']['id']}})[_0x08fc('0x20')](function(_0x26e279){if(_0x26e279){return _0x26e279[_0x08fc('0x1f')]();}})[_0x08fc('0x20')](function(_0x540763){var _0x537308=path['join'](config[_0x08fc('0x48')],'server/files/sounds/original',util[_0x08fc('0x49')]('%s.%s',_0x540763[_0x08fc('0x42')],_0x540763[_0x08fc('0x72')]));var _0x48c228=path[_0x08fc('0x51')](config['root'],_0x08fc('0x44'),util[_0x08fc('0x49')](_0x08fc('0x4a'),_0x540763[_0x08fc('0x42')],_0x540763[_0x08fc('0x43')]));fs[_0x08fc('0x54')](_0x537308);fs[_0x08fc('0x54')](_0x48c228);return _0x540763;})['then'](function(_0x2f6534){if(_0x2f6534){return _0x4a44a6['status'](0xcc)['end']();}})[_0x08fc('0x20')](handleEntityNotFound(_0x4a44a6,null))[_0x08fc('0x3b')](handleError(_0x4a44a6,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