Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / sound / sound.controller.js
index b703864..ff16791 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9427=['jsforce','desk.js','to-csv','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','end','status','offset','undefined','count','limit','json','apply','update','then','destroy','Sounds','error','name','send','index','map','Sound','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','sort','where','pick','merge','type','filter','options','include','findAll','rows','params','rawAttributes','includeAll','find','download','save_name','join','root','server/files/sounds/converted','converted_format','Sequelize','ValidationError','Sound\x20not\x20found','format','%s.%s','catch','create','basename','originalname','file','extname','filename','substring','wav','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','unlinkSync','src','original_duration','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_bitRate','converted_sampleRate','body','userProfileId','role','get','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','description','delete','server/files/sounds/original','original_format','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','path','sox','fs-extra','lodash','squel','crypto'];(function(_0x481df5,_0x216652){var _0x32726e=function(_0x2133f4){while(--_0x2133f4){_0x481df5['push'](_0x481df5['shift']());}};_0x32726e(++_0x216652);}(_0x9427,0x70));var _0x7942=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x9427[_0x321bb2];return _0x9c12ed;};'use strict';var emlformat=require(_0x7942('0x0'));var rimraf=require(_0x7942('0x1'));var zipdir=require(_0x7942('0x2'));var jsonpatch=require(_0x7942('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x7942('0x4'));var Mustache=require(_0x7942('0x5'));var util=require('util');var path=require(_0x7942('0x6'));var sox=require(_0x7942('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x7942('0x8'));var _=require(_0x7942('0x9'));var squel=require(_0x7942('0xa'));var crypto=require(_0x7942('0xb'));var jsforce=require(_0x7942('0xc'));var deskjs=require(_0x7942('0xd'));var toCsv=require(_0x7942('0xe'));var querystring=require(_0x7942('0xf'));var Papa=require(_0x7942('0x10'));var Redis=require(_0x7942('0x11'));var authService=require(_0x7942('0x12'));var qs=require(_0x7942('0x13'));var as=require(_0x7942('0x14'));var hardwareService=require(_0x7942('0x15'));var logger=require('../../config/logger')(_0x7942('0x16'));var utils=require(_0x7942('0x17'));var config=require(_0x7942('0x18'));var licenseUtil=require(_0x7942('0x19'));var db=require(_0x7942('0x1a'))['db'];function respondWithStatusCode(_0x403999,_0x3f4226){_0x3f4226=_0x3f4226||0xcc;return function(_0x291043){if(_0x291043){return _0x403999[_0x7942('0x1b')](_0x3f4226);}return _0x403999['status'](_0x3f4226)[_0x7942('0x1c')]();};}function respondWithResult(_0x676ed,_0xec66c5){_0xec66c5=_0xec66c5||0xc8;return function(_0x4df7dc){if(_0x4df7dc){return _0x676ed[_0x7942('0x1d')](_0xec66c5)['json'](_0x4df7dc);}};}function respondWithFilteredResult(_0x11cf76,_0x8d1cc1){return function(_0x27b9f5){if(_0x27b9f5){var _0x48ea46=typeof _0x8d1cc1[_0x7942('0x1e')]===_0x7942('0x1f')&&typeof _0x8d1cc1['limit']==='undefined';var _0x1a54b1=_0x27b9f5[_0x7942('0x20')];var _0x32c02f=_0x48ea46?0x0:_0x8d1cc1[_0x7942('0x1e')];var _0x53fbcc=_0x48ea46?_0x27b9f5[_0x7942('0x20')]:_0x8d1cc1[_0x7942('0x1e')]+_0x8d1cc1[_0x7942('0x21')];var _0x3b3e97;if(_0x53fbcc>=_0x1a54b1){_0x53fbcc=_0x1a54b1;_0x3b3e97=0xc8;}else{_0x3b3e97=0xce;}_0x11cf76[_0x7942('0x1d')](_0x3b3e97);return _0x11cf76['set']('Content-Range',_0x32c02f+'-'+_0x53fbcc+'/'+_0x1a54b1)[_0x7942('0x22')](_0x27b9f5);}return null;};}function patchUpdates(_0x2c0432){return function(_0x56e621){try{jsonpatch[_0x7942('0x23')](_0x56e621,_0x2c0432,!![]);}catch(_0x29ee76){return BPromise['reject'](_0x29ee76);}return _0x56e621['save']();};}function saveUpdates(_0x568382,_0x5832b6){return function(_0x26f053){if(_0x26f053){return _0x26f053[_0x7942('0x24')](_0x568382)[_0x7942('0x25')](function(_0x579be1){return _0x579be1;});}return null;};}function removeEntity(_0x3d1d05,_0x33fd0f){return function(_0x39cc56){if(_0x39cc56){return _0x39cc56[_0x7942('0x26')]()[_0x7942('0x25')](function(){var _0x24b6f0=_0x39cc56['get']({'plain':!![]});var _0x2fed35=_0x7942('0x27');return db['UserProfileResource']['destroy']({'where':{'type':_0x2fed35,'resourceId':_0x24b6f0['id']}})['then'](function(){return _0x39cc56;});})[_0x7942('0x25')](function(){_0x3d1d05['status'](0xcc)[_0x7942('0x1c')]();});}};}function handleEntityNotFound(_0x17b56b,_0x1f5146){return function(_0x3b8727){if(!_0x3b8727){_0x17b56b[_0x7942('0x1b')](0x194);}return _0x3b8727;};}function handleError(_0xb45bf5,_0x503d81){_0x503d81=_0x503d81||0x1f4;return function(_0x19e847){logger[_0x7942('0x28')](_0x19e847['stack']);if(_0x19e847['name']){delete _0x19e847[_0x7942('0x29')];}_0xb45bf5['status'](_0x503d81)[_0x7942('0x2a')](_0x19e847);};}exports[_0x7942('0x2b')]=function(_0x2e1c6f,_0xae4bea){var _0x57b713={},_0x323182={},_0x28a252={'count':0x0,'rows':[]};var _0x4fe54b=_[_0x7942('0x2c')](db[_0x7942('0x2d')]['rawAttributes'],function(_0x2106a0){return{'name':_0x2106a0[_0x7942('0x2e')],'type':_0x2106a0['type'][_0x7942('0x2f')]};});_0x323182[_0x7942('0x30')]=_['map'](_0x4fe54b,_0x7942('0x29'));_0x323182[_0x7942('0x31')]=_[_0x7942('0x32')](_0x2e1c6f[_0x7942('0x31')]);_0x323182[_0x7942('0x33')]=_['intersection'](_0x323182['model'],_0x323182[_0x7942('0x31')]);_0x57b713[_0x7942('0x34')]=_[_0x7942('0x35')](_0x323182[_0x7942('0x30')],qs['fields'](_0x2e1c6f['query'][_0x7942('0x36')]));_0x57b713[_0x7942('0x34')]=_0x57b713[_0x7942('0x34')][_0x7942('0x37')]?_0x57b713[_0x7942('0x34')]:_0x323182[_0x7942('0x30')];if(!_0x2e1c6f[_0x7942('0x31')]['hasOwnProperty']('nolimit')){_0x57b713['limit']=qs[_0x7942('0x21')](_0x2e1c6f[_0x7942('0x31')][_0x7942('0x21')]);_0x57b713[_0x7942('0x1e')]=qs['offset'](_0x2e1c6f[_0x7942('0x31')]['offset']);}_0x57b713['order']=qs['sort'](_0x2e1c6f[_0x7942('0x31')][_0x7942('0x38')]);_0x57b713[_0x7942('0x39')]=qs[_0x7942('0x33')](_[_0x7942('0x3a')](_0x2e1c6f[_0x7942('0x31')],_0x323182['filters']),_0x4fe54b);if(_0x2e1c6f[_0x7942('0x31')]['filter']){_0x57b713[_0x7942('0x39')]=_[_0x7942('0x3b')](_0x57b713[_0x7942('0x39')],{'$or':_[_0x7942('0x2c')](_0x4fe54b,function(_0x51d2ca){if(_0x51d2ca[_0x7942('0x3c')]!=='VIRTUAL'){var _0x44a40b={};_0x44a40b[_0x51d2ca[_0x7942('0x29')]]={'$like':'%'+_0x2e1c6f[_0x7942('0x31')][_0x7942('0x3d')]+'%'};return _0x44a40b;}})});}_0x57b713=_[_0x7942('0x3b')]({},_0x57b713,_0x2e1c6f[_0x7942('0x3e')]);var _0x551277={'where':_0x57b713['where']};return db[_0x7942('0x2d')][_0x7942('0x20')](_0x551277)[_0x7942('0x25')](function(_0x452d1a){_0x28a252[_0x7942('0x20')]=_0x452d1a;if(_0x2e1c6f['query']['includeAll']){_0x57b713[_0x7942('0x3f')]=[{'all':!![]}];}return db[_0x7942('0x2d')][_0x7942('0x40')](_0x57b713);})[_0x7942('0x25')](function(_0x3f67c4){_0x28a252[_0x7942('0x41')]=_0x3f67c4;return _0x28a252;})['then'](respondWithFilteredResult(_0xae4bea,_0x57b713))['catch'](handleError(_0xae4bea,null));};exports['show']=function(_0x1e6985,_0x4f9401){var _0x391453={'raw':!![],'where':{'id':_0x1e6985[_0x7942('0x42')]['id']}},_0x325c88={};_0x325c88[_0x7942('0x30')]=_[_0x7942('0x32')](db[_0x7942('0x2d')][_0x7942('0x43')]);_0x325c88[_0x7942('0x31')]=_[_0x7942('0x32')](_0x1e6985[_0x7942('0x31')]);_0x325c88['filters']=_[_0x7942('0x35')](_0x325c88[_0x7942('0x30')],_0x325c88[_0x7942('0x31')]);_0x391453['attributes']=_[_0x7942('0x35')](_0x325c88[_0x7942('0x30')],qs[_0x7942('0x36')](_0x1e6985[_0x7942('0x31')]['fields']));_0x391453[_0x7942('0x34')]=_0x391453['attributes']['length']?_0x391453['attributes']:_0x325c88['model'];if(_0x1e6985[_0x7942('0x31')][_0x7942('0x44')]){_0x391453[_0x7942('0x3f')]=[{'all':!![]}];}_0x391453=_[_0x7942('0x3b')]({},_0x391453,_0x1e6985[_0x7942('0x3e')]);return db[_0x7942('0x2d')][_0x7942('0x45')](_0x391453)[_0x7942('0x25')](handleEntityNotFound(_0x4f9401,null))['then'](respondWithResult(_0x4f9401,null))['catch'](handleError(_0x4f9401,null));};exports[_0x7942('0x46')]=function(_0x45443f,_0x5af822,_0x41573a){return db['Sound']['find']({'where':{'id':_0x45443f[_0x7942('0x42')]['id']},'attributes':[_0x7942('0x29'),_0x7942('0x47'),'converted_format'],'raw':!![]})['then'](handleEntityNotFound(_0x5af822,null))[_0x7942('0x25')](function(_0x5d8997){if(_0x5d8997){if(!fs['existsSync'](path[_0x7942('0x48')](config[_0x7942('0x49')],_0x7942('0x4a'),_0x5d8997['save_name']+'.'+_0x5d8997[_0x7942('0x4b')]))){throw new db[(_0x7942('0x4c'))][(_0x7942('0x4d'))](_0x7942('0x4e'));}return _0x5af822[_0x7942('0x46')](path[_0x7942('0x48')](config[_0x7942('0x49')],_0x7942('0x4a'),util[_0x7942('0x4f')]('%s.%s',_0x5d8997[_0x7942('0x47')],_0x5d8997['converted_format'])),util['format'](_0x7942('0x50'),_0x5d8997[_0x7942('0x29')],_0x5d8997[_0x7942('0x4b')]));}return null;})[_0x7942('0x51')](handleError(_0x5af822,null));};exports[_0x7942('0x52')]=function(_0x2d7d1c,_0x462bdc,_0x2612ed){var _0xec9c9={'name':path[_0x7942('0x53')](_0x2d7d1c['file'][_0x7942('0x54')],path['extname'](_0x2d7d1c['file'][_0x7942('0x54')])),'save_name':path[_0x7942('0x53')](_0x2d7d1c[_0x7942('0x55')]['filename'],path[_0x7942('0x56')](_0x2d7d1c[_0x7942('0x55')][_0x7942('0x57')])),'original_format':path[_0x7942('0x56')](_0x2d7d1c[_0x7942('0x55')][_0x7942('0x54')])[_0x7942('0x58')](0x1),'converted_format':_0x7942('0x59')};var _0x5529ff=path[_0x7942('0x48')](config[_0x7942('0x49')],'server/files/sounds/original',_0x2d7d1c['file']['filename']);var _0x477d90=path['join'](config['root'],_0x7942('0x4a'),util['format'](_0x7942('0x50'),path[_0x7942('0x53')](_0x2d7d1c[_0x7942('0x55')]['filename'],path[_0x7942('0x56')](_0x2d7d1c['file']['filename'])),_0xec9c9[_0x7942('0x4b')]));logger[_0x7942('0x5a')](_0x7942('0x5b'),_0x5529ff);logger[_0x7942('0x5a')](_0x7942('0x5c'),_0x477d90);try{fs[_0x7942('0x5d')](_0x5529ff,parseInt(_0x7942('0x5e'),0x8));var _0x585152=sox['transcode'](_0x5529ff,_0x477d90,{'sampleRate':0x1f40,'format':_0x7942('0x59'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x585152['on'](_0x7942('0x28'),function(_0x58a674){fs[_0x7942('0x5f')](_0x5529ff);_0x462bdc[_0x7942('0x1d')](0x1f4)[_0x7942('0x2a')](_0x58a674);});_0x585152['on'](_0x7942('0x60'),function(_0x3a9af1){_0xec9c9[_0x7942('0x61')]=isNaN(_0x3a9af1[_0x7942('0x62')])?null:_0x3a9af1['duration']*0x3e8;_0xec9c9[_0x7942('0x63')]=isNaN(_0x3a9af1[_0x7942('0x64')])?null:_0x3a9af1[_0x7942('0x64')];_0xec9c9[_0x7942('0x65')]=isNaN(_0x3a9af1[_0x7942('0x66')])?null:_0x3a9af1['channelCount'];_0xec9c9[_0x7942('0x67')]=isNaN(_0x3a9af1[_0x7942('0x68')])?null:_0x3a9af1[_0x7942('0x68')];_0xec9c9['original_sampleRate']=isNaN(_0x3a9af1[_0x7942('0x69')])?null:_0x3a9af1[_0x7942('0x69')];});_0x585152['on'](_0x7942('0x6a'),function(_0x22fa91){_0xec9c9[_0x7942('0x6b')]=isNaN(_0x22fa91[_0x7942('0x62')])?null:_0x22fa91[_0x7942('0x62')]*0x3e8;_0xec9c9[_0x7942('0x6c')]=isNaN(_0x22fa91[_0x7942('0x64')])?null:_0x22fa91['sampleCount'];_0xec9c9['converted_channelCount']=isNaN(_0x22fa91[_0x7942('0x66')])?null:_0x22fa91[_0x7942('0x66')];_0xec9c9[_0x7942('0x6d')]=isNaN(_0x22fa91['bitRate'])?null:_0x22fa91['bitRate'];_0xec9c9[_0x7942('0x6e')]=isNaN(_0x22fa91['sampleRate'])?null:_0x22fa91['sampleRate'];});_0x585152['on'](_0x7942('0x1c'),function(){fs[_0x7942('0x5d')](_0x477d90,parseInt(_0x7942('0x5e'),0x8));return db['Sound']['create'](_0xec9c9)['then'](function(_0x50403d){var _0x3f17ed={'role':_0x2d7d1c[_0x7942('0x6f')]['role'],'userProfileId':_0x2d7d1c[_0x7942('0x6f')][_0x7942('0x70')]};if(!_0x3f17ed)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3f17ed[_0x7942('0x71')]==='user'){var _0x434f3a=_0x50403d[_0x7942('0x72')]({'plain':!![]});return db[_0x7942('0x73')][_0x7942('0x45')]({'where':{'name':_0x7942('0x27'),'userProfileId':_0x3f17ed['userProfileId']},'raw':!![]})['then'](function(_0x5c8c3d){if(_0x5c8c3d&&_0x5c8c3d[_0x7942('0x74')]===0x0){return db[_0x7942('0x75')][_0x7942('0x52')]({'name':_0x434f3a[_0x7942('0x29')],'resourceId':_0x434f3a['id'],'type':_0x5c8c3d[_0x7942('0x29')],'sectionId':_0x5c8c3d['id']},{})[_0x7942('0x25')](function(){return _0x50403d;});}else{return _0x50403d;}})[_0x7942('0x51')](function(_0x31f643){logger['error'](_0x7942('0x76'),_0x31f643);throw _0x31f643;});}return _0x50403d;})[_0x7942('0x25')](respondWithResult(_0x462bdc,null))[_0x7942('0x51')](handleError(_0x462bdc,null));});_0x585152[_0x7942('0x77')]();}catch(_0xd30b34){_0x462bdc[_0x7942('0x1d')](0x1f4)[_0x7942('0x2a')](_0xd30b34);}};exports[_0x7942('0x24')]=function(_0xba16db,_0x4c0ebc,_0xbbedf2){return db[_0x7942('0x2d')]['find']({'where':{'id':_0xba16db[_0x7942('0x42')]['id']}})[_0x7942('0x25')](handleEntityNotFound(_0x4c0ebc,null))[_0x7942('0x25')](saveUpdates(_[_0x7942('0x3a')](_0xba16db[_0x7942('0x6f')],[_0x7942('0x29'),_0x7942('0x78')]),null))[_0x7942('0x25')](respondWithResult(_0x4c0ebc,null))[_0x7942('0x51')](handleError(_0x4c0ebc,null));};exports[_0x7942('0x79')]=function(_0x1b07b0,_0x5c0b13,_0x7a982a){return db[_0x7942('0x2d')][_0x7942('0x45')]({'where':{'id':_0x1b07b0['params']['id']}})[_0x7942('0x25')](function(_0xa8d32a){if(_0xa8d32a){return _0xa8d32a['destroy']();}})[_0x7942('0x25')](function(_0x3bc5ae){var _0xedfefd=path[_0x7942('0x48')](config['root'],_0x7942('0x7a'),util[_0x7942('0x4f')](_0x7942('0x50'),_0x3bc5ae['save_name'],_0x3bc5ae[_0x7942('0x7b')]));var _0x51cd92=path[_0x7942('0x48')](config[_0x7942('0x49')],'server/files/sounds/converted',util['format'](_0x7942('0x50'),_0x3bc5ae[_0x7942('0x47')],_0x3bc5ae[_0x7942('0x4b')]));fs[_0x7942('0x5f')](_0xedfefd);fs[_0x7942('0x5f')](_0x51cd92);return _0x3bc5ae;})[_0x7942('0x25')](function(_0xaa5866){if(_0xaa5866){return _0x5c0b13[_0x7942('0x1d')](0xcc)['end']();}})['then'](handleEntityNotFound(_0x5c0b13,null))[_0x7942('0x51')](handleError(_0x5c0b13,null));};
\ No newline at end of file
+var _0x7116=['duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','converted_duration','converted_sampleCount','converted_bitRate','role','body','user','userProfileId','error','start','description','original_format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','save','update','destroy','get','Sounds','UserProfileResource','then','stack','name','send','index','map','Sound','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','catch','params','find','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','wav','info','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','original_duration'];(function(_0x546dd2,_0x2d5991){var _0x265106=function(_0x5bab94){while(--_0x5bab94){_0x546dd2['push'](_0x546dd2['shift']());}};_0x265106(++_0x2d5991);}(_0x7116,0x88));var _0x6711=function(_0x508b77,_0x5de944){_0x508b77=_0x508b77-0x0;var _0x440bd=_0x7116[_0x508b77];return _0x440bd;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x6711('0x0'));var jsonpatch=require(_0x6711('0x1'));var rp=require(_0x6711('0x2'));var moment=require('moment');var BPromise=require(_0x6711('0x3'));var Mustache=require(_0x6711('0x4'));var util=require('util');var path=require(_0x6711('0x5'));var sox=require(_0x6711('0x6'));var csv=require(_0x6711('0x7'));var ejs=require(_0x6711('0x8'));var fs=require('fs');var fs_extra=require(_0x6711('0x9'));var _=require(_0x6711('0xa'));var squel=require(_0x6711('0xb'));var crypto=require(_0x6711('0xc'));var jsforce=require(_0x6711('0xd'));var deskjs=require(_0x6711('0xe'));var toCsv=require('to-csv');var querystring=require(_0x6711('0xf'));var Papa=require(_0x6711('0x10'));var Redis=require(_0x6711('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x6711('0x12'));var utils=require(_0x6711('0x13'));var config=require(_0x6711('0x14'));var licenseUtil=require(_0x6711('0x15'));var db=require(_0x6711('0x16'))['db'];function respondWithStatusCode(_0x291904,_0x35ab1f){_0x35ab1f=_0x35ab1f||0xcc;return function(_0x5b1abf){if(_0x5b1abf){return _0x291904[_0x6711('0x17')](_0x35ab1f);}return _0x291904[_0x6711('0x18')](_0x35ab1f)[_0x6711('0x19')]();};}function respondWithResult(_0x42a582,_0x44947b){_0x44947b=_0x44947b||0xc8;return function(_0xc7172c){if(_0xc7172c){return _0x42a582[_0x6711('0x18')](_0x44947b)[_0x6711('0x1a')](_0xc7172c);}};}function respondWithFilteredResult(_0x357601,_0x4395f7){return function(_0x5424d0){if(_0x5424d0){var _0x2a0012=typeof _0x4395f7[_0x6711('0x1b')]===_0x6711('0x1c')&&typeof _0x4395f7['limit']===_0x6711('0x1c');var _0x44c113=_0x5424d0[_0x6711('0x1d')];var _0x53db67=_0x2a0012?0x0:_0x4395f7['offset'];var _0x275990=_0x2a0012?_0x5424d0[_0x6711('0x1d')]:_0x4395f7[_0x6711('0x1b')]+_0x4395f7[_0x6711('0x1e')];var _0x5b804d;if(_0x275990>=_0x44c113){_0x275990=_0x44c113;_0x5b804d=0xc8;}else{_0x5b804d=0xce;}_0x357601[_0x6711('0x18')](_0x5b804d);return _0x357601[_0x6711('0x1f')](_0x6711('0x20'),_0x53db67+'-'+_0x275990+'/'+_0x44c113)[_0x6711('0x1a')](_0x5424d0);}return null;};}function patchUpdates(_0x83af5d){return function(_0x1bd47d){try{jsonpatch['apply'](_0x1bd47d,_0x83af5d,!![]);}catch(_0x81f9c2){return BPromise['reject'](_0x81f9c2);}return _0x1bd47d[_0x6711('0x21')]();};}function saveUpdates(_0x3f5d4c,_0x5e82cd){return function(_0x2b8c87){if(_0x2b8c87){return _0x2b8c87[_0x6711('0x22')](_0x3f5d4c)['then'](function(_0x5e50c6){return _0x5e50c6;});}return null;};}function removeEntity(_0x25a0cd,_0x3f7cda){return function(_0x22c116){if(_0x22c116){return _0x22c116[_0x6711('0x23')]()['then'](function(){var _0x8925a4=_0x22c116[_0x6711('0x24')]({'plain':!![]});var _0x37e26d=_0x6711('0x25');return db[_0x6711('0x26')][_0x6711('0x23')]({'where':{'type':_0x37e26d,'resourceId':_0x8925a4['id']}})[_0x6711('0x27')](function(){return _0x22c116;});})[_0x6711('0x27')](function(){_0x25a0cd[_0x6711('0x18')](0xcc)[_0x6711('0x19')]();});}};}function handleEntityNotFound(_0x22d1d7,_0x3c9b41){return function(_0x5b62e4){if(!_0x5b62e4){_0x22d1d7['sendStatus'](0x194);}return _0x5b62e4;};}function handleError(_0x32eef0,_0x2c2ea1){_0x2c2ea1=_0x2c2ea1||0x1f4;return function(_0x2be1b8){logger['error'](_0x2be1b8[_0x6711('0x28')]);if(_0x2be1b8['name']){delete _0x2be1b8[_0x6711('0x29')];}_0x32eef0['status'](_0x2c2ea1)[_0x6711('0x2a')](_0x2be1b8);};}exports[_0x6711('0x2b')]=function(_0x4c9228,_0x4dd2fe){var _0x13d919={},_0xd1987={},_0x33be3f={'count':0x0,'rows':[]};var _0xa95b92=_[_0x6711('0x2c')](db[_0x6711('0x2d')]['rawAttributes'],function(_0x333daa){return{'name':_0x333daa['fieldName'],'type':_0x333daa[_0x6711('0x2e')][_0x6711('0x2f')]};});_0xd1987[_0x6711('0x30')]=_[_0x6711('0x2c')](_0xa95b92,_0x6711('0x29'));_0xd1987[_0x6711('0x31')]=_[_0x6711('0x32')](_0x4c9228['query']);_0xd1987[_0x6711('0x33')]=_[_0x6711('0x34')](_0xd1987['model'],_0xd1987['query']);_0x13d919[_0x6711('0x35')]=_[_0x6711('0x34')](_0xd1987[_0x6711('0x30')],qs[_0x6711('0x36')](_0x4c9228[_0x6711('0x31')][_0x6711('0x36')]));_0x13d919[_0x6711('0x35')]=_0x13d919[_0x6711('0x35')]['length']?_0x13d919['attributes']:_0xd1987[_0x6711('0x30')];if(!_0x4c9228[_0x6711('0x31')][_0x6711('0x37')](_0x6711('0x38'))){_0x13d919['limit']=qs[_0x6711('0x1e')](_0x4c9228[_0x6711('0x31')][_0x6711('0x1e')]);_0x13d919[_0x6711('0x1b')]=qs[_0x6711('0x1b')](_0x4c9228[_0x6711('0x31')][_0x6711('0x1b')]);}_0x13d919['order']=qs[_0x6711('0x39')](_0x4c9228[_0x6711('0x31')][_0x6711('0x39')]);_0x13d919[_0x6711('0x3a')]=qs[_0x6711('0x33')](_[_0x6711('0x3b')](_0x4c9228[_0x6711('0x31')],_0xd1987['filters']),_0xa95b92);if(_0x4c9228[_0x6711('0x31')][_0x6711('0x3c')]){_0x13d919['where']=_['merge'](_0x13d919[_0x6711('0x3a')],{'$or':_[_0x6711('0x2c')](_0xa95b92,function(_0x201a35){if(_0x201a35[_0x6711('0x2e')]!==_0x6711('0x3d')){var _0x23b338={};_0x23b338[_0x201a35['name']]={'$like':'%'+_0x4c9228[_0x6711('0x31')][_0x6711('0x3c')]+'%'};return _0x23b338;}})});}_0x13d919=_[_0x6711('0x3e')]({},_0x13d919,_0x4c9228[_0x6711('0x3f')]);var _0x402744={'where':_0x13d919[_0x6711('0x3a')]};return db[_0x6711('0x2d')]['count'](_0x402744)[_0x6711('0x27')](function(_0x25eb72){_0x33be3f['count']=_0x25eb72;if(_0x4c9228['query'][_0x6711('0x40')]){_0x13d919[_0x6711('0x41')]=[{'all':!![]}];}return db[_0x6711('0x2d')][_0x6711('0x42')](_0x13d919);})[_0x6711('0x27')](function(_0x41b5b3){_0x33be3f['rows']=_0x41b5b3;return _0x33be3f;})[_0x6711('0x27')](respondWithFilteredResult(_0x4dd2fe,_0x13d919))[_0x6711('0x43')](handleError(_0x4dd2fe,null));};exports['show']=function(_0xafb64a,_0x23180a){var _0x3541d9={'raw':!![],'where':{'id':_0xafb64a[_0x6711('0x44')]['id']}},_0x624372={};_0x624372[_0x6711('0x30')]=_[_0x6711('0x32')](db[_0x6711('0x2d')]['rawAttributes']);_0x624372['query']=_['keys'](_0xafb64a[_0x6711('0x31')]);_0x624372[_0x6711('0x33')]=_[_0x6711('0x34')](_0x624372[_0x6711('0x30')],_0x624372[_0x6711('0x31')]);_0x3541d9[_0x6711('0x35')]=_[_0x6711('0x34')](_0x624372[_0x6711('0x30')],qs[_0x6711('0x36')](_0xafb64a['query'][_0x6711('0x36')]));_0x3541d9[_0x6711('0x35')]=_0x3541d9[_0x6711('0x35')]['length']?_0x3541d9['attributes']:_0x624372[_0x6711('0x30')];if(_0xafb64a[_0x6711('0x31')][_0x6711('0x40')]){_0x3541d9[_0x6711('0x41')]=[{'all':!![]}];}_0x3541d9=_['merge']({},_0x3541d9,_0xafb64a[_0x6711('0x3f')]);return db[_0x6711('0x2d')][_0x6711('0x45')](_0x3541d9)[_0x6711('0x27')](handleEntityNotFound(_0x23180a,null))['then'](respondWithResult(_0x23180a,null))[_0x6711('0x43')](handleError(_0x23180a,null));};exports['download']=function(_0x1c0100,_0x4ce91b,_0x5426f6){return db[_0x6711('0x2d')][_0x6711('0x45')]({'where':{'id':_0x1c0100[_0x6711('0x44')]['id']},'attributes':['name',_0x6711('0x46'),_0x6711('0x47')],'raw':!![]})[_0x6711('0x27')](handleEntityNotFound(_0x4ce91b,null))['then'](function(_0x13b29e){if(_0x13b29e){if(!fs[_0x6711('0x48')](path[_0x6711('0x49')](config[_0x6711('0x4a')],_0x6711('0x4b'),_0x13b29e[_0x6711('0x46')]+'.'+_0x13b29e[_0x6711('0x47')]))){throw new db[(_0x6711('0x4c'))][(_0x6711('0x4d'))](_0x6711('0x4e'));}return _0x4ce91b[_0x6711('0x4f')](path[_0x6711('0x49')](config[_0x6711('0x4a')],_0x6711('0x4b'),util[_0x6711('0x50')](_0x6711('0x51'),_0x13b29e['save_name'],_0x13b29e[_0x6711('0x47')])),util[_0x6711('0x50')]('%s.%s',_0x13b29e['name'],_0x13b29e['converted_format']));}return null;})[_0x6711('0x43')](handleError(_0x4ce91b,null));};exports[_0x6711('0x52')]=function(_0x30841f,_0x1fc2f5,_0x5a7d23){var _0x344665={'name':path[_0x6711('0x53')](_0x30841f[_0x6711('0x54')][_0x6711('0x55')],path[_0x6711('0x56')](_0x30841f[_0x6711('0x54')][_0x6711('0x55')])),'save_name':path[_0x6711('0x53')](_0x30841f['file'][_0x6711('0x57')],path[_0x6711('0x56')](_0x30841f[_0x6711('0x54')][_0x6711('0x57')])),'original_format':path['extname'](_0x30841f['file'][_0x6711('0x55')])['substring'](0x1),'converted_format':_0x6711('0x58')};var _0x58e8f0=path[_0x6711('0x49')](config[_0x6711('0x4a')],'server/files/sounds/original',_0x30841f[_0x6711('0x54')][_0x6711('0x57')]);var _0x10abdd=path[_0x6711('0x49')](config[_0x6711('0x4a')],_0x6711('0x4b'),util[_0x6711('0x50')]('%s.%s',path[_0x6711('0x53')](_0x30841f[_0x6711('0x54')][_0x6711('0x57')],path['extname'](_0x30841f['file'][_0x6711('0x57')])),_0x344665['converted_format']));logger['info']('Sound\x20upload\x20filepath:\x20%s',_0x58e8f0);logger[_0x6711('0x59')](_0x6711('0x5a'),_0x10abdd);try{fs[_0x6711('0x5b')](_0x58e8f0,parseInt(_0x6711('0x5c'),0x8));var _0x2ae852=sox[_0x6711('0x5d')](_0x58e8f0,_0x10abdd,{'sampleRate':0x1f40,'format':_0x6711('0x58'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x2ae852['on']('error',function(_0x1f1302){fs[_0x6711('0x5e')](_0x58e8f0);_0x1fc2f5['status'](0x1f4)[_0x6711('0x2a')](_0x1f1302);});_0x2ae852['on']('src',function(_0xf4baf8){_0x344665[_0x6711('0x5f')]=isNaN(_0xf4baf8[_0x6711('0x60')])?null:_0xf4baf8[_0x6711('0x60')]*0x3e8;_0x344665[_0x6711('0x61')]=isNaN(_0xf4baf8['sampleCount'])?null:_0xf4baf8[_0x6711('0x62')];_0x344665[_0x6711('0x63')]=isNaN(_0xf4baf8[_0x6711('0x64')])?null:_0xf4baf8[_0x6711('0x64')];_0x344665[_0x6711('0x65')]=isNaN(_0xf4baf8[_0x6711('0x66')])?null:_0xf4baf8['bitRate'];_0x344665[_0x6711('0x67')]=isNaN(_0xf4baf8[_0x6711('0x68')])?null:_0xf4baf8[_0x6711('0x68')];});_0x2ae852['on']('dest',function(_0x2c516d){_0x344665[_0x6711('0x69')]=isNaN(_0x2c516d[_0x6711('0x60')])?null:_0x2c516d['duration']*0x3e8;_0x344665[_0x6711('0x6a')]=isNaN(_0x2c516d[_0x6711('0x62')])?null:_0x2c516d[_0x6711('0x62')];_0x344665['converted_channelCount']=isNaN(_0x2c516d[_0x6711('0x64')])?null:_0x2c516d['channelCount'];_0x344665[_0x6711('0x6b')]=isNaN(_0x2c516d[_0x6711('0x66')])?null:_0x2c516d[_0x6711('0x66')];_0x344665['converted_sampleRate']=isNaN(_0x2c516d[_0x6711('0x68')])?null:_0x2c516d[_0x6711('0x68')];});_0x2ae852['on'](_0x6711('0x19'),function(){fs[_0x6711('0x5b')](_0x10abdd,parseInt('0777',0x8));return db[_0x6711('0x2d')][_0x6711('0x52')](_0x344665)[_0x6711('0x27')](function(_0xd5f22d){var _0x4d8235={'role':_0x30841f['body'][_0x6711('0x6c')],'userProfileId':_0x30841f[_0x6711('0x6d')]['userProfileId']};if(!_0x4d8235)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4d8235[_0x6711('0x6c')]===_0x6711('0x6e')){var _0x407c64=_0xd5f22d[_0x6711('0x24')]({'plain':!![]});return db['UserProfileSection'][_0x6711('0x45')]({'where':{'name':_0x6711('0x25'),'userProfileId':_0x4d8235[_0x6711('0x6f')]},'raw':!![]})[_0x6711('0x27')](function(_0x32e2b6){if(_0x32e2b6&&_0x32e2b6['autoAssociation']===0x0){return db['UserProfileResource'][_0x6711('0x52')]({'name':_0x407c64[_0x6711('0x29')],'resourceId':_0x407c64['id'],'type':_0x32e2b6['name'],'sectionId':_0x32e2b6['id']},{})[_0x6711('0x27')](function(){return _0xd5f22d;});}else{return _0xd5f22d;}})[_0x6711('0x43')](function(_0x1940bd){logger[_0x6711('0x70')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1940bd);throw _0x1940bd;});}return _0xd5f22d;})[_0x6711('0x27')](respondWithResult(_0x1fc2f5,null))[_0x6711('0x43')](handleError(_0x1fc2f5,null));});_0x2ae852[_0x6711('0x71')]();}catch(_0x5b9c3a){_0x1fc2f5[_0x6711('0x18')](0x1f4)[_0x6711('0x2a')](_0x5b9c3a);}};exports[_0x6711('0x22')]=function(_0x5d99a8,_0x3cf8e0,_0xd93399){return db[_0x6711('0x2d')][_0x6711('0x45')]({'where':{'id':_0x5d99a8[_0x6711('0x44')]['id']}})[_0x6711('0x27')](handleEntityNotFound(_0x3cf8e0,null))['then'](saveUpdates(_[_0x6711('0x3b')](_0x5d99a8[_0x6711('0x6d')],[_0x6711('0x29'),_0x6711('0x72')]),null))['then'](respondWithResult(_0x3cf8e0,null))[_0x6711('0x43')](handleError(_0x3cf8e0,null));};exports['delete']=function(_0xc6ffea,_0x45449c,_0x15f14c){return db[_0x6711('0x2d')][_0x6711('0x45')]({'where':{'id':_0xc6ffea['params']['id']}})[_0x6711('0x27')](function(_0x140567){if(_0x140567){return _0x140567[_0x6711('0x23')]();}})[_0x6711('0x27')](function(_0x1b4ac0){var _0x3cb90d=path[_0x6711('0x49')](config[_0x6711('0x4a')],'server/files/sounds/original',util[_0x6711('0x50')]('%s.%s',_0x1b4ac0[_0x6711('0x46')],_0x1b4ac0[_0x6711('0x73')]));var _0x37151e=path[_0x6711('0x49')](config[_0x6711('0x4a')],_0x6711('0x4b'),util[_0x6711('0x50')]('%s.%s',_0x1b4ac0['save_name'],_0x1b4ac0[_0x6711('0x47')]));fs[_0x6711('0x5e')](_0x3cb90d);fs[_0x6711('0x5e')](_0x37151e);return _0x1b4ac0;})[_0x6711('0x27')](function(_0x19c5c8){if(_0x19c5c8){return _0x45449c['status'](0xcc)[_0x6711('0x19')]();}})['then'](handleEntityNotFound(_0x45449c,null))[_0x6711('0x43')](handleError(_0x45449c,null));};
\ No newline at end of file