Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / sound / sound.controller.js
index f0f5872..0c249de 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4c13=['reject','update','then','destroy','UserProfileResource','error','stack','name','send','map','Sound','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','catch','show','params','intersection','length','includeAll','download','save_name','converted_format','root','Sound\x20not\x20found','join','server/files/sounds/converted','format','%s.%s','create','basename','file','originalname','extname','filename','wav','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','transcode','unlinkSync','original_duration','duration','original_channelCount','channelCount','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_sampleCount','sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','0777','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','get','find','Sounds','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','description','delete','server/files/sounds/original','original_format','eml-format','rimraf','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','count','apply'];(function(_0x16c7d4,_0x1fd6a5){var _0x54c042=function(_0x2ef67c){while(--_0x2ef67c){_0x16c7d4['push'](_0x16c7d4['shift']());}};_0x54c042(++_0x1fd6a5);}(_0x4c13,0x153));var _0x34c1=function(_0x5f36f4,_0x24e9f1){_0x5f36f4=_0x5f36f4-0x0;var _0x1e600b=_0x4c13[_0x5f36f4];return _0x1e600b;};'use strict';var emlformat=require(_0x34c1('0x0'));var rimraf=require(_0x34c1('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x34c1('0x2'));var moment=require(_0x34c1('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x34c1('0x4'));var util=require(_0x34c1('0x5'));var path=require(_0x34c1('0x6'));var sox=require(_0x34c1('0x7'));var csv=require(_0x34c1('0x8'));var ejs=require(_0x34c1('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x34c1('0xa'));var squel=require('squel');var crypto=require(_0x34c1('0xb'));var jsforce=require(_0x34c1('0xc'));var deskjs=require(_0x34c1('0xd'));var toCsv=require(_0x34c1('0x8'));var querystring=require(_0x34c1('0xe'));var Papa=require(_0x34c1('0xf'));var Redis=require(_0x34c1('0x10'));var authService=require(_0x34c1('0x11'));var qs=require(_0x34c1('0x12'));var as=require(_0x34c1('0x13'));var hardwareService=require(_0x34c1('0x14'));var logger=require(_0x34c1('0x15'))('api');var utils=require(_0x34c1('0x16'));var config=require(_0x34c1('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x34c1('0x18'))['db'];function respondWithStatusCode(_0x158ef2,_0x4f017c){_0x4f017c=_0x4f017c||0xcc;return function(_0x5c44dc){if(_0x5c44dc){return _0x158ef2['sendStatus'](_0x4f017c);}return _0x158ef2[_0x34c1('0x19')](_0x4f017c)[_0x34c1('0x1a')]();};}function respondWithResult(_0x3cc992,_0x96e161){_0x96e161=_0x96e161||0xc8;return function(_0x5e07f2){if(_0x5e07f2){return _0x3cc992[_0x34c1('0x19')](_0x96e161)[_0x34c1('0x1b')](_0x5e07f2);}};}function respondWithFilteredResult(_0x1d7e60,_0x122e0e){return function(_0x530e35){if(_0x530e35){var _0x1cc8d1=typeof _0x122e0e[_0x34c1('0x1c')]===_0x34c1('0x1d')&&typeof _0x122e0e[_0x34c1('0x1e')]===_0x34c1('0x1d');var _0x29c505=_0x530e35[_0x34c1('0x1f')];var _0x438c83=_0x1cc8d1?0x0:_0x122e0e[_0x34c1('0x1c')];var _0x57d99f=_0x1cc8d1?_0x530e35[_0x34c1('0x1f')]:_0x122e0e[_0x34c1('0x1c')]+_0x122e0e['limit'];var _0x378b38;if(_0x57d99f>=_0x29c505){_0x57d99f=_0x29c505;_0x378b38=0xc8;}else{_0x378b38=0xce;}_0x1d7e60[_0x34c1('0x19')](_0x378b38);return _0x1d7e60['set']('Content-Range',_0x438c83+'-'+_0x57d99f+'/'+_0x29c505)[_0x34c1('0x1b')](_0x530e35);}return null;};}function patchUpdates(_0x51e7b3){return function(_0x3179da){try{jsonpatch[_0x34c1('0x20')](_0x3179da,_0x51e7b3,!![]);}catch(_0x52d17d){return BPromise[_0x34c1('0x21')](_0x52d17d);}return _0x3179da['save']();};}function saveUpdates(_0x28bc6f,_0x4422f0){return function(_0x248154){if(_0x248154){return _0x248154[_0x34c1('0x22')](_0x28bc6f)[_0x34c1('0x23')](function(_0x44c398){return _0x44c398;});}return null;};}function removeEntity(_0x55d3da,_0x2b7e48){return function(_0x348d28){if(_0x348d28){return _0x348d28[_0x34c1('0x24')]()[_0x34c1('0x23')](function(){var _0x47589b=_0x348d28['get']({'plain':!![]});var _0x44da35='Sounds';return db[_0x34c1('0x25')][_0x34c1('0x24')]({'where':{'type':_0x44da35,'resourceId':_0x47589b['id']}})['then'](function(){return _0x348d28;});})[_0x34c1('0x23')](function(){_0x55d3da[_0x34c1('0x19')](0xcc)[_0x34c1('0x1a')]();});}};}function handleEntityNotFound(_0x4b1bc3,_0x41bff6){return function(_0x46df70){if(!_0x46df70){_0x4b1bc3['sendStatus'](0x194);}return _0x46df70;};}function handleError(_0x3ffe15,_0x59a7de){_0x59a7de=_0x59a7de||0x1f4;return function(_0xafaea5){logger[_0x34c1('0x26')](_0xafaea5[_0x34c1('0x27')]);if(_0xafaea5[_0x34c1('0x28')]){delete _0xafaea5[_0x34c1('0x28')];}_0x3ffe15[_0x34c1('0x19')](_0x59a7de)[_0x34c1('0x29')](_0xafaea5);};}exports['index']=function(_0x43fd92,_0x3ef5b7){var _0x15cfeb={},_0x499367={},_0x4330fe={'count':0x0,'rows':[]};var _0x11fb70=_[_0x34c1('0x2a')](db[_0x34c1('0x2b')][_0x34c1('0x2c')],function(_0x57db22){return{'name':_0x57db22[_0x34c1('0x2d')],'type':_0x57db22[_0x34c1('0x2e')][_0x34c1('0x2f')]};});_0x499367[_0x34c1('0x30')]=_[_0x34c1('0x2a')](_0x11fb70,'name');_0x499367[_0x34c1('0x31')]=_[_0x34c1('0x32')](_0x43fd92[_0x34c1('0x31')]);_0x499367[_0x34c1('0x33')]=_['intersection'](_0x499367[_0x34c1('0x30')],_0x499367[_0x34c1('0x31')]);_0x15cfeb[_0x34c1('0x34')]=_['intersection'](_0x499367[_0x34c1('0x30')],qs['fields'](_0x43fd92['query'][_0x34c1('0x35')]));_0x15cfeb['attributes']=_0x15cfeb[_0x34c1('0x34')]['length']?_0x15cfeb[_0x34c1('0x34')]:_0x499367[_0x34c1('0x30')];if(!_0x43fd92[_0x34c1('0x31')][_0x34c1('0x36')](_0x34c1('0x37'))){_0x15cfeb['limit']=qs[_0x34c1('0x1e')](_0x43fd92['query'][_0x34c1('0x1e')]);_0x15cfeb[_0x34c1('0x1c')]=qs[_0x34c1('0x1c')](_0x43fd92[_0x34c1('0x31')][_0x34c1('0x1c')]);}_0x15cfeb[_0x34c1('0x38')]=qs[_0x34c1('0x39')](_0x43fd92['query'][_0x34c1('0x39')]);_0x15cfeb[_0x34c1('0x3a')]=qs['filters'](_[_0x34c1('0x3b')](_0x43fd92[_0x34c1('0x31')],_0x499367[_0x34c1('0x33')]),_0x11fb70);if(_0x43fd92[_0x34c1('0x31')][_0x34c1('0x3c')]){_0x15cfeb[_0x34c1('0x3a')]=_[_0x34c1('0x3d')](_0x15cfeb[_0x34c1('0x3a')],{'$or':_['map'](_0x11fb70,function(_0xc44540){if(_0xc44540[_0x34c1('0x2e')]!==_0x34c1('0x3e')){var _0x47255b={};_0x47255b[_0xc44540['name']]={'$like':'%'+_0x43fd92[_0x34c1('0x31')][_0x34c1('0x3c')]+'%'};return _0x47255b;}})});}_0x15cfeb=_['merge']({},_0x15cfeb,_0x43fd92[_0x34c1('0x3f')]);var _0x4162ad={'where':_0x15cfeb[_0x34c1('0x3a')]};return db[_0x34c1('0x2b')][_0x34c1('0x1f')](_0x4162ad)[_0x34c1('0x23')](function(_0x203567){_0x4330fe[_0x34c1('0x1f')]=_0x203567;if(_0x43fd92['query']['includeAll']){_0x15cfeb[_0x34c1('0x40')]=[{'all':!![]}];}return db[_0x34c1('0x2b')][_0x34c1('0x41')](_0x15cfeb);})[_0x34c1('0x23')](function(_0x20d5f5){_0x4330fe['rows']=_0x20d5f5;return _0x4330fe;})[_0x34c1('0x23')](respondWithFilteredResult(_0x3ef5b7,_0x15cfeb))[_0x34c1('0x42')](handleError(_0x3ef5b7,null));};exports[_0x34c1('0x43')]=function(_0xeda336,_0x567a05){var _0x2f9325={'raw':!![],'where':{'id':_0xeda336[_0x34c1('0x44')]['id']}},_0x1a9f1a={};_0x1a9f1a[_0x34c1('0x30')]=_[_0x34c1('0x32')](db[_0x34c1('0x2b')][_0x34c1('0x2c')]);_0x1a9f1a[_0x34c1('0x31')]=_[_0x34c1('0x32')](_0xeda336[_0x34c1('0x31')]);_0x1a9f1a[_0x34c1('0x33')]=_[_0x34c1('0x45')](_0x1a9f1a[_0x34c1('0x30')],_0x1a9f1a[_0x34c1('0x31')]);_0x2f9325[_0x34c1('0x34')]=_[_0x34c1('0x45')](_0x1a9f1a[_0x34c1('0x30')],qs[_0x34c1('0x35')](_0xeda336[_0x34c1('0x31')][_0x34c1('0x35')]));_0x2f9325['attributes']=_0x2f9325[_0x34c1('0x34')][_0x34c1('0x46')]?_0x2f9325['attributes']:_0x1a9f1a[_0x34c1('0x30')];if(_0xeda336[_0x34c1('0x31')][_0x34c1('0x47')]){_0x2f9325[_0x34c1('0x40')]=[{'all':!![]}];}_0x2f9325=_[_0x34c1('0x3d')]({},_0x2f9325,_0xeda336[_0x34c1('0x3f')]);return db[_0x34c1('0x2b')]['find'](_0x2f9325)[_0x34c1('0x23')](handleEntityNotFound(_0x567a05,null))['then'](respondWithResult(_0x567a05,null))[_0x34c1('0x42')](handleError(_0x567a05,null));};exports[_0x34c1('0x48')]=function(_0x19952f,_0x5f13f2,_0x2e0881){return db['Sound']['find']({'where':{'id':_0x19952f[_0x34c1('0x44')]['id']},'attributes':[_0x34c1('0x28'),_0x34c1('0x49'),_0x34c1('0x4a')],'raw':!![]})[_0x34c1('0x23')](handleEntityNotFound(_0x5f13f2,null))[_0x34c1('0x23')](function(_0x7622e8){if(_0x7622e8){if(!fs['existsSync'](path['join'](config[_0x34c1('0x4b')],'server/files/sounds/converted',_0x7622e8[_0x34c1('0x49')]+'.'+_0x7622e8['converted_format']))){throw new db['Sequelize']['ValidationError'](_0x34c1('0x4c'));}return _0x5f13f2['download'](path[_0x34c1('0x4d')](config[_0x34c1('0x4b')],_0x34c1('0x4e'),util[_0x34c1('0x4f')](_0x34c1('0x50'),_0x7622e8[_0x34c1('0x49')],_0x7622e8[_0x34c1('0x4a')])),util[_0x34c1('0x4f')](_0x34c1('0x50'),_0x7622e8['name'],_0x7622e8['converted_format']));}return null;})[_0x34c1('0x42')](handleError(_0x5f13f2,null));};exports[_0x34c1('0x51')]=function(_0x59d175,_0x4153bb,_0x26f36e){var _0x4b2e90={'name':path[_0x34c1('0x52')](_0x59d175[_0x34c1('0x53')][_0x34c1('0x54')],path[_0x34c1('0x55')](_0x59d175['file']['originalname'])),'save_name':path[_0x34c1('0x52')](_0x59d175[_0x34c1('0x53')][_0x34c1('0x56')],path[_0x34c1('0x55')](_0x59d175[_0x34c1('0x53')][_0x34c1('0x56')])),'original_format':path[_0x34c1('0x55')](_0x59d175[_0x34c1('0x53')][_0x34c1('0x54')])['substring'](0x1),'converted_format':_0x34c1('0x57')};var _0x15a90a=path[_0x34c1('0x4d')](config['root'],'server/files/sounds/original',_0x59d175[_0x34c1('0x53')]['filename']);var _0xf93675=path['join'](config['root'],_0x34c1('0x4e'),util[_0x34c1('0x4f')](_0x34c1('0x50'),path[_0x34c1('0x52')](_0x59d175[_0x34c1('0x53')]['filename'],path[_0x34c1('0x55')](_0x59d175['file']['filename'])),_0x4b2e90[_0x34c1('0x4a')]));logger[_0x34c1('0x58')](_0x34c1('0x59'),_0x15a90a);logger[_0x34c1('0x58')](_0x34c1('0x5a'),_0xf93675);try{fs[_0x34c1('0x5b')](_0x15a90a,parseInt('0777',0x8));var _0x8ddb7=sox[_0x34c1('0x5c')](_0x15a90a,_0xf93675,{'sampleRate':0x1f40,'format':_0x34c1('0x57'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x8ddb7['on'](_0x34c1('0x26'),function(_0xf0f8b7){fs[_0x34c1('0x5d')](_0x15a90a);_0x4153bb['status'](0x1f4)[_0x34c1('0x29')](_0xf0f8b7);});_0x8ddb7['on']('src',function(_0xe68f42){_0x4b2e90[_0x34c1('0x5e')]=isNaN(_0xe68f42[_0x34c1('0x5f')])?null:_0xe68f42['duration']*0x3e8;_0x4b2e90['original_sampleCount']=isNaN(_0xe68f42['sampleCount'])?null:_0xe68f42['sampleCount'];_0x4b2e90[_0x34c1('0x60')]=isNaN(_0xe68f42['channelCount'])?null:_0xe68f42[_0x34c1('0x61')];_0x4b2e90['original_bitRate']=isNaN(_0xe68f42[_0x34c1('0x62')])?null:_0xe68f42[_0x34c1('0x62')];_0x4b2e90[_0x34c1('0x63')]=isNaN(_0xe68f42[_0x34c1('0x64')])?null:_0xe68f42['sampleRate'];});_0x8ddb7['on'](_0x34c1('0x65'),function(_0x45d6e0){_0x4b2e90[_0x34c1('0x66')]=isNaN(_0x45d6e0[_0x34c1('0x5f')])?null:_0x45d6e0[_0x34c1('0x5f')]*0x3e8;_0x4b2e90[_0x34c1('0x67')]=isNaN(_0x45d6e0[_0x34c1('0x68')])?null:_0x45d6e0[_0x34c1('0x68')];_0x4b2e90[_0x34c1('0x69')]=isNaN(_0x45d6e0['channelCount'])?null:_0x45d6e0['channelCount'];_0x4b2e90[_0x34c1('0x6a')]=isNaN(_0x45d6e0['bitRate'])?null:_0x45d6e0['bitRate'];_0x4b2e90[_0x34c1('0x6b')]=isNaN(_0x45d6e0[_0x34c1('0x64')])?null:_0x45d6e0['sampleRate'];});_0x8ddb7['on'](_0x34c1('0x1a'),function(){fs[_0x34c1('0x5b')](_0xf93675,parseInt(_0x34c1('0x6c'),0x8));return db['Sound']['create'](_0x4b2e90)['then'](function(_0x5c60b4){var _0x9b1936={'role':_0x59d175[_0x34c1('0x6d')][_0x34c1('0x6e')],'userProfileId':_0x59d175[_0x34c1('0x6d')]['userProfileId']};if(!_0x9b1936)throw new Error(_0x34c1('0x6f'));if(_0x9b1936[_0x34c1('0x6e')]===_0x34c1('0x70')){var _0x5db80d=_0x5c60b4[_0x34c1('0x71')]({'plain':!![]});return db['UserProfileSection'][_0x34c1('0x72')]({'where':{'name':_0x34c1('0x73'),'userProfileId':_0x9b1936[_0x34c1('0x74')]},'raw':!![]})[_0x34c1('0x23')](function(_0x310715){if(_0x310715&&_0x310715[_0x34c1('0x75')]===0x0){return db['UserProfileResource'][_0x34c1('0x51')]({'name':_0x5db80d[_0x34c1('0x28')],'resourceId':_0x5db80d['id'],'type':_0x310715[_0x34c1('0x28')],'sectionId':_0x310715['id']},{})[_0x34c1('0x23')](function(){return _0x5c60b4;});}else{return _0x5c60b4;}})[_0x34c1('0x42')](function(_0x1aed86){logger[_0x34c1('0x26')](_0x34c1('0x76'),_0x1aed86);throw _0x1aed86;});}return _0x5c60b4;})[_0x34c1('0x23')](respondWithResult(_0x4153bb,null))[_0x34c1('0x42')](handleError(_0x4153bb,null));});_0x8ddb7[_0x34c1('0x77')]();}catch(_0x4ce723){_0x4153bb['status'](0x1f4)[_0x34c1('0x29')](_0x4ce723);}};exports[_0x34c1('0x22')]=function(_0x453094,_0x11942e,_0x315b19){return db[_0x34c1('0x2b')][_0x34c1('0x72')]({'where':{'id':_0x453094[_0x34c1('0x44')]['id']}})[_0x34c1('0x23')](handleEntityNotFound(_0x11942e,null))[_0x34c1('0x23')](saveUpdates(_[_0x34c1('0x3b')](_0x453094['body'],[_0x34c1('0x28'),_0x34c1('0x78')]),null))[_0x34c1('0x23')](respondWithResult(_0x11942e,null))['catch'](handleError(_0x11942e,null));};exports[_0x34c1('0x79')]=function(_0x1167b8,_0x184287,_0x5e48fb){return db['Sound'][_0x34c1('0x72')]({'where':{'id':_0x1167b8[_0x34c1('0x44')]['id']}})[_0x34c1('0x23')](function(_0xc8a0b4){if(_0xc8a0b4){return _0xc8a0b4[_0x34c1('0x24')]();}})[_0x34c1('0x23')](function(_0x474e90){var _0x3cc027=path['join'](config[_0x34c1('0x4b')],_0x34c1('0x7a'),util['format'](_0x34c1('0x50'),_0x474e90[_0x34c1('0x49')],_0x474e90[_0x34c1('0x7b')]));var _0x37313d=path[_0x34c1('0x4d')](config[_0x34c1('0x4b')],_0x34c1('0x4e'),util['format'](_0x34c1('0x50'),_0x474e90['save_name'],_0x474e90[_0x34c1('0x4a')]));fs[_0x34c1('0x5d')](_0x3cc027);fs[_0x34c1('0x5d')](_0x37313d);return _0x474e90;})[_0x34c1('0x23')](function(_0x307d0c){if(_0x307d0c){return _0x184287[_0x34c1('0x19')](0xcc)[_0x34c1('0x1a')]();}})[_0x34c1('0x23')](handleEntityNotFound(_0x184287,null))[_0x34c1('0x42')](handleError(_0x184287,null));};
\ No newline at end of file
+var _0x415f=['server/files/sounds/converted','Sequelize','ValidationError','Sound\x20not\x20found','format','%s.%s','create','basename','file','originalname','extname','filename','substring','wav','server/files/sounds/original','info','chmodSync','0777','transcode','unlinkSync','src','duration','original_sampleCount','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','converted_duration','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','send','pick','description','delete','original_format','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','get','Sounds','UserProfileResource','error','stack','name','index','map','Sound','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','sort','where','filter','merge','VIRTUAL','options','includeAll','include','catch','show','params','find','download','save_name','converted_format','existsSync','join','root'];(function(_0x27bd2c,_0x24bd98){var _0x3784ea=function(_0x4ca802){while(--_0x4ca802){_0x27bd2c['push'](_0x27bd2c['shift']());}};_0x3784ea(++_0x24bd98);}(_0x415f,0x12f));var _0xf415=function(_0x542459,_0x4a1296){_0x542459=_0x542459-0x0;var _0x3eaf66=_0x415f[_0x542459];return _0x3eaf66;};'use strict';var emlformat=require(_0xf415('0x0'));var rimraf=require(_0xf415('0x1'));var zipdir=require(_0xf415('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf415('0x3'));var moment=require(_0xf415('0x4'));var BPromise=require(_0xf415('0x5'));var Mustache=require(_0xf415('0x6'));var util=require(_0xf415('0x7'));var path=require(_0xf415('0x8'));var sox=require(_0xf415('0x9'));var csv=require(_0xf415('0xa'));var ejs=require(_0xf415('0xb'));var fs=require('fs');var fs_extra=require(_0xf415('0xc'));var _=require(_0xf415('0xd'));var squel=require('squel');var crypto=require(_0xf415('0xe'));var jsforce=require(_0xf415('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xf415('0xa'));var querystring=require(_0xf415('0x10'));var Papa=require(_0xf415('0x11'));var Redis=require(_0xf415('0x12'));var authService=require(_0xf415('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xf415('0x14'));var hardwareService=require(_0xf415('0x15'));var logger=require('../../config/logger')(_0xf415('0x16'));var utils=require('../../config/utils');var config=require(_0xf415('0x17'));var licenseUtil=require(_0xf415('0x18'));var db=require(_0xf415('0x19'))['db'];function respondWithStatusCode(_0x44aa16,_0x1349ea){_0x1349ea=_0x1349ea||0xcc;return function(_0xc9f2f4){if(_0xc9f2f4){return _0x44aa16[_0xf415('0x1a')](_0x1349ea);}return _0x44aa16['status'](_0x1349ea)[_0xf415('0x1b')]();};}function respondWithResult(_0x5e8690,_0x55d78d){_0x55d78d=_0x55d78d||0xc8;return function(_0x49c217){if(_0x49c217){return _0x5e8690[_0xf415('0x1c')](_0x55d78d)[_0xf415('0x1d')](_0x49c217);}};}function respondWithFilteredResult(_0x421690,_0x22c154){return function(_0x533309){if(_0x533309){var _0x560f7c=typeof _0x22c154[_0xf415('0x1e')]===_0xf415('0x1f')&&typeof _0x22c154[_0xf415('0x20')]==='undefined';var _0xa33850=_0x533309[_0xf415('0x21')];var _0x265993=_0x560f7c?0x0:_0x22c154[_0xf415('0x1e')];var _0x207d84=_0x560f7c?_0x533309['count']:_0x22c154[_0xf415('0x1e')]+_0x22c154[_0xf415('0x20')];var _0x456b03;if(_0x207d84>=_0xa33850){_0x207d84=_0xa33850;_0x456b03=0xc8;}else{_0x456b03=0xce;}_0x421690[_0xf415('0x1c')](_0x456b03);return _0x421690[_0xf415('0x22')](_0xf415('0x23'),_0x265993+'-'+_0x207d84+'/'+_0xa33850)['json'](_0x533309);}return null;};}function patchUpdates(_0x4bd8e9){return function(_0x1a86d4){try{jsonpatch['apply'](_0x1a86d4,_0x4bd8e9,!![]);}catch(_0x369208){return BPromise[_0xf415('0x24')](_0x369208);}return _0x1a86d4[_0xf415('0x25')]();};}function saveUpdates(_0x178ecb,_0x23ab2b){return function(_0x5ac04f){if(_0x5ac04f){return _0x5ac04f[_0xf415('0x26')](_0x178ecb)[_0xf415('0x27')](function(_0x1e9b00){return _0x1e9b00;});}return null;};}function removeEntity(_0x5610f8,_0x359114){return function(_0x1e82ce){if(_0x1e82ce){return _0x1e82ce[_0xf415('0x28')]()['then'](function(){var _0x1bf35f=_0x1e82ce[_0xf415('0x29')]({'plain':!![]});var _0x1c98a7=_0xf415('0x2a');return db[_0xf415('0x2b')][_0xf415('0x28')]({'where':{'type':_0x1c98a7,'resourceId':_0x1bf35f['id']}})[_0xf415('0x27')](function(){return _0x1e82ce;});})[_0xf415('0x27')](function(){_0x5610f8['status'](0xcc)[_0xf415('0x1b')]();});}};}function handleEntityNotFound(_0x4eec94,_0x43facd){return function(_0x1aa1fa){if(!_0x1aa1fa){_0x4eec94['sendStatus'](0x194);}return _0x1aa1fa;};}function handleError(_0x16153d,_0x974741){_0x974741=_0x974741||0x1f4;return function(_0x2b3b0d){logger[_0xf415('0x2c')](_0x2b3b0d[_0xf415('0x2d')]);if(_0x2b3b0d[_0xf415('0x2e')]){delete _0x2b3b0d['name'];}_0x16153d[_0xf415('0x1c')](_0x974741)['send'](_0x2b3b0d);};}exports[_0xf415('0x2f')]=function(_0x4ee7cd,_0xfc64fa){var _0x1b49a4={},_0x3c9ef3={},_0xe0d37b={'count':0x0,'rows':[]};var _0x1c56a9=_[_0xf415('0x30')](db[_0xf415('0x31')][_0xf415('0x32')],function(_0x452e70){return{'name':_0x452e70[_0xf415('0x33')],'type':_0x452e70[_0xf415('0x34')][_0xf415('0x35')]};});_0x3c9ef3[_0xf415('0x36')]=_[_0xf415('0x30')](_0x1c56a9,_0xf415('0x2e'));_0x3c9ef3['query']=_[_0xf415('0x37')](_0x4ee7cd[_0xf415('0x38')]);_0x3c9ef3[_0xf415('0x39')]=_['intersection'](_0x3c9ef3[_0xf415('0x36')],_0x3c9ef3['query']);_0x1b49a4[_0xf415('0x3a')]=_[_0xf415('0x3b')](_0x3c9ef3[_0xf415('0x36')],qs['fields'](_0x4ee7cd[_0xf415('0x38')][_0xf415('0x3c')]));_0x1b49a4[_0xf415('0x3a')]=_0x1b49a4[_0xf415('0x3a')][_0xf415('0x3d')]?_0x1b49a4['attributes']:_0x3c9ef3[_0xf415('0x36')];if(!_0x4ee7cd[_0xf415('0x38')][_0xf415('0x3e')]('nolimit')){_0x1b49a4[_0xf415('0x20')]=qs[_0xf415('0x20')](_0x4ee7cd[_0xf415('0x38')][_0xf415('0x20')]);_0x1b49a4[_0xf415('0x1e')]=qs['offset'](_0x4ee7cd[_0xf415('0x38')][_0xf415('0x1e')]);}_0x1b49a4['order']=qs[_0xf415('0x3f')](_0x4ee7cd['query'][_0xf415('0x3f')]);_0x1b49a4[_0xf415('0x40')]=qs['filters'](_['pick'](_0x4ee7cd['query'],_0x3c9ef3['filters']),_0x1c56a9);if(_0x4ee7cd['query'][_0xf415('0x41')]){_0x1b49a4[_0xf415('0x40')]=_[_0xf415('0x42')](_0x1b49a4[_0xf415('0x40')],{'$or':_['map'](_0x1c56a9,function(_0x530118){if(_0x530118[_0xf415('0x34')]!==_0xf415('0x43')){var _0x2eb522={};_0x2eb522[_0x530118[_0xf415('0x2e')]]={'$like':'%'+_0x4ee7cd[_0xf415('0x38')][_0xf415('0x41')]+'%'};return _0x2eb522;}})});}_0x1b49a4=_['merge']({},_0x1b49a4,_0x4ee7cd[_0xf415('0x44')]);var _0x448d95={'where':_0x1b49a4[_0xf415('0x40')]};return db[_0xf415('0x31')][_0xf415('0x21')](_0x448d95)['then'](function(_0x538853){_0xe0d37b[_0xf415('0x21')]=_0x538853;if(_0x4ee7cd[_0xf415('0x38')][_0xf415('0x45')]){_0x1b49a4[_0xf415('0x46')]=[{'all':!![]}];}return db['Sound']['findAll'](_0x1b49a4);})[_0xf415('0x27')](function(_0xa2bf6e){_0xe0d37b['rows']=_0xa2bf6e;return _0xe0d37b;})[_0xf415('0x27')](respondWithFilteredResult(_0xfc64fa,_0x1b49a4))[_0xf415('0x47')](handleError(_0xfc64fa,null));};exports[_0xf415('0x48')]=function(_0x1c4bee,_0x7a76e4){var _0x1dcb3a={'raw':!![],'where':{'id':_0x1c4bee[_0xf415('0x49')]['id']}},_0x55d3e3={};_0x55d3e3[_0xf415('0x36')]=_[_0xf415('0x37')](db['Sound'][_0xf415('0x32')]);_0x55d3e3['query']=_['keys'](_0x1c4bee[_0xf415('0x38')]);_0x55d3e3[_0xf415('0x39')]=_[_0xf415('0x3b')](_0x55d3e3[_0xf415('0x36')],_0x55d3e3[_0xf415('0x38')]);_0x1dcb3a[_0xf415('0x3a')]=_[_0xf415('0x3b')](_0x55d3e3[_0xf415('0x36')],qs[_0xf415('0x3c')](_0x1c4bee[_0xf415('0x38')][_0xf415('0x3c')]));_0x1dcb3a[_0xf415('0x3a')]=_0x1dcb3a[_0xf415('0x3a')][_0xf415('0x3d')]?_0x1dcb3a[_0xf415('0x3a')]:_0x55d3e3[_0xf415('0x36')];if(_0x1c4bee[_0xf415('0x38')][_0xf415('0x45')]){_0x1dcb3a[_0xf415('0x46')]=[{'all':!![]}];}_0x1dcb3a=_[_0xf415('0x42')]({},_0x1dcb3a,_0x1c4bee[_0xf415('0x44')]);return db['Sound'][_0xf415('0x4a')](_0x1dcb3a)[_0xf415('0x27')](handleEntityNotFound(_0x7a76e4,null))[_0xf415('0x27')](respondWithResult(_0x7a76e4,null))[_0xf415('0x47')](handleError(_0x7a76e4,null));};exports[_0xf415('0x4b')]=function(_0x2f52fd,_0x27fe44,_0x2524e9){return db['Sound'][_0xf415('0x4a')]({'where':{'id':_0x2f52fd[_0xf415('0x49')]['id']},'attributes':[_0xf415('0x2e'),_0xf415('0x4c'),_0xf415('0x4d')],'raw':!![]})['then'](handleEntityNotFound(_0x27fe44,null))['then'](function(_0x228c95){if(_0x228c95){if(!fs[_0xf415('0x4e')](path[_0xf415('0x4f')](config[_0xf415('0x50')],_0xf415('0x51'),_0x228c95[_0xf415('0x4c')]+'.'+_0x228c95[_0xf415('0x4d')]))){throw new db[(_0xf415('0x52'))][(_0xf415('0x53'))](_0xf415('0x54'));}return _0x27fe44['download'](path[_0xf415('0x4f')](config[_0xf415('0x50')],_0xf415('0x51'),util['format']('%s.%s',_0x228c95[_0xf415('0x4c')],_0x228c95[_0xf415('0x4d')])),util[_0xf415('0x55')](_0xf415('0x56'),_0x228c95[_0xf415('0x2e')],_0x228c95[_0xf415('0x4d')]));}return null;})[_0xf415('0x47')](handleError(_0x27fe44,null));};exports[_0xf415('0x57')]=function(_0x1d231e,_0x44f640,_0x1844ac){var _0x596875={'name':path[_0xf415('0x58')](_0x1d231e[_0xf415('0x59')][_0xf415('0x5a')],path[_0xf415('0x5b')](_0x1d231e[_0xf415('0x59')][_0xf415('0x5a')])),'save_name':path[_0xf415('0x58')](_0x1d231e[_0xf415('0x59')]['filename'],path[_0xf415('0x5b')](_0x1d231e['file'][_0xf415('0x5c')])),'original_format':path[_0xf415('0x5b')](_0x1d231e[_0xf415('0x59')]['originalname'])[_0xf415('0x5d')](0x1),'converted_format':_0xf415('0x5e')};var _0x6994ff=path[_0xf415('0x4f')](config[_0xf415('0x50')],_0xf415('0x5f'),_0x1d231e[_0xf415('0x59')][_0xf415('0x5c')]);var _0x14556c=path['join'](config[_0xf415('0x50')],'server/files/sounds/converted',util[_0xf415('0x55')](_0xf415('0x56'),path['basename'](_0x1d231e['file']['filename'],path[_0xf415('0x5b')](_0x1d231e[_0xf415('0x59')][_0xf415('0x5c')])),_0x596875[_0xf415('0x4d')]));logger[_0xf415('0x60')]('Sound\x20upload\x20filepath:\x20%s',_0x6994ff);logger[_0xf415('0x60')]('Sound\x20upload\x20destination:\x20%s',_0x14556c);try{fs[_0xf415('0x61')](_0x6994ff,parseInt(_0xf415('0x62'),0x8));var _0x4dabdf=sox[_0xf415('0x63')](_0x6994ff,_0x14556c,{'sampleRate':0x1f40,'format':_0xf415('0x5e'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x4dabdf['on'](_0xf415('0x2c'),function(_0xf883e3){fs[_0xf415('0x64')](_0x6994ff);_0x44f640[_0xf415('0x1c')](0x1f4)['send'](_0xf883e3);});_0x4dabdf['on'](_0xf415('0x65'),function(_0xba0cd3){_0x596875['original_duration']=isNaN(_0xba0cd3[_0xf415('0x66')])?null:_0xba0cd3[_0xf415('0x66')]*0x3e8;_0x596875[_0xf415('0x67')]=isNaN(_0xba0cd3[_0xf415('0x68')])?null:_0xba0cd3[_0xf415('0x68')];_0x596875[_0xf415('0x69')]=isNaN(_0xba0cd3[_0xf415('0x6a')])?null:_0xba0cd3[_0xf415('0x6a')];_0x596875[_0xf415('0x6b')]=isNaN(_0xba0cd3[_0xf415('0x6c')])?null:_0xba0cd3[_0xf415('0x6c')];_0x596875[_0xf415('0x6d')]=isNaN(_0xba0cd3[_0xf415('0x6e')])?null:_0xba0cd3['sampleRate'];});_0x4dabdf['on']('dest',function(_0x275401){_0x596875[_0xf415('0x6f')]=isNaN(_0x275401[_0xf415('0x66')])?null:_0x275401[_0xf415('0x66')]*0x3e8;_0x596875['converted_sampleCount']=isNaN(_0x275401[_0xf415('0x68')])?null:_0x275401['sampleCount'];_0x596875[_0xf415('0x70')]=isNaN(_0x275401[_0xf415('0x6a')])?null:_0x275401[_0xf415('0x6a')];_0x596875[_0xf415('0x71')]=isNaN(_0x275401[_0xf415('0x6c')])?null:_0x275401['bitRate'];_0x596875[_0xf415('0x72')]=isNaN(_0x275401[_0xf415('0x6e')])?null:_0x275401[_0xf415('0x6e')];});_0x4dabdf['on'](_0xf415('0x1b'),function(){fs[_0xf415('0x61')](_0x14556c,parseInt(_0xf415('0x62'),0x8));return db[_0xf415('0x31')][_0xf415('0x57')](_0x596875)[_0xf415('0x27')](function(_0x47d947){var _0x43287a={'role':_0x1d231e[_0xf415('0x73')]['role'],'userProfileId':_0x1d231e[_0xf415('0x73')][_0xf415('0x74')]};if(!_0x43287a)throw new Error(_0xf415('0x75'));if(_0x43287a[_0xf415('0x76')]===_0xf415('0x77')){var _0x482e7a=_0x47d947[_0xf415('0x29')]({'plain':!![]});return db[_0xf415('0x78')][_0xf415('0x4a')]({'where':{'name':_0xf415('0x2a'),'userProfileId':_0x43287a[_0xf415('0x74')]},'raw':!![]})[_0xf415('0x27')](function(_0x2ea78f){if(_0x2ea78f&&_0x2ea78f['autoAssociation']===0x0){return db[_0xf415('0x2b')][_0xf415('0x57')]({'name':_0x482e7a[_0xf415('0x2e')],'resourceId':_0x482e7a['id'],'type':_0x2ea78f[_0xf415('0x2e')],'sectionId':_0x2ea78f['id']},{})['then'](function(){return _0x47d947;});}else{return _0x47d947;}})['catch'](function(_0x19c754){logger[_0xf415('0x2c')](_0xf415('0x79'),_0x19c754);throw _0x19c754;});}return _0x47d947;})[_0xf415('0x27')](respondWithResult(_0x44f640,null))[_0xf415('0x47')](handleError(_0x44f640,null));});_0x4dabdf[_0xf415('0x7a')]();}catch(_0x4ade7d){_0x44f640[_0xf415('0x1c')](0x1f4)[_0xf415('0x7b')](_0x4ade7d);}};exports[_0xf415('0x26')]=function(_0x329ec0,_0x2c2d11,_0x31bb4d){return db[_0xf415('0x31')]['find']({'where':{'id':_0x329ec0[_0xf415('0x49')]['id']}})[_0xf415('0x27')](handleEntityNotFound(_0x2c2d11,null))[_0xf415('0x27')](saveUpdates(_[_0xf415('0x7c')](_0x329ec0[_0xf415('0x73')],[_0xf415('0x2e'),_0xf415('0x7d')]),null))[_0xf415('0x27')](respondWithResult(_0x2c2d11,null))[_0xf415('0x47')](handleError(_0x2c2d11,null));};exports[_0xf415('0x7e')]=function(_0x4415f2,_0x5245b4,_0x10a0d0){return db[_0xf415('0x31')][_0xf415('0x4a')]({'where':{'id':_0x4415f2[_0xf415('0x49')]['id']}})[_0xf415('0x27')](function(_0x284914){if(_0x284914){return _0x284914[_0xf415('0x28')]();}})[_0xf415('0x27')](function(_0x179b56){var _0x150377=path[_0xf415('0x4f')](config[_0xf415('0x50')],_0xf415('0x5f'),util[_0xf415('0x55')]('%s.%s',_0x179b56[_0xf415('0x4c')],_0x179b56[_0xf415('0x7f')]));var _0x7f1c6b=path[_0xf415('0x4f')](config[_0xf415('0x50')],_0xf415('0x51'),util[_0xf415('0x55')]('%s.%s',_0x179b56[_0xf415('0x4c')],_0x179b56[_0xf415('0x4d')]));fs[_0xf415('0x64')](_0x150377);fs[_0xf415('0x64')](_0x7f1c6b);return _0x179b56;})[_0xf415('0x27')](function(_0x2ab9f0){if(_0x2ab9f0){return _0x5245b4[_0xf415('0x1c')](0xcc)[_0xf415('0x1b')]();}})['then'](handleEntityNotFound(_0x5245b4,null))[_0xf415('0x47')](handleError(_0x5245b4,null));};
\ No newline at end of file