Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / sound / sound.controller.js
index 9c21477..e9d52ab 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf95f=['lodash','squel','crypto','jsforce','desk.js','to-csv','ioredis','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','Sounds','UserProfileResource','error','stack','name','send','index','map','Sound','rawAttributes','fieldName','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','include','findAll','rows','catch','show','params','length','includeAll','find','download','save_name','converted_format','existsSync','join','root','server/files/sounds/converted','Sequelize','ValidationError','format','%s.%s','create','basename','file','extname','originalname','filename','wav','info','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','src','duration','original_sampleCount','sampleCount','channelCount','bitRate','original_sampleRate','sampleRate','converted_sampleCount','converted_channelCount','converted_bitRate','end','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','start','description','delete','original_format','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','ejs'];(function(_0x52322a,_0xc2b718){var _0x1af925=function(_0x3e5c45){while(--_0x3e5c45){_0x52322a['push'](_0x52322a['shift']());}};_0x1af925(++_0xc2b718);}(_0xf95f,0xe4));var _0xff95=function(_0x1aba9c,_0x465976){_0x1aba9c=_0x1aba9c-0x0;var _0x414891=_0xf95f[_0x1aba9c];return _0x414891;};'use strict';var pdf=require(_0xff95('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xff95('0x1'));var zipdir=require(_0xff95('0x2'));var jsonpatch=require(_0xff95('0x3'));var rp=require('request-promise');var moment=require(_0xff95('0x4'));var BPromise=require(_0xff95('0x5'));var Mustache=require(_0xff95('0x6'));var util=require(_0xff95('0x7'));var path=require(_0xff95('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xff95('0x9'));var fs=require('fs');var _=require(_0xff95('0xa'));var squel=require(_0xff95('0xb'));var crypto=require(_0xff95('0xc'));var jsforce=require(_0xff95('0xd'));var deskjs=require(_0xff95('0xe'));var toCsv=require(_0xff95('0xf'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xff95('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xff95('0x11'));var logger=require(_0xff95('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xff95('0x13'));var db=require(_0xff95('0x14'))['db'];function respondWithStatusCode(_0x5cacda,_0x22aa90){_0x22aa90=_0x22aa90||0xcc;return function(_0x5155f6){if(_0x5155f6){return _0x5cacda[_0xff95('0x15')](_0x22aa90);}return _0x5cacda[_0xff95('0x16')](_0x22aa90)['end']();};}function respondWithResult(_0x2e09fc,_0x293ff2){_0x293ff2=_0x293ff2||0xc8;return function(_0x177565){if(_0x177565){return _0x2e09fc[_0xff95('0x16')](_0x293ff2)[_0xff95('0x17')](_0x177565);}};}function respondWithFilteredResult(_0x34fd84,_0x5d29f2){return function(_0x122e34){if(_0x122e34){var _0x2bc3ed=_0x122e34[_0xff95('0x18')],_0x5265bd=_0x5d29f2['offset'],_0x24dde7=_0x5d29f2[_0xff95('0x19')]+_0x5d29f2[_0xff95('0x1a')],_0x49d5d8;if(_0x24dde7>=_0x2bc3ed){_0x24dde7=_0x2bc3ed;_0x49d5d8=0xc8;}else{_0x49d5d8=0xce;}_0x34fd84[_0xff95('0x16')](_0x49d5d8);return _0x34fd84[_0xff95('0x1b')](_0xff95('0x1c'),_0x5265bd+'-'+_0x24dde7+'/'+_0x2bc3ed)[_0xff95('0x17')](_0x122e34);}return null;};}function patchUpdates(_0x30ec4d){return function(_0x518d09){try{jsonpatch[_0xff95('0x1d')](_0x518d09,_0x30ec4d,!![]);}catch(_0x419f05){return BPromise[_0xff95('0x1e')](_0x419f05);}return _0x518d09[_0xff95('0x1f')]();};}function saveUpdates(_0x2374d0,_0x36a9fa){return function(_0x440465){if(_0x440465){return _0x440465[_0xff95('0x20')](_0x2374d0)[_0xff95('0x21')](function(_0x2e1728){return _0x2e1728;});}return null;};}function removeEntity(_0xfac102,_0x4a34f7){return function(_0x39fed3){if(_0x39fed3){return _0x39fed3[_0xff95('0x22')]()[_0xff95('0x21')](function(){var _0x4a8d2d=_0x39fed3[_0xff95('0x23')]({'plain':!![]});var _0x2a2804=_0xff95('0x24');return db[_0xff95('0x25')]['destroy']({'where':{'type':_0x2a2804,'resourceId':_0x4a8d2d['id']}})[_0xff95('0x21')](function(){return _0x39fed3;});})[_0xff95('0x21')](function(){_0xfac102[_0xff95('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1e3b62,_0x4c73a4){return function(_0x5432ce){if(!_0x5432ce){_0x1e3b62['sendStatus'](0x194);}return _0x5432ce;};}function handleError(_0x25c78c,_0x1a84d2){_0x1a84d2=_0x1a84d2||0x1f4;return function(_0x197096){logger[_0xff95('0x26')](_0x197096[_0xff95('0x27')]);if(_0x197096[_0xff95('0x28')]){delete _0x197096[_0xff95('0x28')];}_0x25c78c[_0xff95('0x16')](_0x1a84d2)[_0xff95('0x29')](_0x197096);};}exports[_0xff95('0x2a')]=function(_0x4f7fc1,_0x39219c){var _0x389af8={},_0x15a4f1={},_0x29123e={'count':0x0,'rows':[]};var _0x564cd9=_[_0xff95('0x2b')](db[_0xff95('0x2c')][_0xff95('0x2d')],function(_0x3436cb){return{'name':_0x3436cb[_0xff95('0x2e')],'type':_0x3436cb['type']['key']};});_0x15a4f1[_0xff95('0x2f')]=_[_0xff95('0x2b')](_0x564cd9,_0xff95('0x28'));_0x15a4f1[_0xff95('0x30')]=_[_0xff95('0x31')](_0x4f7fc1[_0xff95('0x30')]);_0x15a4f1[_0xff95('0x32')]=_[_0xff95('0x33')](_0x15a4f1[_0xff95('0x2f')],_0x15a4f1[_0xff95('0x30')]);_0x389af8['attributes']=_['intersection'](_0x15a4f1['model'],qs['fields'](_0x4f7fc1[_0xff95('0x30')][_0xff95('0x34')]));_0x389af8['attributes']=_0x389af8['attributes']['length']?_0x389af8[_0xff95('0x35')]:_0x15a4f1[_0xff95('0x2f')];if(!_0x4f7fc1[_0xff95('0x30')]['hasOwnProperty'](_0xff95('0x36'))){_0x389af8[_0xff95('0x1a')]=qs[_0xff95('0x1a')](_0x4f7fc1['query'][_0xff95('0x1a')]);_0x389af8[_0xff95('0x19')]=qs[_0xff95('0x19')](_0x4f7fc1[_0xff95('0x30')][_0xff95('0x19')]);}_0x389af8[_0xff95('0x37')]=qs[_0xff95('0x38')](_0x4f7fc1[_0xff95('0x30')][_0xff95('0x38')]);_0x389af8[_0xff95('0x39')]=qs['filters'](_[_0xff95('0x3a')](_0x4f7fc1['query'],_0x15a4f1[_0xff95('0x32')]));if(_0x4f7fc1[_0xff95('0x30')][_0xff95('0x3b')]){_0x389af8[_0xff95('0x39')]=_[_0xff95('0x3c')](_0x389af8[_0xff95('0x39')],{'$or':_[_0xff95('0x2b')](_0x564cd9,function(_0x5d9acf){if(_0x5d9acf[_0xff95('0x3d')]!==_0xff95('0x3e')){var _0x57ef92={};_0x57ef92[_0x5d9acf[_0xff95('0x28')]]={'$like':'%'+_0x4f7fc1['query'][_0xff95('0x3b')]+'%'};return _0x57ef92;}})});}_0x389af8=_[_0xff95('0x3c')]({},_0x389af8,_0x4f7fc1[_0xff95('0x3f')]);var _0x530385={'where':_0x389af8[_0xff95('0x39')]};return db[_0xff95('0x2c')][_0xff95('0x18')](_0x530385)['then'](function(_0x288a75){_0x29123e[_0xff95('0x18')]=_0x288a75;if(_0x4f7fc1['query']['includeAll']){_0x389af8[_0xff95('0x40')]=[{'all':!![]}];}return db[_0xff95('0x2c')][_0xff95('0x41')](_0x389af8);})['then'](function(_0x10c37f){_0x29123e[_0xff95('0x42')]=_0x10c37f;return _0x29123e;})[_0xff95('0x21')](respondWithFilteredResult(_0x39219c,_0x389af8))[_0xff95('0x43')](handleError(_0x39219c,null));};exports[_0xff95('0x44')]=function(_0x57effb,_0x2c6028){var _0x32ce40={'raw':!![],'where':{'id':_0x57effb[_0xff95('0x45')]['id']}},_0xa9a92b={};_0xa9a92b[_0xff95('0x2f')]=_[_0xff95('0x31')](db[_0xff95('0x2c')][_0xff95('0x2d')]);_0xa9a92b[_0xff95('0x30')]=_[_0xff95('0x31')](_0x57effb['query']);_0xa9a92b[_0xff95('0x32')]=_['intersection'](_0xa9a92b['model'],_0xa9a92b[_0xff95('0x30')]);_0x32ce40[_0xff95('0x35')]=_['intersection'](_0xa9a92b[_0xff95('0x2f')],qs[_0xff95('0x34')](_0x57effb['query'][_0xff95('0x34')]));_0x32ce40['attributes']=_0x32ce40[_0xff95('0x35')][_0xff95('0x46')]?_0x32ce40['attributes']:_0xa9a92b[_0xff95('0x2f')];if(_0x57effb[_0xff95('0x30')][_0xff95('0x47')]){_0x32ce40[_0xff95('0x40')]=[{'all':!![]}];}_0x32ce40=_['merge']({},_0x32ce40,_0x57effb[_0xff95('0x3f')]);return db['Sound'][_0xff95('0x48')](_0x32ce40)[_0xff95('0x21')](handleEntityNotFound(_0x2c6028,null))['then'](respondWithResult(_0x2c6028,null))[_0xff95('0x43')](handleError(_0x2c6028,null));};exports[_0xff95('0x49')]=function(_0x19b243,_0x5f5df3,_0x47c32b){return db[_0xff95('0x2c')]['find']({'where':{'id':_0x19b243[_0xff95('0x45')]['id']},'attributes':[_0xff95('0x28'),_0xff95('0x4a'),_0xff95('0x4b')],'raw':!![]})[_0xff95('0x21')](handleEntityNotFound(_0x5f5df3,null))[_0xff95('0x21')](function(_0x1fb870){if(_0x1fb870){if(!fs[_0xff95('0x4c')](path[_0xff95('0x4d')](config[_0xff95('0x4e')],_0xff95('0x4f'),_0x1fb870[_0xff95('0x4a')]+'.'+_0x1fb870[_0xff95('0x4b')]))){throw new db[(_0xff95('0x50'))][(_0xff95('0x51'))]('Sound\x20not\x20found');}return _0x5f5df3['download'](path[_0xff95('0x4d')](config['root'],_0xff95('0x4f'),util[_0xff95('0x52')](_0xff95('0x53'),_0x1fb870[_0xff95('0x4a')],_0x1fb870[_0xff95('0x4b')])),util[_0xff95('0x52')]('%s.%s',_0x1fb870[_0xff95('0x28')],_0x1fb870[_0xff95('0x4b')]));}return null;})[_0xff95('0x43')](handleError(_0x5f5df3,null));};exports[_0xff95('0x54')]=function(_0x26e853,_0x5c2971,_0x201b06){var _0x5b6873={'name':path[_0xff95('0x55')](_0x26e853[_0xff95('0x56')]['originalname'],path[_0xff95('0x57')](_0x26e853[_0xff95('0x56')][_0xff95('0x58')])),'save_name':path[_0xff95('0x55')](_0x26e853[_0xff95('0x56')][_0xff95('0x59')],path[_0xff95('0x57')](_0x26e853[_0xff95('0x56')][_0xff95('0x59')])),'original_format':path[_0xff95('0x57')](_0x26e853['file'][_0xff95('0x58')])['substring'](0x1),'converted_format':_0xff95('0x5a')};var _0x2d6edb=path[_0xff95('0x4d')](config['root'],'server/files/sounds/original',_0x26e853['file'][_0xff95('0x59')]);var _0x134d1a=path[_0xff95('0x4d')](config[_0xff95('0x4e')],'server/files/sounds/converted',util['format'](_0xff95('0x53'),path[_0xff95('0x55')](_0x26e853[_0xff95('0x56')][_0xff95('0x59')],path[_0xff95('0x57')](_0x26e853['file'][_0xff95('0x59')])),_0x5b6873[_0xff95('0x4b')]));logger[_0xff95('0x5b')]('Sound\x20upload\x20filepath:\x20%s',_0x2d6edb);logger[_0xff95('0x5b')](_0xff95('0x5c'),_0x134d1a);try{fs[_0xff95('0x5d')](_0x2d6edb,parseInt(_0xff95('0x5e'),0x8));var _0x7af392=sox[_0xff95('0x5f')](_0x2d6edb,_0x134d1a,{'sampleRate':0x1f40,'format':_0xff95('0x5a'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x7af392['on']('error',function(_0x48ef6f){fs[_0xff95('0x60')](_0x2d6edb);_0x5c2971[_0xff95('0x16')](0x1f4)[_0xff95('0x29')](_0x48ef6f);});_0x7af392['on'](_0xff95('0x61'),function(_0x541cda){_0x5b6873['original_duration']=isNaN(_0x541cda[_0xff95('0x62')])?null:_0x541cda['duration']*0x3e8;_0x5b6873[_0xff95('0x63')]=isNaN(_0x541cda[_0xff95('0x64')])?null:_0x541cda[_0xff95('0x64')];_0x5b6873['original_channelCount']=isNaN(_0x541cda[_0xff95('0x65')])?null:_0x541cda[_0xff95('0x65')];_0x5b6873['original_bitRate']=isNaN(_0x541cda[_0xff95('0x66')])?null:_0x541cda['bitRate'];_0x5b6873[_0xff95('0x67')]=isNaN(_0x541cda[_0xff95('0x68')])?null:_0x541cda[_0xff95('0x68')];});_0x7af392['on']('dest',function(_0x2707b9){_0x5b6873['converted_duration']=isNaN(_0x2707b9['duration'])?null:_0x2707b9[_0xff95('0x62')]*0x3e8;_0x5b6873[_0xff95('0x69')]=isNaN(_0x2707b9[_0xff95('0x64')])?null:_0x2707b9['sampleCount'];_0x5b6873[_0xff95('0x6a')]=isNaN(_0x2707b9['channelCount'])?null:_0x2707b9[_0xff95('0x65')];_0x5b6873[_0xff95('0x6b')]=isNaN(_0x2707b9[_0xff95('0x66')])?null:_0x2707b9[_0xff95('0x66')];_0x5b6873['converted_sampleRate']=isNaN(_0x2707b9[_0xff95('0x68')])?null:_0x2707b9[_0xff95('0x68')];});_0x7af392['on'](_0xff95('0x6c'),function(){fs[_0xff95('0x5d')](_0x134d1a,parseInt(_0xff95('0x5e'),0x8));return db[_0xff95('0x2c')][_0xff95('0x54')](_0x5b6873)[_0xff95('0x21')](function(_0x5d5186){var _0x409f96={'role':_0x26e853[_0xff95('0x6d')][_0xff95('0x6e')],'userProfileId':_0x26e853[_0xff95('0x6d')][_0xff95('0x6f')]};if(!_0x409f96)throw new Error(_0xff95('0x70'));if(_0x409f96[_0xff95('0x6e')]===_0xff95('0x71')){var _0x52c5b1=_0x5d5186[_0xff95('0x23')]({'plain':!![]});return db[_0xff95('0x72')]['find']({'where':{'name':_0xff95('0x24'),'userProfileId':_0x409f96[_0xff95('0x6f')]},'raw':!![]})[_0xff95('0x21')](function(_0x2797a4){if(_0x2797a4&&_0x2797a4['autoAssociation']===0x0){return db[_0xff95('0x25')][_0xff95('0x54')]({'name':_0x52c5b1[_0xff95('0x28')],'resourceId':_0x52c5b1['id'],'type':_0x2797a4[_0xff95('0x28')],'sectionId':_0x2797a4['id']},{})[_0xff95('0x21')](function(){return _0x5d5186;});}else{return _0x5d5186;}})[_0xff95('0x43')](function(_0x4f790a){logger[_0xff95('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4f790a);throw _0x4f790a;});}return _0x5d5186;})[_0xff95('0x21')](respondWithResult(_0x5c2971,null))['catch'](handleError(_0x5c2971,null));});_0x7af392[_0xff95('0x73')]();}catch(_0x379de3){_0x5c2971[_0xff95('0x16')](0x1f4)[_0xff95('0x29')](_0x379de3);}};exports['update']=function(_0x125eb4,_0x3cab9b,_0x4f6a0d){return db['Sound']['find']({'where':{'id':_0x125eb4[_0xff95('0x45')]['id']}})[_0xff95('0x21')](handleEntityNotFound(_0x3cab9b,null))['then'](saveUpdates(_[_0xff95('0x3a')](_0x125eb4[_0xff95('0x6d')],[_0xff95('0x28'),_0xff95('0x74')]),null))[_0xff95('0x21')](respondWithResult(_0x3cab9b,null))[_0xff95('0x43')](handleError(_0x3cab9b,null));};exports[_0xff95('0x75')]=function(_0x428bba,_0x37dec0,_0x40e985){return db[_0xff95('0x2c')][_0xff95('0x48')]({'where':{'id':_0x428bba[_0xff95('0x45')]['id']}})[_0xff95('0x21')](function(_0x5ee05c){if(_0x5ee05c){return _0x5ee05c['destroy']();}})[_0xff95('0x21')](function(_0x5c057b){var _0x201d65=path['join'](config['root'],'server/files/sounds/original',util[_0xff95('0x52')]('%s.%s',_0x5c057b[_0xff95('0x4a')],_0x5c057b[_0xff95('0x76')]));var _0x4f425e=path['join'](config[_0xff95('0x4e')],'server/files/sounds/converted',util[_0xff95('0x52')](_0xff95('0x53'),_0x5c057b['save_name'],_0x5c057b[_0xff95('0x4b')]));fs[_0xff95('0x60')](_0x201d65);fs[_0xff95('0x60')](_0x4f425e);return _0x5c057b;})[_0xff95('0x21')](function(_0x3adc74){if(_0x3adc74){return _0x37dec0[_0xff95('0x16')](0xcc)[_0xff95('0x6c')]();}})[_0xff95('0x21')](handleEntityNotFound(_0x37dec0,null))['catch'](handleError(_0x37dec0,null));};
\ No newline at end of file
+var _0x1859=['util','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','offset','undefined','count','limit','set','Content-Range','json','reject','save','update','destroy','then','get','Sounds','UserProfileResource','end','stack','name','index','map','Sound','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','rawAttributes','options','download','find','converted_format','existsSync','root','Sequelize','ValidationError','Sound\x20not\x20found','join','server/files/sounds/converted','format','%s.%s','save_name','basename','file','extname','originalname','filename','substring','wav','server/files/sounds/original','info','chmodSync','0777','error','send','src','original_duration','duration','original_sampleCount','sampleCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_bitRate','create','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','start','description','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache'];(function(_0x32e869,_0x5dc766){var _0x41d3a0=function(_0x20be93){while(--_0x20be93){_0x32e869['push'](_0x32e869['shift']());}};_0x41d3a0(++_0x5dc766);}(_0x1859,0x178));var _0x9185=function(_0x1fd2f7,_0x4d5811){_0x1fd2f7=_0x1fd2f7-0x0;var _0x4245ae=_0x1859[_0x1fd2f7];return _0x4245ae;};'use strict';var emlformat=require(_0x9185('0x0'));var rimraf=require(_0x9185('0x1'));var zipdir=require(_0x9185('0x2'));var jsonpatch=require(_0x9185('0x3'));var rp=require(_0x9185('0x4'));var moment=require(_0x9185('0x5'));var BPromise=require(_0x9185('0x6'));var Mustache=require(_0x9185('0x7'));var util=require(_0x9185('0x8'));var path=require(_0x9185('0x9'));var sox=require(_0x9185('0xa'));var csv=require('to-csv');var ejs=require(_0x9185('0xb'));var fs=require('fs');var fs_extra=require(_0x9185('0xc'));var _=require(_0x9185('0xd'));var squel=require(_0x9185('0xe'));var crypto=require('crypto');var jsforce=require(_0x9185('0xf'));var deskjs=require(_0x9185('0x10'));var toCsv=require(_0x9185('0x11'));var querystring=require(_0x9185('0x12'));var Papa=require(_0x9185('0x13'));var Redis=require('ioredis');var authService=require(_0x9185('0x14'));var qs=require(_0x9185('0x15'));var as=require(_0x9185('0x16'));var hardwareService=require(_0x9185('0x17'));var logger=require('../../config/logger')('api');var utils=require(_0x9185('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x9185('0x19'));var db=require(_0x9185('0x1a'))['db'];function respondWithStatusCode(_0x2fcb4e,_0x1899d3){_0x1899d3=_0x1899d3||0xcc;return function(_0x5b7d28){if(_0x5b7d28){return _0x2fcb4e[_0x9185('0x1b')](_0x1899d3);}return _0x2fcb4e[_0x9185('0x1c')](_0x1899d3)['end']();};}function respondWithResult(_0x5a1a39,_0x5eef24){_0x5eef24=_0x5eef24||0xc8;return function(_0x3cf890){if(_0x3cf890){return _0x5a1a39[_0x9185('0x1c')](_0x5eef24)['json'](_0x3cf890);}};}function respondWithFilteredResult(_0x3b490c,_0xd1ab53){return function(_0x1c8952){if(_0x1c8952){var _0x4bf8e8=typeof _0xd1ab53[_0x9185('0x1d')]==='undefined'&&typeof _0xd1ab53['limit']===_0x9185('0x1e');var _0x860b30=_0x1c8952[_0x9185('0x1f')];var _0x102427=_0x4bf8e8?0x0:_0xd1ab53[_0x9185('0x1d')];var _0x1fc6fa=_0x4bf8e8?_0x1c8952['count']:_0xd1ab53[_0x9185('0x1d')]+_0xd1ab53[_0x9185('0x20')];var _0x2f9c41;if(_0x1fc6fa>=_0x860b30){_0x1fc6fa=_0x860b30;_0x2f9c41=0xc8;}else{_0x2f9c41=0xce;}_0x3b490c['status'](_0x2f9c41);return _0x3b490c[_0x9185('0x21')](_0x9185('0x22'),_0x102427+'-'+_0x1fc6fa+'/'+_0x860b30)[_0x9185('0x23')](_0x1c8952);}return null;};}function patchUpdates(_0x185eff){return function(_0x44cf1c){try{jsonpatch['apply'](_0x44cf1c,_0x185eff,!![]);}catch(_0x2145a5){return BPromise[_0x9185('0x24')](_0x2145a5);}return _0x44cf1c[_0x9185('0x25')]();};}function saveUpdates(_0x542dfd,_0x49acd3){return function(_0x4307a3){if(_0x4307a3){return _0x4307a3[_0x9185('0x26')](_0x542dfd)['then'](function(_0x26da0e){return _0x26da0e;});}return null;};}function removeEntity(_0x48ffa3,_0x2b5b7d){return function(_0x2c60ac){if(_0x2c60ac){return _0x2c60ac[_0x9185('0x27')]()[_0x9185('0x28')](function(){var _0x31254c=_0x2c60ac[_0x9185('0x29')]({'plain':!![]});var _0x2ba509=_0x9185('0x2a');return db[_0x9185('0x2b')][_0x9185('0x27')]({'where':{'type':_0x2ba509,'resourceId':_0x31254c['id']}})['then'](function(){return _0x2c60ac;});})[_0x9185('0x28')](function(){_0x48ffa3[_0x9185('0x1c')](0xcc)[_0x9185('0x2c')]();});}};}function handleEntityNotFound(_0x34f244,_0x2075eb){return function(_0x249beb){if(!_0x249beb){_0x34f244[_0x9185('0x1b')](0x194);}return _0x249beb;};}function handleError(_0x59cf16,_0x5bb326){_0x5bb326=_0x5bb326||0x1f4;return function(_0x221a05){logger['error'](_0x221a05[_0x9185('0x2d')]);if(_0x221a05['name']){delete _0x221a05[_0x9185('0x2e')];}_0x59cf16[_0x9185('0x1c')](_0x5bb326)['send'](_0x221a05);};}exports[_0x9185('0x2f')]=function(_0x15adc5,_0x1364f7){var _0x1e1621={},_0x5b78a8={},_0x292e58={'count':0x0,'rows':[]};var _0x559acd=_[_0x9185('0x30')](db[_0x9185('0x31')]['rawAttributes'],function(_0x409923){return{'name':_0x409923[_0x9185('0x32')],'type':_0x409923[_0x9185('0x33')][_0x9185('0x34')]};});_0x5b78a8[_0x9185('0x35')]=_[_0x9185('0x30')](_0x559acd,_0x9185('0x2e'));_0x5b78a8[_0x9185('0x36')]=_[_0x9185('0x37')](_0x15adc5[_0x9185('0x36')]);_0x5b78a8['filters']=_[_0x9185('0x38')](_0x5b78a8[_0x9185('0x35')],_0x5b78a8[_0x9185('0x36')]);_0x1e1621[_0x9185('0x39')]=_[_0x9185('0x38')](_0x5b78a8[_0x9185('0x35')],qs[_0x9185('0x3a')](_0x15adc5[_0x9185('0x36')][_0x9185('0x3a')]));_0x1e1621['attributes']=_0x1e1621[_0x9185('0x39')][_0x9185('0x3b')]?_0x1e1621[_0x9185('0x39')]:_0x5b78a8[_0x9185('0x35')];if(!_0x15adc5['query']['hasOwnProperty'](_0x9185('0x3c'))){_0x1e1621[_0x9185('0x20')]=qs['limit'](_0x15adc5[_0x9185('0x36')][_0x9185('0x20')]);_0x1e1621['offset']=qs[_0x9185('0x1d')](_0x15adc5['query'][_0x9185('0x1d')]);}_0x1e1621[_0x9185('0x3d')]=qs[_0x9185('0x3e')](_0x15adc5[_0x9185('0x36')][_0x9185('0x3e')]);_0x1e1621[_0x9185('0x3f')]=qs['filters'](_[_0x9185('0x40')](_0x15adc5[_0x9185('0x36')],_0x5b78a8[_0x9185('0x41')]),_0x559acd);if(_0x15adc5[_0x9185('0x36')][_0x9185('0x42')]){_0x1e1621['where']=_[_0x9185('0x43')](_0x1e1621[_0x9185('0x3f')],{'$or':_[_0x9185('0x30')](_0x559acd,function(_0x489545){if(_0x489545[_0x9185('0x33')]!==_0x9185('0x44')){var _0xceee5f={};_0xceee5f[_0x489545[_0x9185('0x2e')]]={'$like':'%'+_0x15adc5[_0x9185('0x36')][_0x9185('0x42')]+'%'};return _0xceee5f;}})});}_0x1e1621=_[_0x9185('0x43')]({},_0x1e1621,_0x15adc5['options']);var _0x2bf859={'where':_0x1e1621[_0x9185('0x3f')]};return db[_0x9185('0x31')]['count'](_0x2bf859)[_0x9185('0x28')](function(_0x41b0dc){_0x292e58[_0x9185('0x1f')]=_0x41b0dc;if(_0x15adc5['query'][_0x9185('0x45')]){_0x1e1621[_0x9185('0x46')]=[{'all':!![]}];}return db[_0x9185('0x31')][_0x9185('0x47')](_0x1e1621);})[_0x9185('0x28')](function(_0x10f797){_0x292e58[_0x9185('0x48')]=_0x10f797;return _0x292e58;})[_0x9185('0x28')](respondWithFilteredResult(_0x1364f7,_0x1e1621))[_0x9185('0x49')](handleError(_0x1364f7,null));};exports[_0x9185('0x4a')]=function(_0x35c37e,_0x44422c){var _0x5cab99={'raw':!![],'where':{'id':_0x35c37e[_0x9185('0x4b')]['id']}},_0x544a85={};_0x544a85[_0x9185('0x35')]=_[_0x9185('0x37')](db[_0x9185('0x31')][_0x9185('0x4c')]);_0x544a85[_0x9185('0x36')]=_[_0x9185('0x37')](_0x35c37e['query']);_0x544a85['filters']=_[_0x9185('0x38')](_0x544a85[_0x9185('0x35')],_0x544a85[_0x9185('0x36')]);_0x5cab99['attributes']=_[_0x9185('0x38')](_0x544a85[_0x9185('0x35')],qs[_0x9185('0x3a')](_0x35c37e[_0x9185('0x36')][_0x9185('0x3a')]));_0x5cab99[_0x9185('0x39')]=_0x5cab99[_0x9185('0x39')][_0x9185('0x3b')]?_0x5cab99[_0x9185('0x39')]:_0x544a85[_0x9185('0x35')];if(_0x35c37e[_0x9185('0x36')][_0x9185('0x45')]){_0x5cab99[_0x9185('0x46')]=[{'all':!![]}];}_0x5cab99=_['merge']({},_0x5cab99,_0x35c37e[_0x9185('0x4d')]);return db[_0x9185('0x31')]['find'](_0x5cab99)['then'](handleEntityNotFound(_0x44422c,null))[_0x9185('0x28')](respondWithResult(_0x44422c,null))[_0x9185('0x49')](handleError(_0x44422c,null));};exports[_0x9185('0x4e')]=function(_0x6a0934,_0x347503,_0x3401bf){return db[_0x9185('0x31')][_0x9185('0x4f')]({'where':{'id':_0x6a0934[_0x9185('0x4b')]['id']},'attributes':['name','save_name',_0x9185('0x50')],'raw':!![]})[_0x9185('0x28')](handleEntityNotFound(_0x347503,null))[_0x9185('0x28')](function(_0x57c77d){if(_0x57c77d){if(!fs[_0x9185('0x51')](path['join'](config[_0x9185('0x52')],'server/files/sounds/converted',_0x57c77d['save_name']+'.'+_0x57c77d[_0x9185('0x50')]))){throw new db[(_0x9185('0x53'))][(_0x9185('0x54'))](_0x9185('0x55'));}return _0x347503[_0x9185('0x4e')](path[_0x9185('0x56')](config[_0x9185('0x52')],_0x9185('0x57'),util[_0x9185('0x58')](_0x9185('0x59'),_0x57c77d[_0x9185('0x5a')],_0x57c77d['converted_format'])),util['format'](_0x9185('0x59'),_0x57c77d['name'],_0x57c77d['converted_format']));}return null;})['catch'](handleError(_0x347503,null));};exports['create']=function(_0xef7e36,_0x1ad530,_0x21d839){var _0x68c1eb={'name':path[_0x9185('0x5b')](_0xef7e36[_0x9185('0x5c')]['originalname'],path[_0x9185('0x5d')](_0xef7e36['file'][_0x9185('0x5e')])),'save_name':path[_0x9185('0x5b')](_0xef7e36['file'][_0x9185('0x5f')],path[_0x9185('0x5d')](_0xef7e36[_0x9185('0x5c')][_0x9185('0x5f')])),'original_format':path[_0x9185('0x5d')](_0xef7e36[_0x9185('0x5c')][_0x9185('0x5e')])[_0x9185('0x60')](0x1),'converted_format':_0x9185('0x61')};var _0x5050fd=path['join'](config[_0x9185('0x52')],_0x9185('0x62'),_0xef7e36[_0x9185('0x5c')][_0x9185('0x5f')]);var _0x205812=path[_0x9185('0x56')](config[_0x9185('0x52')],_0x9185('0x57'),util[_0x9185('0x58')](_0x9185('0x59'),path[_0x9185('0x5b')](_0xef7e36[_0x9185('0x5c')][_0x9185('0x5f')],path[_0x9185('0x5d')](_0xef7e36[_0x9185('0x5c')][_0x9185('0x5f')])),_0x68c1eb[_0x9185('0x50')]));logger[_0x9185('0x63')]('Sound\x20upload\x20filepath:\x20%s',_0x5050fd);logger[_0x9185('0x63')]('Sound\x20upload\x20destination:\x20%s',_0x205812);try{fs[_0x9185('0x64')](_0x5050fd,parseInt(_0x9185('0x65'),0x8));var _0x7d542e=sox['transcode'](_0x5050fd,_0x205812,{'sampleRate':0x1f40,'format':_0x9185('0x61'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x7d542e['on'](_0x9185('0x66'),function(_0x5189cf){fs['unlinkSync'](_0x5050fd);_0x1ad530[_0x9185('0x1c')](0x1f4)[_0x9185('0x67')](_0x5189cf);});_0x7d542e['on'](_0x9185('0x68'),function(_0x47dcff){_0x68c1eb[_0x9185('0x69')]=isNaN(_0x47dcff[_0x9185('0x6a')])?null:_0x47dcff[_0x9185('0x6a')]*0x3e8;_0x68c1eb[_0x9185('0x6b')]=isNaN(_0x47dcff[_0x9185('0x6c')])?null:_0x47dcff[_0x9185('0x6c')];_0x68c1eb['original_channelCount']=isNaN(_0x47dcff[_0x9185('0x6d')])?null:_0x47dcff[_0x9185('0x6d')];_0x68c1eb[_0x9185('0x6e')]=isNaN(_0x47dcff[_0x9185('0x6f')])?null:_0x47dcff[_0x9185('0x6f')];_0x68c1eb[_0x9185('0x70')]=isNaN(_0x47dcff[_0x9185('0x71')])?null:_0x47dcff[_0x9185('0x71')];});_0x7d542e['on'](_0x9185('0x72'),function(_0x221866){_0x68c1eb[_0x9185('0x73')]=isNaN(_0x221866['duration'])?null:_0x221866[_0x9185('0x6a')]*0x3e8;_0x68c1eb[_0x9185('0x74')]=isNaN(_0x221866[_0x9185('0x6c')])?null:_0x221866[_0x9185('0x6c')];_0x68c1eb['converted_channelCount']=isNaN(_0x221866[_0x9185('0x6d')])?null:_0x221866['channelCount'];_0x68c1eb[_0x9185('0x75')]=isNaN(_0x221866['bitRate'])?null:_0x221866[_0x9185('0x6f')];_0x68c1eb['converted_sampleRate']=isNaN(_0x221866[_0x9185('0x71')])?null:_0x221866['sampleRate'];});_0x7d542e['on']('end',function(){fs[_0x9185('0x64')](_0x205812,parseInt(_0x9185('0x65'),0x8));return db[_0x9185('0x31')][_0x9185('0x76')](_0x68c1eb)['then'](function(_0x555838){var _0x5313c9={'role':_0xef7e36[_0x9185('0x77')][_0x9185('0x78')],'userProfileId':_0xef7e36[_0x9185('0x77')]['userProfileId']};if(!_0x5313c9)throw new Error(_0x9185('0x79'));if(_0x5313c9[_0x9185('0x78')]===_0x9185('0x7a')){var _0xc12b4f=_0x555838[_0x9185('0x29')]({'plain':!![]});return db[_0x9185('0x7b')][_0x9185('0x4f')]({'where':{'name':'Sounds','userProfileId':_0x5313c9['userProfileId']},'raw':!![]})[_0x9185('0x28')](function(_0x14ce14){if(_0x14ce14&&_0x14ce14[_0x9185('0x7c')]===0x0){return db[_0x9185('0x2b')]['create']({'name':_0xc12b4f[_0x9185('0x2e')],'resourceId':_0xc12b4f['id'],'type':_0x14ce14[_0x9185('0x2e')],'sectionId':_0x14ce14['id']},{})[_0x9185('0x28')](function(){return _0x555838;});}else{return _0x555838;}})['catch'](function(_0x220e69){logger[_0x9185('0x66')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x220e69);throw _0x220e69;});}return _0x555838;})[_0x9185('0x28')](respondWithResult(_0x1ad530,null))[_0x9185('0x49')](handleError(_0x1ad530,null));});_0x7d542e[_0x9185('0x7d')]();}catch(_0x5eb8b9){_0x1ad530[_0x9185('0x1c')](0x1f4)['send'](_0x5eb8b9);}};exports[_0x9185('0x26')]=function(_0x826925,_0x1f635c,_0x2594f6){return db[_0x9185('0x31')][_0x9185('0x4f')]({'where':{'id':_0x826925[_0x9185('0x4b')]['id']}})['then'](handleEntityNotFound(_0x1f635c,null))[_0x9185('0x28')](saveUpdates(_['pick'](_0x826925[_0x9185('0x77')],['name',_0x9185('0x7e')]),null))[_0x9185('0x28')](respondWithResult(_0x1f635c,null))[_0x9185('0x49')](handleError(_0x1f635c,null));};exports['delete']=function(_0x3f1404,_0x495170,_0x147547){return db[_0x9185('0x31')][_0x9185('0x4f')]({'where':{'id':_0x3f1404[_0x9185('0x4b')]['id']}})[_0x9185('0x28')](function(_0x49c753){if(_0x49c753){return _0x49c753[_0x9185('0x27')]();}})[_0x9185('0x28')](function(_0x52cbf5){var _0x555a50=path[_0x9185('0x56')](config[_0x9185('0x52')],_0x9185('0x62'),util[_0x9185('0x58')](_0x9185('0x59'),_0x52cbf5[_0x9185('0x5a')],_0x52cbf5['original_format']));var _0x34b6a3=path[_0x9185('0x56')](config['root'],_0x9185('0x57'),util['format'](_0x9185('0x59'),_0x52cbf5[_0x9185('0x5a')],_0x52cbf5[_0x9185('0x50')]));fs[_0x9185('0x7f')](_0x555a50);fs['unlinkSync'](_0x34b6a3);return _0x52cbf5;})[_0x9185('0x28')](function(_0x29a952){if(_0x29a952){return _0x495170[_0x9185('0x1c')](0xcc)[_0x9185('0x2c')]();}})['then'](handleEntityNotFound(_0x495170,null))[_0x9185('0x49')](handleError(_0x495170,null));};
\ No newline at end of file