Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / api / sound / sound.controller.js
index 51443e5..21ae50c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7b81=['ioredis','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','update','destroy','then','get','Sounds','UserProfileResource','error','name','send','index','map','Sound','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','keys','find','catch','download','save_name','join','root','converted_format','Sound\x20not\x20found','format','%s.%s','basename','file','originalname','filename','extname','wav','server/files/sounds/original','server/files/sounds/converted','info','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','src','original_duration','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','bitRate','sampleRate','converted_duration','converted_sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','pick','description','delete','original_format','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x7b81,0x167));var _0x17b8=function(_0x266378,_0x477398){_0x266378=_0x266378-0x0;var _0x5c26e9=_0x7b81[_0x266378];return _0x5c26e9;};'use strict';var emlformat=require(_0x17b8('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x17b8('0x1'));var jsonpatch=require(_0x17b8('0x2'));var rp=require(_0x17b8('0x3'));var moment=require(_0x17b8('0x4'));var BPromise=require(_0x17b8('0x5'));var Mustache=require('mustache');var util=require(_0x17b8('0x6'));var path=require(_0x17b8('0x7'));var sox=require(_0x17b8('0x8'));var csv=require(_0x17b8('0x9'));var ejs=require(_0x17b8('0xa'));var fs=require('fs');var fs_extra=require(_0x17b8('0xb'));var _=require(_0x17b8('0xc'));var squel=require(_0x17b8('0xd'));var crypto=require(_0x17b8('0xe'));var jsforce=require(_0x17b8('0xf'));var deskjs=require(_0x17b8('0x10'));var toCsv=require(_0x17b8('0x9'));var querystring=require(_0x17b8('0x11'));var Papa=require(_0x17b8('0x12'));var Redis=require(_0x17b8('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x17b8('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x17b8('0x15'))('api');var utils=require(_0x17b8('0x16'));var config=require(_0x17b8('0x17'));var licenseUtil=require(_0x17b8('0x18'));var db=require(_0x17b8('0x19'))['db'];function respondWithStatusCode(_0x4bc13f,_0xbcdb5d){_0xbcdb5d=_0xbcdb5d||0xcc;return function(_0x35fac4){if(_0x35fac4){return _0x4bc13f[_0x17b8('0x1a')](_0xbcdb5d);}return _0x4bc13f[_0x17b8('0x1b')](_0xbcdb5d)[_0x17b8('0x1c')]();};}function respondWithResult(_0x184202,_0x526322){_0x526322=_0x526322||0xc8;return function(_0x39b2f6){if(_0x39b2f6){return _0x184202[_0x17b8('0x1b')](_0x526322)[_0x17b8('0x1d')](_0x39b2f6);}};}function respondWithFilteredResult(_0x16a515,_0x240d0c){return function(_0x36f8f4){if(_0x36f8f4){var _0x130c61=typeof _0x240d0c[_0x17b8('0x1e')]===_0x17b8('0x1f')&&typeof _0x240d0c[_0x17b8('0x20')]===_0x17b8('0x1f');var _0x59f083=_0x36f8f4['count'];var _0x237fed=_0x130c61?0x0:_0x240d0c[_0x17b8('0x1e')];var _0x42fada=_0x130c61?_0x36f8f4[_0x17b8('0x21')]:_0x240d0c[_0x17b8('0x1e')]+_0x240d0c[_0x17b8('0x20')];var _0x1124cf;if(_0x42fada>=_0x59f083){_0x42fada=_0x59f083;_0x1124cf=0xc8;}else{_0x1124cf=0xce;}_0x16a515[_0x17b8('0x1b')](_0x1124cf);return _0x16a515[_0x17b8('0x22')]('Content-Range',_0x237fed+'-'+_0x42fada+'/'+_0x59f083)[_0x17b8('0x1d')](_0x36f8f4);}return null;};}function patchUpdates(_0x2c46d4){return function(_0x9e5a0e){try{jsonpatch[_0x17b8('0x23')](_0x9e5a0e,_0x2c46d4,!![]);}catch(_0x4f4a36){return BPromise[_0x17b8('0x24')](_0x4f4a36);}return _0x9e5a0e['save']();};}function saveUpdates(_0x17fb50,_0x3e8ee3){return function(_0x30737f){if(_0x30737f){return _0x30737f[_0x17b8('0x25')](_0x17fb50)['then'](function(_0x3aea7e){return _0x3aea7e;});}return null;};}function removeEntity(_0x1d64f3,_0x2e9615){return function(_0x5b0932){if(_0x5b0932){return _0x5b0932[_0x17b8('0x26')]()[_0x17b8('0x27')](function(){var _0x5d47e6=_0x5b0932[_0x17b8('0x28')]({'plain':!![]});var _0x401805=_0x17b8('0x29');return db[_0x17b8('0x2a')]['destroy']({'where':{'type':_0x401805,'resourceId':_0x5d47e6['id']}})['then'](function(){return _0x5b0932;});})['then'](function(){_0x1d64f3['status'](0xcc)[_0x17b8('0x1c')]();});}};}function handleEntityNotFound(_0x264120,_0x43273d){return function(_0x487d73){if(!_0x487d73){_0x264120[_0x17b8('0x1a')](0x194);}return _0x487d73;};}function handleError(_0x368e4f,_0x378502){_0x378502=_0x378502||0x1f4;return function(_0x41e38f){logger[_0x17b8('0x2b')](_0x41e38f['stack']);if(_0x41e38f[_0x17b8('0x2c')]){delete _0x41e38f[_0x17b8('0x2c')];}_0x368e4f[_0x17b8('0x1b')](_0x378502)[_0x17b8('0x2d')](_0x41e38f);};}exports[_0x17b8('0x2e')]=function(_0x596cbf,_0x285b85){var _0x4da139={},_0x44bd1a={},_0x52f18a={'count':0x0,'rows':[]};var _0x2467f8=_[_0x17b8('0x2f')](db[_0x17b8('0x30')][_0x17b8('0x31')],function(_0x8a2f67){return{'name':_0x8a2f67[_0x17b8('0x32')],'type':_0x8a2f67[_0x17b8('0x33')][_0x17b8('0x34')]};});_0x44bd1a[_0x17b8('0x35')]=_['map'](_0x2467f8,_0x17b8('0x2c'));_0x44bd1a[_0x17b8('0x36')]=_['keys'](_0x596cbf[_0x17b8('0x36')]);_0x44bd1a[_0x17b8('0x37')]=_[_0x17b8('0x38')](_0x44bd1a[_0x17b8('0x35')],_0x44bd1a[_0x17b8('0x36')]);_0x4da139[_0x17b8('0x39')]=_[_0x17b8('0x38')](_0x44bd1a[_0x17b8('0x35')],qs[_0x17b8('0x3a')](_0x596cbf[_0x17b8('0x36')]['fields']));_0x4da139[_0x17b8('0x39')]=_0x4da139['attributes'][_0x17b8('0x3b')]?_0x4da139['attributes']:_0x44bd1a[_0x17b8('0x35')];if(!_0x596cbf[_0x17b8('0x36')][_0x17b8('0x3c')](_0x17b8('0x3d'))){_0x4da139[_0x17b8('0x20')]=qs[_0x17b8('0x20')](_0x596cbf[_0x17b8('0x36')][_0x17b8('0x20')]);_0x4da139[_0x17b8('0x1e')]=qs['offset'](_0x596cbf[_0x17b8('0x36')][_0x17b8('0x1e')]);}_0x4da139[_0x17b8('0x3e')]=qs[_0x17b8('0x3f')](_0x596cbf[_0x17b8('0x36')][_0x17b8('0x3f')]);_0x4da139['where']=qs[_0x17b8('0x37')](_['pick'](_0x596cbf['query'],_0x44bd1a[_0x17b8('0x37')]),_0x2467f8);if(_0x596cbf[_0x17b8('0x36')][_0x17b8('0x40')]){_0x4da139[_0x17b8('0x41')]=_[_0x17b8('0x42')](_0x4da139[_0x17b8('0x41')],{'$or':_[_0x17b8('0x2f')](_0x2467f8,function(_0x23a9fb){if(_0x23a9fb[_0x17b8('0x33')]!==_0x17b8('0x43')){var _0x4bd76a={};_0x4bd76a[_0x23a9fb[_0x17b8('0x2c')]]={'$like':'%'+_0x596cbf[_0x17b8('0x36')]['filter']+'%'};return _0x4bd76a;}})});}_0x4da139=_['merge']({},_0x4da139,_0x596cbf[_0x17b8('0x44')]);var _0x57a0eb={'where':_0x4da139[_0x17b8('0x41')]};return db[_0x17b8('0x30')][_0x17b8('0x21')](_0x57a0eb)[_0x17b8('0x27')](function(_0x723a94){_0x52f18a[_0x17b8('0x21')]=_0x723a94;if(_0x596cbf[_0x17b8('0x36')][_0x17b8('0x45')]){_0x4da139[_0x17b8('0x46')]=[{'all':!![]}];}return db[_0x17b8('0x30')][_0x17b8('0x47')](_0x4da139);})[_0x17b8('0x27')](function(_0x5c6e77){_0x52f18a[_0x17b8('0x48')]=_0x5c6e77;return _0x52f18a;})['then'](respondWithFilteredResult(_0x285b85,_0x4da139))['catch'](handleError(_0x285b85,null));};exports['show']=function(_0x51291d,_0x4c4e10){var _0x12ef0d={'raw':!![],'where':{'id':_0x51291d[_0x17b8('0x49')]['id']}},_0x33f9c4={};_0x33f9c4[_0x17b8('0x35')]=_[_0x17b8('0x4a')](db[_0x17b8('0x30')]['rawAttributes']);_0x33f9c4['query']=_[_0x17b8('0x4a')](_0x51291d[_0x17b8('0x36')]);_0x33f9c4[_0x17b8('0x37')]=_['intersection'](_0x33f9c4[_0x17b8('0x35')],_0x33f9c4[_0x17b8('0x36')]);_0x12ef0d[_0x17b8('0x39')]=_[_0x17b8('0x38')](_0x33f9c4['model'],qs[_0x17b8('0x3a')](_0x51291d[_0x17b8('0x36')]['fields']));_0x12ef0d['attributes']=_0x12ef0d['attributes'][_0x17b8('0x3b')]?_0x12ef0d[_0x17b8('0x39')]:_0x33f9c4[_0x17b8('0x35')];if(_0x51291d[_0x17b8('0x36')][_0x17b8('0x45')]){_0x12ef0d[_0x17b8('0x46')]=[{'all':!![]}];}_0x12ef0d=_[_0x17b8('0x42')]({},_0x12ef0d,_0x51291d[_0x17b8('0x44')]);return db[_0x17b8('0x30')][_0x17b8('0x4b')](_0x12ef0d)['then'](handleEntityNotFound(_0x4c4e10,null))[_0x17b8('0x27')](respondWithResult(_0x4c4e10,null))[_0x17b8('0x4c')](handleError(_0x4c4e10,null));};exports[_0x17b8('0x4d')]=function(_0x348bc6,_0x4fe915,_0x269faa){return db['Sound'][_0x17b8('0x4b')]({'where':{'id':_0x348bc6[_0x17b8('0x49')]['id']},'attributes':[_0x17b8('0x2c'),_0x17b8('0x4e'),'converted_format'],'raw':!![]})[_0x17b8('0x27')](handleEntityNotFound(_0x4fe915,null))[_0x17b8('0x27')](function(_0x3b95eb){if(_0x3b95eb){if(!fs['existsSync'](path[_0x17b8('0x4f')](config[_0x17b8('0x50')],'server/files/sounds/converted',_0x3b95eb['save_name']+'.'+_0x3b95eb[_0x17b8('0x51')]))){throw new db['Sequelize']['ValidationError'](_0x17b8('0x52'));}return _0x4fe915[_0x17b8('0x4d')](path['join'](config[_0x17b8('0x50')],'server/files/sounds/converted',util[_0x17b8('0x53')]('%s.%s',_0x3b95eb['save_name'],_0x3b95eb['converted_format'])),util[_0x17b8('0x53')](_0x17b8('0x54'),_0x3b95eb[_0x17b8('0x2c')],_0x3b95eb[_0x17b8('0x51')]));}return null;})['catch'](handleError(_0x4fe915,null));};exports['create']=function(_0x257552,_0xc7aa01,_0x3ae4e8){var _0x27e45b={'name':path[_0x17b8('0x55')](_0x257552[_0x17b8('0x56')][_0x17b8('0x57')],path['extname'](_0x257552[_0x17b8('0x56')]['originalname'])),'save_name':path[_0x17b8('0x55')](_0x257552[_0x17b8('0x56')][_0x17b8('0x58')],path['extname'](_0x257552[_0x17b8('0x56')][_0x17b8('0x58')])),'original_format':path[_0x17b8('0x59')](_0x257552[_0x17b8('0x56')][_0x17b8('0x57')])['substring'](0x1),'converted_format':_0x17b8('0x5a')};var _0x109602=path[_0x17b8('0x4f')](config[_0x17b8('0x50')],_0x17b8('0x5b'),_0x257552[_0x17b8('0x56')]['filename']);var _0x4c2f40=path[_0x17b8('0x4f')](config[_0x17b8('0x50')],_0x17b8('0x5c'),util[_0x17b8('0x53')](_0x17b8('0x54'),path[_0x17b8('0x55')](_0x257552[_0x17b8('0x56')]['filename'],path[_0x17b8('0x59')](_0x257552[_0x17b8('0x56')][_0x17b8('0x58')])),_0x27e45b[_0x17b8('0x51')]));logger[_0x17b8('0x5d')]('Sound\x20upload\x20filepath:\x20%s',_0x109602);logger['info'](_0x17b8('0x5e'),_0x4c2f40);try{fs[_0x17b8('0x5f')](_0x109602,parseInt(_0x17b8('0x60'),0x8));var _0x210329=sox[_0x17b8('0x61')](_0x109602,_0x4c2f40,{'sampleRate':0x1f40,'format':_0x17b8('0x5a'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x210329['on'](_0x17b8('0x2b'),function(_0x32286c){fs[_0x17b8('0x62')](_0x109602);_0xc7aa01['status'](0x1f4)[_0x17b8('0x2d')](_0x32286c);});_0x210329['on'](_0x17b8('0x63'),function(_0x2b6aaf){_0x27e45b[_0x17b8('0x64')]=isNaN(_0x2b6aaf[_0x17b8('0x65')])?null:_0x2b6aaf[_0x17b8('0x65')]*0x3e8;_0x27e45b[_0x17b8('0x66')]=isNaN(_0x2b6aaf[_0x17b8('0x67')])?null:_0x2b6aaf['sampleCount'];_0x27e45b[_0x17b8('0x68')]=isNaN(_0x2b6aaf[_0x17b8('0x69')])?null:_0x2b6aaf['channelCount'];_0x27e45b['original_bitRate']=isNaN(_0x2b6aaf[_0x17b8('0x6a')])?null:_0x2b6aaf[_0x17b8('0x6a')];_0x27e45b['original_sampleRate']=isNaN(_0x2b6aaf[_0x17b8('0x6b')])?null:_0x2b6aaf[_0x17b8('0x6b')];});_0x210329['on']('dest',function(_0x2e9b4e){_0x27e45b[_0x17b8('0x6c')]=isNaN(_0x2e9b4e[_0x17b8('0x65')])?null:_0x2e9b4e[_0x17b8('0x65')]*0x3e8;_0x27e45b[_0x17b8('0x6d')]=isNaN(_0x2e9b4e[_0x17b8('0x67')])?null:_0x2e9b4e[_0x17b8('0x67')];_0x27e45b[_0x17b8('0x6e')]=isNaN(_0x2e9b4e[_0x17b8('0x69')])?null:_0x2e9b4e[_0x17b8('0x69')];_0x27e45b[_0x17b8('0x6f')]=isNaN(_0x2e9b4e[_0x17b8('0x6a')])?null:_0x2e9b4e[_0x17b8('0x6a')];_0x27e45b[_0x17b8('0x70')]=isNaN(_0x2e9b4e['sampleRate'])?null:_0x2e9b4e['sampleRate'];});_0x210329['on'](_0x17b8('0x1c'),function(){fs['chmodSync'](_0x4c2f40,parseInt('0777',0x8));return db['Sound'][_0x17b8('0x71')](_0x27e45b)[_0x17b8('0x27')](function(_0xebb025){var _0x17a6c5={'role':_0x257552[_0x17b8('0x72')][_0x17b8('0x73')],'userProfileId':_0x257552[_0x17b8('0x72')][_0x17b8('0x74')]};if(!_0x17a6c5)throw new Error(_0x17b8('0x75'));if(_0x17a6c5[_0x17b8('0x73')]==='user'){var _0x43d40b=_0xebb025[_0x17b8('0x28')]({'plain':!![]});return db[_0x17b8('0x76')][_0x17b8('0x4b')]({'where':{'name':_0x17b8('0x29'),'userProfileId':_0x17a6c5['userProfileId']},'raw':!![]})[_0x17b8('0x27')](function(_0x1706af){if(_0x1706af&&_0x1706af[_0x17b8('0x77')]===0x0){return db[_0x17b8('0x2a')][_0x17b8('0x71')]({'name':_0x43d40b['name'],'resourceId':_0x43d40b['id'],'type':_0x1706af[_0x17b8('0x2c')],'sectionId':_0x1706af['id']},{})['then'](function(){return _0xebb025;});}else{return _0xebb025;}})[_0x17b8('0x4c')](function(_0x125677){logger[_0x17b8('0x2b')](_0x17b8('0x78'),_0x125677);throw _0x125677;});}return _0xebb025;})[_0x17b8('0x27')](respondWithResult(_0xc7aa01,null))[_0x17b8('0x4c')](handleError(_0xc7aa01,null));});_0x210329[_0x17b8('0x79')]();}catch(_0x18b997){_0xc7aa01[_0x17b8('0x1b')](0x1f4)['send'](_0x18b997);}};exports['update']=function(_0x2a7116,_0x4cf37a,_0x10f780){return db['Sound'][_0x17b8('0x4b')]({'where':{'id':_0x2a7116[_0x17b8('0x49')]['id']}})[_0x17b8('0x27')](handleEntityNotFound(_0x4cf37a,null))[_0x17b8('0x27')](saveUpdates(_[_0x17b8('0x7a')](_0x2a7116[_0x17b8('0x72')],[_0x17b8('0x2c'),_0x17b8('0x7b')]),null))[_0x17b8('0x27')](respondWithResult(_0x4cf37a,null))[_0x17b8('0x4c')](handleError(_0x4cf37a,null));};exports[_0x17b8('0x7c')]=function(_0x1eed84,_0x4bb8a6,_0x29e6f5){return db['Sound']['find']({'where':{'id':_0x1eed84['params']['id']}})[_0x17b8('0x27')](function(_0x1d6bad){if(_0x1d6bad){return _0x1d6bad['destroy']();}})[_0x17b8('0x27')](function(_0xea793){var _0x3cdd7f=path[_0x17b8('0x4f')](config[_0x17b8('0x50')],'server/files/sounds/original',util[_0x17b8('0x53')](_0x17b8('0x54'),_0xea793[_0x17b8('0x4e')],_0xea793[_0x17b8('0x7d')]));var _0x4257d7=path[_0x17b8('0x4f')](config[_0x17b8('0x50')],_0x17b8('0x5c'),util[_0x17b8('0x53')](_0x17b8('0x54'),_0xea793['save_name'],_0xea793[_0x17b8('0x51')]));fs[_0x17b8('0x62')](_0x3cdd7f);fs[_0x17b8('0x62')](_0x4257d7);return _0xea793;})[_0x17b8('0x27')](function(_0x5e69fe){if(_0x5e69fe){return _0x4bb8a6[_0x17b8('0x1b')](0xcc)[_0x17b8('0x1c')]();}})[_0x17b8('0x27')](handleEntityNotFound(_0x4bb8a6,null))[_0x17b8('0x4c')](handleError(_0x4bb8a6,null));};
\ No newline at end of file
+var _0x5d54=['undefined','limit','count','Content-Range','json','apply','save','then','destroy','get','Sounds','UserProfileResource','end','error','name','send','Sound','fieldName','type','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','options','includeAll','findAll','rows','catch','params','keys','rawAttributes','find','download','save_name','existsSync','join','root','server/files/sounds/converted','converted_format','Sequelize','ValidationError','Sound\x20not\x20found','format','%s.%s','create','basename','originalname','extname','file','filename','substring','server/files/sounds/original','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','src','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','sampleRate','converted_duration','converted_sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','body','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','update','description','original_format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','offset'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5d54,0x151));var _0x45d5=function(_0xa89c3e,_0x144268){_0xa89c3e=_0xa89c3e-0x0;var _0x48072f=_0x5d54[_0xa89c3e];return _0x48072f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x45d5('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x45d5('0x1'));var rp=require(_0x45d5('0x2'));var moment=require(_0x45d5('0x3'));var BPromise=require(_0x45d5('0x4'));var Mustache=require(_0x45d5('0x5'));var util=require(_0x45d5('0x6'));var path=require(_0x45d5('0x7'));var sox=require(_0x45d5('0x8'));var csv=require(_0x45d5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x45d5('0xa'));var _=require(_0x45d5('0xb'));var squel=require('squel');var crypto=require(_0x45d5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x45d5('0xd'));var toCsv=require(_0x45d5('0x9'));var querystring=require(_0x45d5('0xe'));var Papa=require(_0x45d5('0xf'));var Redis=require(_0x45d5('0x10'));var authService=require(_0x45d5('0x11'));var qs=require(_0x45d5('0x12'));var as=require(_0x45d5('0x13'));var hardwareService=require(_0x45d5('0x14'));var logger=require('../../config/logger')(_0x45d5('0x15'));var utils=require(_0x45d5('0x16'));var config=require(_0x45d5('0x17'));var licenseUtil=require(_0x45d5('0x18'));var db=require(_0x45d5('0x19'))['db'];function respondWithStatusCode(_0x1f55bd,_0x520c71){_0x520c71=_0x520c71||0xcc;return function(_0x48aae7){if(_0x48aae7){return _0x1f55bd[_0x45d5('0x1a')](_0x520c71);}return _0x1f55bd[_0x45d5('0x1b')](_0x520c71)['end']();};}function respondWithResult(_0x387a6f,_0x2e0b72){_0x2e0b72=_0x2e0b72||0xc8;return function(_0x34cfa7){if(_0x34cfa7){return _0x387a6f[_0x45d5('0x1b')](_0x2e0b72)['json'](_0x34cfa7);}};}function respondWithFilteredResult(_0x5ebcd5,_0x59643c){return function(_0x5c4ddd){if(_0x5c4ddd){var _0x37349e=typeof _0x59643c[_0x45d5('0x1c')]===_0x45d5('0x1d')&&typeof _0x59643c[_0x45d5('0x1e')]===_0x45d5('0x1d');var _0x2cde59=_0x5c4ddd['count'];var _0x244d46=_0x37349e?0x0:_0x59643c[_0x45d5('0x1c')];var _0x3ba33d=_0x37349e?_0x5c4ddd[_0x45d5('0x1f')]:_0x59643c[_0x45d5('0x1c')]+_0x59643c[_0x45d5('0x1e')];var _0x3af941;if(_0x3ba33d>=_0x2cde59){_0x3ba33d=_0x2cde59;_0x3af941=0xc8;}else{_0x3af941=0xce;}_0x5ebcd5['status'](_0x3af941);return _0x5ebcd5['set'](_0x45d5('0x20'),_0x244d46+'-'+_0x3ba33d+'/'+_0x2cde59)[_0x45d5('0x21')](_0x5c4ddd);}return null;};}function patchUpdates(_0x123fc7){return function(_0x24a349){try{jsonpatch[_0x45d5('0x22')](_0x24a349,_0x123fc7,!![]);}catch(_0x25a1f6){return BPromise['reject'](_0x25a1f6);}return _0x24a349[_0x45d5('0x23')]();};}function saveUpdates(_0x1d4d28,_0x398d31){return function(_0x2fc072){if(_0x2fc072){return _0x2fc072['update'](_0x1d4d28)[_0x45d5('0x24')](function(_0x249206){return _0x249206;});}return null;};}function removeEntity(_0x5e7891,_0x2d17a6){return function(_0x2b3a2f){if(_0x2b3a2f){return _0x2b3a2f[_0x45d5('0x25')]()[_0x45d5('0x24')](function(){var _0x20573d=_0x2b3a2f[_0x45d5('0x26')]({'plain':!![]});var _0x8c4559=_0x45d5('0x27');return db[_0x45d5('0x28')][_0x45d5('0x25')]({'where':{'type':_0x8c4559,'resourceId':_0x20573d['id']}})['then'](function(){return _0x2b3a2f;});})[_0x45d5('0x24')](function(){_0x5e7891[_0x45d5('0x1b')](0xcc)[_0x45d5('0x29')]();});}};}function handleEntityNotFound(_0x2862d6,_0x3db7fe){return function(_0x4ddd3b){if(!_0x4ddd3b){_0x2862d6['sendStatus'](0x194);}return _0x4ddd3b;};}function handleError(_0x304305,_0x17066b){_0x17066b=_0x17066b||0x1f4;return function(_0x12911a){logger[_0x45d5('0x2a')](_0x12911a['stack']);if(_0x12911a[_0x45d5('0x2b')]){delete _0x12911a[_0x45d5('0x2b')];}_0x304305[_0x45d5('0x1b')](_0x17066b)[_0x45d5('0x2c')](_0x12911a);};}exports['index']=function(_0x518eda,_0x546b91){var _0x23b598={},_0x161c72={},_0x2a84ae={'count':0x0,'rows':[]};var _0x237863=_['map'](db[_0x45d5('0x2d')]['rawAttributes'],function(_0x33cb27){return{'name':_0x33cb27[_0x45d5('0x2e')],'type':_0x33cb27[_0x45d5('0x2f')]['key']};});_0x161c72[_0x45d5('0x30')]=_['map'](_0x237863,_0x45d5('0x2b'));_0x161c72[_0x45d5('0x31')]=_['keys'](_0x518eda['query']);_0x161c72['filters']=_[_0x45d5('0x32')](_0x161c72['model'],_0x161c72[_0x45d5('0x31')]);_0x23b598[_0x45d5('0x33')]=_['intersection'](_0x161c72[_0x45d5('0x30')],qs[_0x45d5('0x34')](_0x518eda['query'][_0x45d5('0x34')]));_0x23b598[_0x45d5('0x33')]=_0x23b598[_0x45d5('0x33')][_0x45d5('0x35')]?_0x23b598[_0x45d5('0x33')]:_0x161c72[_0x45d5('0x30')];if(!_0x518eda[_0x45d5('0x31')][_0x45d5('0x36')](_0x45d5('0x37'))){_0x23b598['limit']=qs[_0x45d5('0x1e')](_0x518eda[_0x45d5('0x31')]['limit']);_0x23b598[_0x45d5('0x1c')]=qs[_0x45d5('0x1c')](_0x518eda[_0x45d5('0x31')][_0x45d5('0x1c')]);}_0x23b598['order']=qs['sort'](_0x518eda[_0x45d5('0x31')][_0x45d5('0x38')]);_0x23b598[_0x45d5('0x39')]=qs['filters'](_[_0x45d5('0x3a')](_0x518eda['query'],_0x161c72['filters']),_0x237863);if(_0x518eda[_0x45d5('0x31')]['filter']){_0x23b598[_0x45d5('0x39')]=_[_0x45d5('0x3b')](_0x23b598['where'],{'$or':_['map'](_0x237863,function(_0x4ddb89){if(_0x4ddb89[_0x45d5('0x2f')]!==_0x45d5('0x3c')){var _0x190b1c={};_0x190b1c[_0x4ddb89['name']]={'$like':'%'+_0x518eda[_0x45d5('0x31')]['filter']+'%'};return _0x190b1c;}})});}_0x23b598=_[_0x45d5('0x3b')]({},_0x23b598,_0x518eda[_0x45d5('0x3d')]);var _0x49365a={'where':_0x23b598[_0x45d5('0x39')]};return db['Sound'][_0x45d5('0x1f')](_0x49365a)[_0x45d5('0x24')](function(_0x46ba1a){_0x2a84ae['count']=_0x46ba1a;if(_0x518eda[_0x45d5('0x31')][_0x45d5('0x3e')]){_0x23b598['include']=[{'all':!![]}];}return db[_0x45d5('0x2d')][_0x45d5('0x3f')](_0x23b598);})[_0x45d5('0x24')](function(_0x5ce11d){_0x2a84ae[_0x45d5('0x40')]=_0x5ce11d;return _0x2a84ae;})[_0x45d5('0x24')](respondWithFilteredResult(_0x546b91,_0x23b598))[_0x45d5('0x41')](handleError(_0x546b91,null));};exports['show']=function(_0x18494a,_0x1a265e){var _0x118278={'raw':!![],'where':{'id':_0x18494a[_0x45d5('0x42')]['id']}},_0x2ba9db={};_0x2ba9db[_0x45d5('0x30')]=_[_0x45d5('0x43')](db[_0x45d5('0x2d')][_0x45d5('0x44')]);_0x2ba9db[_0x45d5('0x31')]=_['keys'](_0x18494a[_0x45d5('0x31')]);_0x2ba9db['filters']=_[_0x45d5('0x32')](_0x2ba9db[_0x45d5('0x30')],_0x2ba9db[_0x45d5('0x31')]);_0x118278['attributes']=_[_0x45d5('0x32')](_0x2ba9db['model'],qs[_0x45d5('0x34')](_0x18494a[_0x45d5('0x31')][_0x45d5('0x34')]));_0x118278[_0x45d5('0x33')]=_0x118278[_0x45d5('0x33')]['length']?_0x118278[_0x45d5('0x33')]:_0x2ba9db[_0x45d5('0x30')];if(_0x18494a[_0x45d5('0x31')][_0x45d5('0x3e')]){_0x118278['include']=[{'all':!![]}];}_0x118278=_[_0x45d5('0x3b')]({},_0x118278,_0x18494a[_0x45d5('0x3d')]);return db[_0x45d5('0x2d')][_0x45d5('0x45')](_0x118278)[_0x45d5('0x24')](handleEntityNotFound(_0x1a265e,null))[_0x45d5('0x24')](respondWithResult(_0x1a265e,null))[_0x45d5('0x41')](handleError(_0x1a265e,null));};exports[_0x45d5('0x46')]=function(_0x39311b,_0x109f3a,_0x5f2708){return db['Sound']['find']({'where':{'id':_0x39311b[_0x45d5('0x42')]['id']},'attributes':[_0x45d5('0x2b'),_0x45d5('0x47'),'converted_format'],'raw':!![]})[_0x45d5('0x24')](handleEntityNotFound(_0x109f3a,null))[_0x45d5('0x24')](function(_0x86f5f4){if(_0x86f5f4){if(!fs[_0x45d5('0x48')](path[_0x45d5('0x49')](config[_0x45d5('0x4a')],_0x45d5('0x4b'),_0x86f5f4[_0x45d5('0x47')]+'.'+_0x86f5f4[_0x45d5('0x4c')]))){throw new db[(_0x45d5('0x4d'))][(_0x45d5('0x4e'))](_0x45d5('0x4f'));}return _0x109f3a[_0x45d5('0x46')](path[_0x45d5('0x49')](config[_0x45d5('0x4a')],_0x45d5('0x4b'),util[_0x45d5('0x50')](_0x45d5('0x51'),_0x86f5f4[_0x45d5('0x47')],_0x86f5f4[_0x45d5('0x4c')])),util[_0x45d5('0x50')](_0x45d5('0x51'),_0x86f5f4['name'],_0x86f5f4[_0x45d5('0x4c')]));}return null;})[_0x45d5('0x41')](handleError(_0x109f3a,null));};exports[_0x45d5('0x52')]=function(_0x5790d0,_0x5c7dfc,_0x15cae0){var _0x22fcb1={'name':path[_0x45d5('0x53')](_0x5790d0['file'][_0x45d5('0x54')],path[_0x45d5('0x55')](_0x5790d0[_0x45d5('0x56')]['originalname'])),'save_name':path['basename'](_0x5790d0[_0x45d5('0x56')][_0x45d5('0x57')],path['extname'](_0x5790d0[_0x45d5('0x56')][_0x45d5('0x57')])),'original_format':path[_0x45d5('0x55')](_0x5790d0['file']['originalname'])[_0x45d5('0x58')](0x1),'converted_format':'wav'};var _0x149214=path[_0x45d5('0x49')](config[_0x45d5('0x4a')],_0x45d5('0x59'),_0x5790d0[_0x45d5('0x56')][_0x45d5('0x57')]);var _0xfac743=path[_0x45d5('0x49')](config[_0x45d5('0x4a')],_0x45d5('0x4b'),util[_0x45d5('0x50')](_0x45d5('0x51'),path['basename'](_0x5790d0[_0x45d5('0x56')]['filename'],path['extname'](_0x5790d0['file'][_0x45d5('0x57')])),_0x22fcb1[_0x45d5('0x4c')]));logger[_0x45d5('0x5a')](_0x45d5('0x5b'),_0x149214);logger[_0x45d5('0x5a')](_0x45d5('0x5c'),_0xfac743);try{fs[_0x45d5('0x5d')](_0x149214,parseInt(_0x45d5('0x5e'),0x8));var _0x1a5e93=sox[_0x45d5('0x5f')](_0x149214,_0xfac743,{'sampleRate':0x1f40,'format':'wav','channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x1a5e93['on'](_0x45d5('0x2a'),function(_0x45b1c3){fs[_0x45d5('0x60')](_0x149214);_0x5c7dfc['status'](0x1f4)['send'](_0x45b1c3);});_0x1a5e93['on'](_0x45d5('0x61'),function(_0x58f905){_0x22fcb1['original_duration']=isNaN(_0x58f905[_0x45d5('0x62')])?null:_0x58f905[_0x45d5('0x62')]*0x3e8;_0x22fcb1[_0x45d5('0x63')]=isNaN(_0x58f905[_0x45d5('0x64')])?null:_0x58f905['sampleCount'];_0x22fcb1[_0x45d5('0x65')]=isNaN(_0x58f905[_0x45d5('0x66')])?null:_0x58f905['channelCount'];_0x22fcb1[_0x45d5('0x67')]=isNaN(_0x58f905[_0x45d5('0x68')])?null:_0x58f905[_0x45d5('0x68')];_0x22fcb1['original_sampleRate']=isNaN(_0x58f905[_0x45d5('0x69')])?null:_0x58f905[_0x45d5('0x69')];});_0x1a5e93['on']('dest',function(_0x1126a6){_0x22fcb1[_0x45d5('0x6a')]=isNaN(_0x1126a6[_0x45d5('0x62')])?null:_0x1126a6[_0x45d5('0x62')]*0x3e8;_0x22fcb1[_0x45d5('0x6b')]=isNaN(_0x1126a6['sampleCount'])?null:_0x1126a6[_0x45d5('0x64')];_0x22fcb1[_0x45d5('0x6c')]=isNaN(_0x1126a6['channelCount'])?null:_0x1126a6[_0x45d5('0x66')];_0x22fcb1[_0x45d5('0x6d')]=isNaN(_0x1126a6[_0x45d5('0x68')])?null:_0x1126a6['bitRate'];_0x22fcb1[_0x45d5('0x6e')]=isNaN(_0x1126a6['sampleRate'])?null:_0x1126a6[_0x45d5('0x69')];});_0x1a5e93['on'](_0x45d5('0x29'),function(){fs[_0x45d5('0x5d')](_0xfac743,parseInt(_0x45d5('0x5e'),0x8));return db[_0x45d5('0x2d')]['create'](_0x22fcb1)[_0x45d5('0x24')](function(_0x24c118){var _0xe1fccf={'role':_0x5790d0[_0x45d5('0x6f')]['role'],'userProfileId':_0x5790d0[_0x45d5('0x6f')][_0x45d5('0x70')]};if(!_0xe1fccf)throw new Error(_0x45d5('0x71'));if(_0xe1fccf[_0x45d5('0x72')]===_0x45d5('0x73')){var _0x2d0310=_0x24c118[_0x45d5('0x26')]({'plain':!![]});return db[_0x45d5('0x74')]['find']({'where':{'name':'Sounds','userProfileId':_0xe1fccf[_0x45d5('0x70')]},'raw':!![]})['then'](function(_0x18f9f9){if(_0x18f9f9&&_0x18f9f9['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x2d0310['name'],'resourceId':_0x2d0310['id'],'type':_0x18f9f9[_0x45d5('0x2b')],'sectionId':_0x18f9f9['id']},{})['then'](function(){return _0x24c118;});}else{return _0x24c118;}})[_0x45d5('0x41')](function(_0x1519e0){logger[_0x45d5('0x2a')](_0x45d5('0x75'),_0x1519e0);throw _0x1519e0;});}return _0x24c118;})[_0x45d5('0x24')](respondWithResult(_0x5c7dfc,null))[_0x45d5('0x41')](handleError(_0x5c7dfc,null));});_0x1a5e93[_0x45d5('0x76')]();}catch(_0x383575){_0x5c7dfc[_0x45d5('0x1b')](0x1f4)[_0x45d5('0x2c')](_0x383575);}};exports[_0x45d5('0x77')]=function(_0x792e91,_0x16bea1,_0x105958){return db[_0x45d5('0x2d')][_0x45d5('0x45')]({'where':{'id':_0x792e91['params']['id']}})['then'](handleEntityNotFound(_0x16bea1,null))[_0x45d5('0x24')](saveUpdates(_[_0x45d5('0x3a')](_0x792e91['body'],[_0x45d5('0x2b'),_0x45d5('0x78')]),null))[_0x45d5('0x24')](respondWithResult(_0x16bea1,null))[_0x45d5('0x41')](handleError(_0x16bea1,null));};exports['delete']=function(_0x24cce8,_0x575c62,_0x23ae72){return db[_0x45d5('0x2d')][_0x45d5('0x45')]({'where':{'id':_0x24cce8[_0x45d5('0x42')]['id']}})[_0x45d5('0x24')](function(_0x3d4724){if(_0x3d4724){return _0x3d4724['destroy']();}})['then'](function(_0x2956b4){var _0x132ae6=path['join'](config[_0x45d5('0x4a')],_0x45d5('0x59'),util[_0x45d5('0x50')](_0x45d5('0x51'),_0x2956b4[_0x45d5('0x47')],_0x2956b4[_0x45d5('0x79')]));var _0x242343=path[_0x45d5('0x49')](config[_0x45d5('0x4a')],_0x45d5('0x4b'),util['format']('%s.%s',_0x2956b4[_0x45d5('0x47')],_0x2956b4[_0x45d5('0x4c')]));fs[_0x45d5('0x60')](_0x132ae6);fs['unlinkSync'](_0x242343);return _0x2956b4;})[_0x45d5('0x24')](function(_0x49b8b8){if(_0x49b8b8){return _0x575c62['status'](0xcc)['end']();}})[_0x45d5('0x24')](handleEntityNotFound(_0x575c62,null))['catch'](handleError(_0x575c62,null));};
\ No newline at end of file