Built motion from commit f74363e9.|2.6.34
[motion2.git] / server / api / sound / sound.controller.js
index 7e3aee9..98c6907 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf722=['src','original_duration','duration','original_sampleCount','sampleCount','original_channelCount','original_bitRate','bitRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_channelCount','channelCount','converted_bitRate','converted_sampleRate','0777','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','start','description','delete','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','sox','fs-extra','squel','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','update','destroy','then','Sounds','UserProfileResource','error','name','Sound','rawAttributes','fieldName','key','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','download','save_name','converted_format','existsSync','join','root','server/files/sounds/converted','Sequelize','Sound\x20not\x20found','create','basename','file','originalname','extname','filename','substring','wav','format','%s.%s','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','transcode','unlinkSync','send'];(function(_0x3ed136,_0x16fb6b){var _0x45292b=function(_0x42e5b6){while(--_0x42e5b6){_0x3ed136['push'](_0x3ed136['shift']());}};_0x45292b(++_0x16fb6b);}(_0xf722,0x1ed));var _0x2f72=function(_0x5ddb1c,_0x5ea4df){_0x5ddb1c=_0x5ddb1c-0x0;var _0x354adc=_0xf722[_0x5ddb1c];return _0x354adc;};'use strict';var emlformat=require(_0x2f72('0x0'));var rimraf=require(_0x2f72('0x1'));var zipdir=require(_0x2f72('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x2f72('0x3'));var moment=require(_0x2f72('0x4'));var BPromise=require(_0x2f72('0x5'));var Mustache=require(_0x2f72('0x6'));var util=require('util');var path=require('path');var sox=require(_0x2f72('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x2f72('0x8'));var _=require('lodash');var squel=require(_0x2f72('0x9'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x2f72('0xa'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x2f72('0xb'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x2f72('0xc'));var as=require(_0x2f72('0xd'));var hardwareService=require(_0x2f72('0xe'));var logger=require(_0x2f72('0xf'))(_0x2f72('0x10'));var utils=require(_0x2f72('0x11'));var config=require(_0x2f72('0x12'));var licenseUtil=require(_0x2f72('0x13'));var db=require(_0x2f72('0x14'))['db'];function respondWithStatusCode(_0x33dab6,_0x123275){_0x123275=_0x123275||0xcc;return function(_0x3de2c5){if(_0x3de2c5){return _0x33dab6[_0x2f72('0x15')](_0x123275);}return _0x33dab6[_0x2f72('0x16')](_0x123275)[_0x2f72('0x17')]();};}function respondWithResult(_0x24bf42,_0x2d79a1){_0x2d79a1=_0x2d79a1||0xc8;return function(_0x911634){if(_0x911634){return _0x24bf42[_0x2f72('0x16')](_0x2d79a1)[_0x2f72('0x18')](_0x911634);}};}function respondWithFilteredResult(_0x308a3f,_0x2b82b2){return function(_0x378f76){if(_0x378f76){var _0x402ac8=typeof _0x2b82b2[_0x2f72('0x19')]===_0x2f72('0x1a')&&typeof _0x2b82b2[_0x2f72('0x1b')]===_0x2f72('0x1a');var _0x22fa00=_0x378f76[_0x2f72('0x1c')];var _0x44bb71=_0x402ac8?0x0:_0x2b82b2[_0x2f72('0x19')];var _0x23abba=_0x402ac8?_0x378f76[_0x2f72('0x1c')]:_0x2b82b2['offset']+_0x2b82b2[_0x2f72('0x1b')];var _0x587718;if(_0x23abba>=_0x22fa00){_0x23abba=_0x22fa00;_0x587718=0xc8;}else{_0x587718=0xce;}_0x308a3f['status'](_0x587718);return _0x308a3f[_0x2f72('0x1d')](_0x2f72('0x1e'),_0x44bb71+'-'+_0x23abba+'/'+_0x22fa00)[_0x2f72('0x18')](_0x378f76);}return null;};}function patchUpdates(_0x483e5b){return function(_0x35e194){try{jsonpatch[_0x2f72('0x1f')](_0x35e194,_0x483e5b,!![]);}catch(_0x348f72){return BPromise['reject'](_0x348f72);}return _0x35e194['save']();};}function saveUpdates(_0x1c442d,_0x2e43b3){return function(_0x363574){if(_0x363574){return _0x363574[_0x2f72('0x20')](_0x1c442d)['then'](function(_0x3326d7){return _0x3326d7;});}return null;};}function removeEntity(_0x2f427d,_0x1ac77a){return function(_0x104979){if(_0x104979){return _0x104979[_0x2f72('0x21')]()[_0x2f72('0x22')](function(){var _0x2d0cb3=_0x104979['get']({'plain':!![]});var _0x2d015d=_0x2f72('0x23');return db[_0x2f72('0x24')][_0x2f72('0x21')]({'where':{'type':_0x2d015d,'resourceId':_0x2d0cb3['id']}})[_0x2f72('0x22')](function(){return _0x104979;});})['then'](function(){_0x2f427d[_0x2f72('0x16')](0xcc)[_0x2f72('0x17')]();});}};}function handleEntityNotFound(_0x1091d9,_0x542822){return function(_0x41e1bb){if(!_0x41e1bb){_0x1091d9[_0x2f72('0x15')](0x194);}return _0x41e1bb;};}function handleError(_0x497838,_0x253b6e){_0x253b6e=_0x253b6e||0x1f4;return function(_0x22e401){logger[_0x2f72('0x25')](_0x22e401['stack']);if(_0x22e401[_0x2f72('0x26')]){delete _0x22e401[_0x2f72('0x26')];}_0x497838[_0x2f72('0x16')](_0x253b6e)['send'](_0x22e401);};}exports['index']=function(_0x150614,_0x539e31){var _0x42ec67={},_0x1446a7={},_0x27e001={'count':0x0,'rows':[]};var _0x3ca25a=_['map'](db[_0x2f72('0x27')][_0x2f72('0x28')],function(_0x2f9102){return{'name':_0x2f9102[_0x2f72('0x29')],'type':_0x2f9102['type'][_0x2f72('0x2a')]};});_0x1446a7[_0x2f72('0x2b')]=_[_0x2f72('0x2c')](_0x3ca25a,'name');_0x1446a7[_0x2f72('0x2d')]=_[_0x2f72('0x2e')](_0x150614[_0x2f72('0x2d')]);_0x1446a7[_0x2f72('0x2f')]=_[_0x2f72('0x30')](_0x1446a7[_0x2f72('0x2b')],_0x1446a7[_0x2f72('0x2d')]);_0x42ec67[_0x2f72('0x31')]=_[_0x2f72('0x30')](_0x1446a7[_0x2f72('0x2b')],qs[_0x2f72('0x32')](_0x150614['query']['fields']));_0x42ec67[_0x2f72('0x31')]=_0x42ec67[_0x2f72('0x31')]['length']?_0x42ec67['attributes']:_0x1446a7[_0x2f72('0x2b')];if(!_0x150614[_0x2f72('0x2d')][_0x2f72('0x33')](_0x2f72('0x34'))){_0x42ec67['limit']=qs[_0x2f72('0x1b')](_0x150614[_0x2f72('0x2d')][_0x2f72('0x1b')]);_0x42ec67[_0x2f72('0x19')]=qs[_0x2f72('0x19')](_0x150614[_0x2f72('0x2d')][_0x2f72('0x19')]);}_0x42ec67['order']=qs[_0x2f72('0x35')](_0x150614[_0x2f72('0x2d')][_0x2f72('0x35')]);_0x42ec67[_0x2f72('0x36')]=qs[_0x2f72('0x2f')](_[_0x2f72('0x37')](_0x150614[_0x2f72('0x2d')],_0x1446a7[_0x2f72('0x2f')]),_0x3ca25a);if(_0x150614[_0x2f72('0x2d')][_0x2f72('0x38')]){_0x42ec67['where']=_['merge'](_0x42ec67[_0x2f72('0x36')],{'$or':_[_0x2f72('0x2c')](_0x3ca25a,function(_0x379671){if(_0x379671['type']!=='VIRTUAL'){var _0x54c68c={};_0x54c68c[_0x379671[_0x2f72('0x26')]]={'$like':'%'+_0x150614[_0x2f72('0x2d')][_0x2f72('0x38')]+'%'};return _0x54c68c;}})});}_0x42ec67=_[_0x2f72('0x39')]({},_0x42ec67,_0x150614[_0x2f72('0x3a')]);var _0x58af80={'where':_0x42ec67['where']};return db['Sound']['count'](_0x58af80)[_0x2f72('0x22')](function(_0x5b5540){_0x27e001[_0x2f72('0x1c')]=_0x5b5540;if(_0x150614[_0x2f72('0x2d')][_0x2f72('0x3b')]){_0x42ec67[_0x2f72('0x3c')]=[{'all':!![]}];}return db['Sound']['findAll'](_0x42ec67);})['then'](function(_0x4c9a7b){_0x27e001[_0x2f72('0x3d')]=_0x4c9a7b;return _0x27e001;})[_0x2f72('0x22')](respondWithFilteredResult(_0x539e31,_0x42ec67))[_0x2f72('0x3e')](handleError(_0x539e31,null));};exports[_0x2f72('0x3f')]=function(_0x5ce41c,_0x535624){var _0x40b675={'raw':!![],'where':{'id':_0x5ce41c[_0x2f72('0x40')]['id']}},_0xcfde92={};_0xcfde92[_0x2f72('0x2b')]=_[_0x2f72('0x2e')](db[_0x2f72('0x27')][_0x2f72('0x28')]);_0xcfde92[_0x2f72('0x2d')]=_[_0x2f72('0x2e')](_0x5ce41c['query']);_0xcfde92[_0x2f72('0x2f')]=_[_0x2f72('0x30')](_0xcfde92[_0x2f72('0x2b')],_0xcfde92[_0x2f72('0x2d')]);_0x40b675[_0x2f72('0x31')]=_[_0x2f72('0x30')](_0xcfde92[_0x2f72('0x2b')],qs[_0x2f72('0x32')](_0x5ce41c[_0x2f72('0x2d')]['fields']));_0x40b675['attributes']=_0x40b675[_0x2f72('0x31')]['length']?_0x40b675[_0x2f72('0x31')]:_0xcfde92['model'];if(_0x5ce41c[_0x2f72('0x2d')][_0x2f72('0x3b')]){_0x40b675[_0x2f72('0x3c')]=[{'all':!![]}];}_0x40b675=_[_0x2f72('0x39')]({},_0x40b675,_0x5ce41c[_0x2f72('0x3a')]);return db[_0x2f72('0x27')][_0x2f72('0x41')](_0x40b675)[_0x2f72('0x22')](handleEntityNotFound(_0x535624,null))[_0x2f72('0x22')](respondWithResult(_0x535624,null))[_0x2f72('0x3e')](handleError(_0x535624,null));};exports[_0x2f72('0x42')]=function(_0xb088ad,_0x24e619,_0x1285e9){return db[_0x2f72('0x27')][_0x2f72('0x41')]({'where':{'id':_0xb088ad['params']['id']},'attributes':['name',_0x2f72('0x43'),_0x2f72('0x44')],'raw':!![]})['then'](handleEntityNotFound(_0x24e619,null))['then'](function(_0x3a80a9){if(_0x3a80a9){if(!fs[_0x2f72('0x45')](path[_0x2f72('0x46')](config[_0x2f72('0x47')],_0x2f72('0x48'),_0x3a80a9[_0x2f72('0x43')]+'.'+_0x3a80a9[_0x2f72('0x44')]))){throw new db[(_0x2f72('0x49'))]['ValidationError'](_0x2f72('0x4a'));}return _0x24e619[_0x2f72('0x42')](path[_0x2f72('0x46')](config[_0x2f72('0x47')],_0x2f72('0x48'),util['format']('%s.%s',_0x3a80a9[_0x2f72('0x43')],_0x3a80a9[_0x2f72('0x44')])),util['format']('%s.%s',_0x3a80a9[_0x2f72('0x26')],_0x3a80a9[_0x2f72('0x44')]));}return null;})[_0x2f72('0x3e')](handleError(_0x24e619,null));};exports[_0x2f72('0x4b')]=function(_0x24a80c,_0xde9817,_0x14d36c){var _0x47616a={'name':path[_0x2f72('0x4c')](_0x24a80c[_0x2f72('0x4d')][_0x2f72('0x4e')],path[_0x2f72('0x4f')](_0x24a80c['file'][_0x2f72('0x4e')])),'save_name':path[_0x2f72('0x4c')](_0x24a80c[_0x2f72('0x4d')][_0x2f72('0x50')],path['extname'](_0x24a80c[_0x2f72('0x4d')][_0x2f72('0x50')])),'original_format':path[_0x2f72('0x4f')](_0x24a80c['file'][_0x2f72('0x4e')])[_0x2f72('0x51')](0x1),'converted_format':_0x2f72('0x52')};var _0x24671b=path[_0x2f72('0x46')](config[_0x2f72('0x47')],'server/files/sounds/original',_0x24a80c['file'][_0x2f72('0x50')]);var _0x1b7028=path[_0x2f72('0x46')](config[_0x2f72('0x47')],_0x2f72('0x48'),util[_0x2f72('0x53')](_0x2f72('0x54'),path[_0x2f72('0x4c')](_0x24a80c[_0x2f72('0x4d')]['filename'],path[_0x2f72('0x4f')](_0x24a80c[_0x2f72('0x4d')][_0x2f72('0x50')])),_0x47616a[_0x2f72('0x44')]));logger[_0x2f72('0x55')](_0x2f72('0x56'),_0x24671b);logger[_0x2f72('0x55')](_0x2f72('0x57'),_0x1b7028);try{fs[_0x2f72('0x58')](_0x24671b,parseInt('0777',0x8));var _0x1a7b13=sox[_0x2f72('0x59')](_0x24671b,_0x1b7028,{'sampleRate':0x1f40,'format':'wav','channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x1a7b13['on'](_0x2f72('0x25'),function(_0xabb5c){fs[_0x2f72('0x5a')](_0x24671b);_0xde9817['status'](0x1f4)[_0x2f72('0x5b')](_0xabb5c);});_0x1a7b13['on'](_0x2f72('0x5c'),function(_0x48a9f9){_0x47616a[_0x2f72('0x5d')]=isNaN(_0x48a9f9[_0x2f72('0x5e')])?null:_0x48a9f9[_0x2f72('0x5e')]*0x3e8;_0x47616a[_0x2f72('0x5f')]=isNaN(_0x48a9f9['sampleCount'])?null:_0x48a9f9[_0x2f72('0x60')];_0x47616a[_0x2f72('0x61')]=isNaN(_0x48a9f9['channelCount'])?null:_0x48a9f9['channelCount'];_0x47616a[_0x2f72('0x62')]=isNaN(_0x48a9f9[_0x2f72('0x63')])?null:_0x48a9f9[_0x2f72('0x63')];_0x47616a['original_sampleRate']=isNaN(_0x48a9f9['sampleRate'])?null:_0x48a9f9[_0x2f72('0x64')];});_0x1a7b13['on'](_0x2f72('0x65'),function(_0x3d8c63){_0x47616a[_0x2f72('0x66')]=isNaN(_0x3d8c63['duration'])?null:_0x3d8c63[_0x2f72('0x5e')]*0x3e8;_0x47616a[_0x2f72('0x67')]=isNaN(_0x3d8c63[_0x2f72('0x60')])?null:_0x3d8c63[_0x2f72('0x60')];_0x47616a[_0x2f72('0x68')]=isNaN(_0x3d8c63[_0x2f72('0x69')])?null:_0x3d8c63[_0x2f72('0x69')];_0x47616a[_0x2f72('0x6a')]=isNaN(_0x3d8c63[_0x2f72('0x63')])?null:_0x3d8c63[_0x2f72('0x63')];_0x47616a[_0x2f72('0x6b')]=isNaN(_0x3d8c63[_0x2f72('0x64')])?null:_0x3d8c63[_0x2f72('0x64')];});_0x1a7b13['on']('end',function(){fs[_0x2f72('0x58')](_0x1b7028,parseInt(_0x2f72('0x6c'),0x8));return db[_0x2f72('0x27')][_0x2f72('0x4b')](_0x47616a)[_0x2f72('0x22')](function(_0x447e4e){var _0x270ca3={'role':_0x24a80c[_0x2f72('0x6d')][_0x2f72('0x6e')],'userProfileId':_0x24a80c[_0x2f72('0x6d')]['userProfileId']};if(!_0x270ca3)throw new Error(_0x2f72('0x6f'));if(_0x270ca3[_0x2f72('0x6e')]==='user'){var _0x368c51=_0x447e4e['get']({'plain':!![]});return db[_0x2f72('0x70')]['find']({'where':{'name':'Sounds','userProfileId':_0x270ca3[_0x2f72('0x71')]},'raw':!![]})[_0x2f72('0x22')](function(_0x3273a3){if(_0x3273a3&&_0x3273a3['autoAssociation']===0x0){return db[_0x2f72('0x24')][_0x2f72('0x4b')]({'name':_0x368c51['name'],'resourceId':_0x368c51['id'],'type':_0x3273a3[_0x2f72('0x26')],'sectionId':_0x3273a3['id']},{})[_0x2f72('0x22')](function(){return _0x447e4e;});}else{return _0x447e4e;}})[_0x2f72('0x3e')](function(_0x212b92){logger[_0x2f72('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x212b92);throw _0x212b92;});}return _0x447e4e;})['then'](respondWithResult(_0xde9817,null))['catch'](handleError(_0xde9817,null));});_0x1a7b13[_0x2f72('0x72')]();}catch(_0x593360){_0xde9817['status'](0x1f4)[_0x2f72('0x5b')](_0x593360);}};exports['update']=function(_0x1638cb,_0x2417c6,_0x265e06){return db['Sound'][_0x2f72('0x41')]({'where':{'id':_0x1638cb[_0x2f72('0x40')]['id']}})['then'](handleEntityNotFound(_0x2417c6,null))[_0x2f72('0x22')](saveUpdates(_[_0x2f72('0x37')](_0x1638cb[_0x2f72('0x6d')],[_0x2f72('0x26'),_0x2f72('0x73')]),null))[_0x2f72('0x22')](respondWithResult(_0x2417c6,null))[_0x2f72('0x3e')](handleError(_0x2417c6,null));};exports[_0x2f72('0x74')]=function(_0x4d1e15,_0x3cdb9a,_0x15c08a){return db[_0x2f72('0x27')][_0x2f72('0x41')]({'where':{'id':_0x4d1e15[_0x2f72('0x40')]['id']}})[_0x2f72('0x22')](function(_0x48e39a){if(_0x48e39a){return _0x48e39a['destroy']();}})[_0x2f72('0x22')](function(_0x13faec){var _0x43f7eb=path['join'](config[_0x2f72('0x47')],'server/files/sounds/original',util[_0x2f72('0x53')](_0x2f72('0x54'),_0x13faec[_0x2f72('0x43')],_0x13faec['original_format']));var _0x53213c=path[_0x2f72('0x46')](config['root'],_0x2f72('0x48'),util[_0x2f72('0x53')](_0x2f72('0x54'),_0x13faec['save_name'],_0x13faec[_0x2f72('0x44')]));fs['unlinkSync'](_0x43f7eb);fs[_0x2f72('0x5a')](_0x53213c);return _0x13faec;})[_0x2f72('0x22')](function(_0x2c98f6){if(_0x2c98f6){return _0x3cdb9a[_0x2f72('0x16')](0xcc)['end']();}})[_0x2f72('0x22')](handleEntityNotFound(_0x3cdb9a,null))[_0x2f72('0x3e')](handleError(_0x3cdb9a,null));};
\ No newline at end of file
+var _0xaccb=['filename','substring','wav','root','server/files/sounds/original','Sound\x20upload\x20filepath:\x20%s','info','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','unlinkSync','src','duration','original_sampleCount','sampleCount','original_channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','channelCount','converted_bitRate','converted_sampleRate','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','delete','original_format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','get','Sounds','UserProfileResource','destroy','error','name','send','index','map','Sound','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','sort','where','filter','VIRTUAL','merge','options','includeAll','catch','show','params','length','include','find','download','save_name','converted_format','existsSync','join','Sequelize','ValidationError','Sound\x20not\x20found','server/files/sounds/converted','format','%s.%s','create','basename','originalname','extname','file'];(function(_0x2b85c3,_0x132939){var _0x3176f7=function(_0x4be851){while(--_0x4be851){_0x2b85c3['push'](_0x2b85c3['shift']());}};_0x3176f7(++_0x132939);}(_0xaccb,0xa1));var _0xbacc=function(_0x39ccc8,_0x288f6c){_0x39ccc8=_0x39ccc8-0x0;var _0xcf62bd=_0xaccb[_0x39ccc8];return _0xcf62bd;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbacc('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbacc('0x1'));var rp=require(_0xbacc('0x2'));var moment=require(_0xbacc('0x3'));var BPromise=require(_0xbacc('0x4'));var Mustache=require(_0xbacc('0x5'));var util=require(_0xbacc('0x6'));var path=require(_0xbacc('0x7'));var sox=require(_0xbacc('0x8'));var csv=require('to-csv');var ejs=require(_0xbacc('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbacc('0xa'));var squel=require('squel');var crypto=require(_0xbacc('0xb'));var jsforce=require(_0xbacc('0xc'));var deskjs=require(_0xbacc('0xd'));var toCsv=require(_0xbacc('0xe'));var querystring=require(_0xbacc('0xf'));var Papa=require(_0xbacc('0x10'));var Redis=require(_0xbacc('0x11'));var authService=require(_0xbacc('0x12'));var qs=require(_0xbacc('0x13'));var as=require(_0xbacc('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbacc('0x15'))(_0xbacc('0x16'));var utils=require(_0xbacc('0x17'));var config=require(_0xbacc('0x18'));var licenseUtil=require(_0xbacc('0x19'));var db=require(_0xbacc('0x1a'))['db'];function respondWithStatusCode(_0x3495b9,_0x8357a7){_0x8357a7=_0x8357a7||0xcc;return function(_0x12c818){if(_0x12c818){return _0x3495b9[_0xbacc('0x1b')](_0x8357a7);}return _0x3495b9[_0xbacc('0x1c')](_0x8357a7)[_0xbacc('0x1d')]();};}function respondWithResult(_0x593132,_0x18b369){_0x18b369=_0x18b369||0xc8;return function(_0x14ce17){if(_0x14ce17){return _0x593132[_0xbacc('0x1c')](_0x18b369)[_0xbacc('0x1e')](_0x14ce17);}};}function respondWithFilteredResult(_0x4b016d,_0x38429d){return function(_0x1b6e18){if(_0x1b6e18){var _0x5f34e1=typeof _0x38429d[_0xbacc('0x1f')]===_0xbacc('0x20')&&typeof _0x38429d['limit']===_0xbacc('0x20');var _0x26d1d8=_0x1b6e18[_0xbacc('0x21')];var _0xda6fe8=_0x5f34e1?0x0:_0x38429d[_0xbacc('0x1f')];var _0x5ccf92=_0x5f34e1?_0x1b6e18[_0xbacc('0x21')]:_0x38429d[_0xbacc('0x1f')]+_0x38429d[_0xbacc('0x22')];var _0x5235c9;if(_0x5ccf92>=_0x26d1d8){_0x5ccf92=_0x26d1d8;_0x5235c9=0xc8;}else{_0x5235c9=0xce;}_0x4b016d['status'](_0x5235c9);return _0x4b016d[_0xbacc('0x23')](_0xbacc('0x24'),_0xda6fe8+'-'+_0x5ccf92+'/'+_0x26d1d8)[_0xbacc('0x1e')](_0x1b6e18);}return null;};}function patchUpdates(_0x3a12fc){return function(_0x1a9dae){try{jsonpatch[_0xbacc('0x25')](_0x1a9dae,_0x3a12fc,!![]);}catch(_0x473a28){return BPromise[_0xbacc('0x26')](_0x473a28);}return _0x1a9dae[_0xbacc('0x27')]();};}function saveUpdates(_0x2b1610,_0x230bfb){return function(_0x1e09dc){if(_0x1e09dc){return _0x1e09dc[_0xbacc('0x28')](_0x2b1610)[_0xbacc('0x29')](function(_0x321c72){return _0x321c72;});}return null;};}function removeEntity(_0x42b0d3,_0x374090){return function(_0x4ba0d9){if(_0x4ba0d9){return _0x4ba0d9['destroy']()[_0xbacc('0x29')](function(){var _0x40cb19=_0x4ba0d9[_0xbacc('0x2a')]({'plain':!![]});var _0x372acd=_0xbacc('0x2b');return db[_0xbacc('0x2c')][_0xbacc('0x2d')]({'where':{'type':_0x372acd,'resourceId':_0x40cb19['id']}})[_0xbacc('0x29')](function(){return _0x4ba0d9;});})['then'](function(){_0x42b0d3[_0xbacc('0x1c')](0xcc)[_0xbacc('0x1d')]();});}};}function handleEntityNotFound(_0x55adf3,_0x43b03c){return function(_0x12be12){if(!_0x12be12){_0x55adf3[_0xbacc('0x1b')](0x194);}return _0x12be12;};}function handleError(_0x3fe33e,_0x130d50){_0x130d50=_0x130d50||0x1f4;return function(_0x872580){logger[_0xbacc('0x2e')](_0x872580['stack']);if(_0x872580[_0xbacc('0x2f')]){delete _0x872580[_0xbacc('0x2f')];}_0x3fe33e[_0xbacc('0x1c')](_0x130d50)[_0xbacc('0x30')](_0x872580);};}exports[_0xbacc('0x31')]=function(_0xa581aa,_0x2d5533){var _0x3d274e={},_0x2080cc={},_0x2b2b4f={'count':0x0,'rows':[]};var _0x330da2=_[_0xbacc('0x32')](db[_0xbacc('0x33')][_0xbacc('0x34')],function(_0x3d6731){return{'name':_0x3d6731[_0xbacc('0x35')],'type':_0x3d6731[_0xbacc('0x36')][_0xbacc('0x37')]};});_0x2080cc[_0xbacc('0x38')]=_[_0xbacc('0x32')](_0x330da2,_0xbacc('0x2f'));_0x2080cc[_0xbacc('0x39')]=_[_0xbacc('0x3a')](_0xa581aa[_0xbacc('0x39')]);_0x2080cc[_0xbacc('0x3b')]=_[_0xbacc('0x3c')](_0x2080cc[_0xbacc('0x38')],_0x2080cc[_0xbacc('0x39')]);_0x3d274e['attributes']=_[_0xbacc('0x3c')](_0x2080cc[_0xbacc('0x38')],qs[_0xbacc('0x3d')](_0xa581aa[_0xbacc('0x39')]['fields']));_0x3d274e[_0xbacc('0x3e')]=_0x3d274e[_0xbacc('0x3e')]['length']?_0x3d274e[_0xbacc('0x3e')]:_0x2080cc[_0xbacc('0x38')];if(!_0xa581aa['query']['hasOwnProperty'](_0xbacc('0x3f'))){_0x3d274e[_0xbacc('0x22')]=qs[_0xbacc('0x22')](_0xa581aa['query'][_0xbacc('0x22')]);_0x3d274e[_0xbacc('0x1f')]=qs[_0xbacc('0x1f')](_0xa581aa[_0xbacc('0x39')]['offset']);}_0x3d274e['order']=qs[_0xbacc('0x40')](_0xa581aa[_0xbacc('0x39')][_0xbacc('0x40')]);_0x3d274e[_0xbacc('0x41')]=qs[_0xbacc('0x3b')](_['pick'](_0xa581aa[_0xbacc('0x39')],_0x2080cc[_0xbacc('0x3b')]),_0x330da2);if(_0xa581aa[_0xbacc('0x39')][_0xbacc('0x42')]){_0x3d274e[_0xbacc('0x41')]=_['merge'](_0x3d274e[_0xbacc('0x41')],{'$or':_['map'](_0x330da2,function(_0x18c1ad){if(_0x18c1ad[_0xbacc('0x36')]!==_0xbacc('0x43')){var _0x3741f4={};_0x3741f4[_0x18c1ad[_0xbacc('0x2f')]]={'$like':'%'+_0xa581aa[_0xbacc('0x39')][_0xbacc('0x42')]+'%'};return _0x3741f4;}})});}_0x3d274e=_[_0xbacc('0x44')]({},_0x3d274e,_0xa581aa[_0xbacc('0x45')]);var _0x51525a={'where':_0x3d274e['where']};return db[_0xbacc('0x33')][_0xbacc('0x21')](_0x51525a)[_0xbacc('0x29')](function(_0x299a9d){_0x2b2b4f['count']=_0x299a9d;if(_0xa581aa[_0xbacc('0x39')][_0xbacc('0x46')]){_0x3d274e['include']=[{'all':!![]}];}return db[_0xbacc('0x33')]['findAll'](_0x3d274e);})[_0xbacc('0x29')](function(_0x43023e){_0x2b2b4f['rows']=_0x43023e;return _0x2b2b4f;})[_0xbacc('0x29')](respondWithFilteredResult(_0x2d5533,_0x3d274e))[_0xbacc('0x47')](handleError(_0x2d5533,null));};exports[_0xbacc('0x48')]=function(_0x4a9a42,_0x49c6cb){var _0xedc5f0={'raw':!![],'where':{'id':_0x4a9a42[_0xbacc('0x49')]['id']}},_0x4aafe7={};_0x4aafe7[_0xbacc('0x38')]=_[_0xbacc('0x3a')](db['Sound'][_0xbacc('0x34')]);_0x4aafe7[_0xbacc('0x39')]=_[_0xbacc('0x3a')](_0x4a9a42[_0xbacc('0x39')]);_0x4aafe7[_0xbacc('0x3b')]=_[_0xbacc('0x3c')](_0x4aafe7[_0xbacc('0x38')],_0x4aafe7[_0xbacc('0x39')]);_0xedc5f0[_0xbacc('0x3e')]=_[_0xbacc('0x3c')](_0x4aafe7[_0xbacc('0x38')],qs['fields'](_0x4a9a42[_0xbacc('0x39')][_0xbacc('0x3d')]));_0xedc5f0[_0xbacc('0x3e')]=_0xedc5f0['attributes'][_0xbacc('0x4a')]?_0xedc5f0[_0xbacc('0x3e')]:_0x4aafe7[_0xbacc('0x38')];if(_0x4a9a42['query'][_0xbacc('0x46')]){_0xedc5f0[_0xbacc('0x4b')]=[{'all':!![]}];}_0xedc5f0=_[_0xbacc('0x44')]({},_0xedc5f0,_0x4a9a42[_0xbacc('0x45')]);return db[_0xbacc('0x33')][_0xbacc('0x4c')](_0xedc5f0)[_0xbacc('0x29')](handleEntityNotFound(_0x49c6cb,null))[_0xbacc('0x29')](respondWithResult(_0x49c6cb,null))[_0xbacc('0x47')](handleError(_0x49c6cb,null));};exports[_0xbacc('0x4d')]=function(_0x47cb88,_0x4d5c28,_0x20a75f){return db[_0xbacc('0x33')][_0xbacc('0x4c')]({'where':{'id':_0x47cb88['params']['id']},'attributes':[_0xbacc('0x2f'),_0xbacc('0x4e'),_0xbacc('0x4f')],'raw':!![]})['then'](handleEntityNotFound(_0x4d5c28,null))[_0xbacc('0x29')](function(_0x241ee6){if(_0x241ee6){if(!fs[_0xbacc('0x50')](path[_0xbacc('0x51')](config['root'],'server/files/sounds/converted',_0x241ee6[_0xbacc('0x4e')]+'.'+_0x241ee6['converted_format']))){throw new db[(_0xbacc('0x52'))][(_0xbacc('0x53'))](_0xbacc('0x54'));}return _0x4d5c28['download'](path[_0xbacc('0x51')](config['root'],_0xbacc('0x55'),util[_0xbacc('0x56')]('%s.%s',_0x241ee6[_0xbacc('0x4e')],_0x241ee6[_0xbacc('0x4f')])),util[_0xbacc('0x56')](_0xbacc('0x57'),_0x241ee6[_0xbacc('0x2f')],_0x241ee6[_0xbacc('0x4f')]));}return null;})['catch'](handleError(_0x4d5c28,null));};exports[_0xbacc('0x58')]=function(_0x32a96a,_0x3369e9,_0x1ad314){var _0x68ba93={'name':path[_0xbacc('0x59')](_0x32a96a['file'][_0xbacc('0x5a')],path[_0xbacc('0x5b')](_0x32a96a[_0xbacc('0x5c')][_0xbacc('0x5a')])),'save_name':path[_0xbacc('0x59')](_0x32a96a[_0xbacc('0x5c')][_0xbacc('0x5d')],path[_0xbacc('0x5b')](_0x32a96a[_0xbacc('0x5c')][_0xbacc('0x5d')])),'original_format':path[_0xbacc('0x5b')](_0x32a96a[_0xbacc('0x5c')][_0xbacc('0x5a')])[_0xbacc('0x5e')](0x1),'converted_format':_0xbacc('0x5f')};var _0x3c0b06=path[_0xbacc('0x51')](config[_0xbacc('0x60')],_0xbacc('0x61'),_0x32a96a[_0xbacc('0x5c')][_0xbacc('0x5d')]);var _0x292c67=path[_0xbacc('0x51')](config['root'],_0xbacc('0x55'),util[_0xbacc('0x56')](_0xbacc('0x57'),path[_0xbacc('0x59')](_0x32a96a[_0xbacc('0x5c')]['filename'],path[_0xbacc('0x5b')](_0x32a96a[_0xbacc('0x5c')]['filename'])),_0x68ba93[_0xbacc('0x4f')]));logger['info'](_0xbacc('0x62'),_0x3c0b06);logger[_0xbacc('0x63')](_0xbacc('0x64'),_0x292c67);try{fs[_0xbacc('0x65')](_0x3c0b06,parseInt(_0xbacc('0x66'),0x8));var _0x590082=sox['transcode'](_0x3c0b06,_0x292c67,{'sampleRate':0x1f40,'format':_0xbacc('0x5f'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x590082['on'](_0xbacc('0x2e'),function(_0x27a256){fs[_0xbacc('0x67')](_0x3c0b06);_0x3369e9[_0xbacc('0x1c')](0x1f4)[_0xbacc('0x30')](_0x27a256);});_0x590082['on'](_0xbacc('0x68'),function(_0x29b406){_0x68ba93['original_duration']=isNaN(_0x29b406[_0xbacc('0x69')])?null:_0x29b406[_0xbacc('0x69')]*0x3e8;_0x68ba93[_0xbacc('0x6a')]=isNaN(_0x29b406[_0xbacc('0x6b')])?null:_0x29b406['sampleCount'];_0x68ba93[_0xbacc('0x6c')]=isNaN(_0x29b406['channelCount'])?null:_0x29b406['channelCount'];_0x68ba93[_0xbacc('0x6d')]=isNaN(_0x29b406[_0xbacc('0x6e')])?null:_0x29b406[_0xbacc('0x6e')];_0x68ba93[_0xbacc('0x6f')]=isNaN(_0x29b406[_0xbacc('0x70')])?null:_0x29b406[_0xbacc('0x70')];});_0x590082['on']('dest',function(_0x45b298){_0x68ba93['converted_duration']=isNaN(_0x45b298[_0xbacc('0x69')])?null:_0x45b298[_0xbacc('0x69')]*0x3e8;_0x68ba93['converted_sampleCount']=isNaN(_0x45b298[_0xbacc('0x6b')])?null:_0x45b298['sampleCount'];_0x68ba93['converted_channelCount']=isNaN(_0x45b298[_0xbacc('0x71')])?null:_0x45b298['channelCount'];_0x68ba93[_0xbacc('0x72')]=isNaN(_0x45b298[_0xbacc('0x6e')])?null:_0x45b298[_0xbacc('0x6e')];_0x68ba93[_0xbacc('0x73')]=isNaN(_0x45b298[_0xbacc('0x70')])?null:_0x45b298['sampleRate'];});_0x590082['on']('end',function(){fs[_0xbacc('0x65')](_0x292c67,parseInt('0777',0x8));return db[_0xbacc('0x33')][_0xbacc('0x58')](_0x68ba93)[_0xbacc('0x29')](function(_0x35e4d3){var _0x160c7f={'role':_0x32a96a[_0xbacc('0x74')][_0xbacc('0x75')],'userProfileId':_0x32a96a['body'][_0xbacc('0x76')]};if(!_0x160c7f)throw new Error(_0xbacc('0x77'));if(_0x160c7f[_0xbacc('0x75')]===_0xbacc('0x78')){var _0x1294f9=_0x35e4d3[_0xbacc('0x2a')]({'plain':!![]});return db[_0xbacc('0x79')][_0xbacc('0x4c')]({'where':{'name':'Sounds','userProfileId':_0x160c7f['userProfileId']},'raw':!![]})[_0xbacc('0x29')](function(_0x14083e){if(_0x14083e&&_0x14083e[_0xbacc('0x7a')]===0x0){return db[_0xbacc('0x2c')][_0xbacc('0x58')]({'name':_0x1294f9[_0xbacc('0x2f')],'resourceId':_0x1294f9['id'],'type':_0x14083e[_0xbacc('0x2f')],'sectionId':_0x14083e['id']},{})[_0xbacc('0x29')](function(){return _0x35e4d3;});}else{return _0x35e4d3;}})[_0xbacc('0x47')](function(_0x5381c8){logger[_0xbacc('0x2e')](_0xbacc('0x7b'),_0x5381c8);throw _0x5381c8;});}return _0x35e4d3;})['then'](respondWithResult(_0x3369e9,null))[_0xbacc('0x47')](handleError(_0x3369e9,null));});_0x590082[_0xbacc('0x7c')]();}catch(_0x17c73c){_0x3369e9['status'](0x1f4)['send'](_0x17c73c);}};exports[_0xbacc('0x28')]=function(_0x4642e2,_0x3b37e3,_0x5d71cf){return db[_0xbacc('0x33')]['find']({'where':{'id':_0x4642e2['params']['id']}})[_0xbacc('0x29')](handleEntityNotFound(_0x3b37e3,null))[_0xbacc('0x29')](saveUpdates(_['pick'](_0x4642e2[_0xbacc('0x74')],['name','description']),null))['then'](respondWithResult(_0x3b37e3,null))[_0xbacc('0x47')](handleError(_0x3b37e3,null));};exports[_0xbacc('0x7d')]=function(_0x2203ed,_0x49e194,_0x481615){return db[_0xbacc('0x33')][_0xbacc('0x4c')]({'where':{'id':_0x2203ed[_0xbacc('0x49')]['id']}})['then'](function(_0x5363fc){if(_0x5363fc){return _0x5363fc[_0xbacc('0x2d')]();}})['then'](function(_0x55e7a7){var _0x156d9d=path[_0xbacc('0x51')](config[_0xbacc('0x60')],'server/files/sounds/original',util[_0xbacc('0x56')](_0xbacc('0x57'),_0x55e7a7[_0xbacc('0x4e')],_0x55e7a7[_0xbacc('0x7e')]));var _0x4e99c3=path['join'](config[_0xbacc('0x60')],_0xbacc('0x55'),util[_0xbacc('0x56')](_0xbacc('0x57'),_0x55e7a7['save_name'],_0x55e7a7['converted_format']));fs[_0xbacc('0x67')](_0x156d9d);fs[_0xbacc('0x67')](_0x4e99c3);return _0x55e7a7;})['then'](function(_0x43b417){if(_0x43b417){return _0x49e194[_0xbacc('0x1c')](0xcc)[_0xbacc('0x1d')]();}})['then'](handleEntityNotFound(_0x49e194,null))['catch'](handleError(_0x49e194,null));};
\ No newline at end of file