Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / sound / sound.controller.js
index c4defd1..f0f5872 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcf25=['ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','set','Content-Range','apply','reject','save','then','destroy','get','Sounds','UserProfileResource','error','stack','name','send','index','Sound','rawAttributes','fieldName','type','key','model','map','keys','query','intersection','fields','length','attributes','hasOwnProperty','limit','order','sort','where','pick','filters','filter','merge','VIRTUAL','include','findAll','rows','catch','show','params','includeAll','download','save_name','converted_format','existsSync','join','root','Sequelize','ValidationError','Sound\x20not\x20found','server/files/sounds/converted','format','%s.%s','create','basename','extname','file','filename','wav','server/files/sounds/original','info','Sound\x20upload\x20destination:\x20%s','0777','transcode','unlinkSync','src','original_duration','duration','sampleCount','original_channelCount','channelCount','bitRate','original_sampleRate','sampleRate','dest','converted_duration','converted_sampleCount','converted_channelCount','chmodSync','body','role','userProfileId','user','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','start','description','delete','original_format','eml-format','zip-dir','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','papaparse'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xcf25,0x6e));var _0x5cf2=function(_0xb2652a,_0x31610a){_0xb2652a=_0xb2652a-0x0;var _0x290cb1=_0xcf25[_0xb2652a];return _0x290cb1;};'use strict';var emlformat=require(_0x5cf2('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5cf2('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5cf2('0x2'));var moment=require(_0x5cf2('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x5cf2('0x4'));var util=require(_0x5cf2('0x5'));var path=require('path');var sox=require(_0x5cf2('0x6'));var csv=require(_0x5cf2('0x7'));var ejs=require(_0x5cf2('0x8'));var fs=require('fs');var fs_extra=require(_0x5cf2('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x5cf2('0xa'));var jsforce=require(_0x5cf2('0xb'));var deskjs=require(_0x5cf2('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x5cf2('0xd'));var Redis=require(_0x5cf2('0xe'));var authService=require(_0x5cf2('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x5cf2('0x10'));var hardwareService=require(_0x5cf2('0x11'));var logger=require(_0x5cf2('0x12'))('api');var utils=require(_0x5cf2('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x5cf2('0x14'));var db=require(_0x5cf2('0x15'))['db'];function respondWithStatusCode(_0x4465c6,_0x13df21){_0x13df21=_0x13df21||0xcc;return function(_0x2a8a53){if(_0x2a8a53){return _0x4465c6[_0x5cf2('0x16')](_0x13df21);}return _0x4465c6['status'](_0x13df21)[_0x5cf2('0x17')]();};}function respondWithResult(_0x3e236e,_0x3bc56d){_0x3bc56d=_0x3bc56d||0xc8;return function(_0x22042b){if(_0x22042b){return _0x3e236e[_0x5cf2('0x18')](_0x3bc56d)[_0x5cf2('0x19')](_0x22042b);}};}function respondWithFilteredResult(_0x3beef5,_0x11ef19){return function(_0x2d925f){if(_0x2d925f){var _0x4a6080=typeof _0x11ef19[_0x5cf2('0x1a')]==='undefined'&&typeof _0x11ef19['limit']===_0x5cf2('0x1b');var _0x13bd79=_0x2d925f[_0x5cf2('0x1c')];var _0x56a63f=_0x4a6080?0x0:_0x11ef19[_0x5cf2('0x1a')];var _0xfa14d7=_0x4a6080?_0x2d925f[_0x5cf2('0x1c')]:_0x11ef19['offset']+_0x11ef19['limit'];var _0x9bd1e5;if(_0xfa14d7>=_0x13bd79){_0xfa14d7=_0x13bd79;_0x9bd1e5=0xc8;}else{_0x9bd1e5=0xce;}_0x3beef5[_0x5cf2('0x18')](_0x9bd1e5);return _0x3beef5[_0x5cf2('0x1d')](_0x5cf2('0x1e'),_0x56a63f+'-'+_0xfa14d7+'/'+_0x13bd79)['json'](_0x2d925f);}return null;};}function patchUpdates(_0x3ffff8){return function(_0x1afc7b){try{jsonpatch[_0x5cf2('0x1f')](_0x1afc7b,_0x3ffff8,!![]);}catch(_0x69bcd){return BPromise[_0x5cf2('0x20')](_0x69bcd);}return _0x1afc7b[_0x5cf2('0x21')]();};}function saveUpdates(_0x428e73,_0x1930fb){return function(_0x3ba604){if(_0x3ba604){return _0x3ba604['update'](_0x428e73)[_0x5cf2('0x22')](function(_0x8cf634){return _0x8cf634;});}return null;};}function removeEntity(_0x5a416f,_0x493f63){return function(_0x460fae){if(_0x460fae){return _0x460fae[_0x5cf2('0x23')]()['then'](function(){var _0x4e82e4=_0x460fae[_0x5cf2('0x24')]({'plain':!![]});var _0x296db7=_0x5cf2('0x25');return db[_0x5cf2('0x26')][_0x5cf2('0x23')]({'where':{'type':_0x296db7,'resourceId':_0x4e82e4['id']}})[_0x5cf2('0x22')](function(){return _0x460fae;});})[_0x5cf2('0x22')](function(){_0x5a416f['status'](0xcc)[_0x5cf2('0x17')]();});}};}function handleEntityNotFound(_0x10f8e5,_0x5ce17f){return function(_0x3d336a){if(!_0x3d336a){_0x10f8e5['sendStatus'](0x194);}return _0x3d336a;};}function handleError(_0xc1605,_0x4eef6c){_0x4eef6c=_0x4eef6c||0x1f4;return function(_0x2a0917){logger[_0x5cf2('0x27')](_0x2a0917[_0x5cf2('0x28')]);if(_0x2a0917[_0x5cf2('0x29')]){delete _0x2a0917['name'];}_0xc1605[_0x5cf2('0x18')](_0x4eef6c)[_0x5cf2('0x2a')](_0x2a0917);};}exports[_0x5cf2('0x2b')]=function(_0x425cf8,_0x3af023){var _0x491f5c={},_0x3238ad={},_0x10c416={'count':0x0,'rows':[]};var _0x221588=_['map'](db[_0x5cf2('0x2c')][_0x5cf2('0x2d')],function(_0x21adff){return{'name':_0x21adff[_0x5cf2('0x2e')],'type':_0x21adff[_0x5cf2('0x2f')][_0x5cf2('0x30')]};});_0x3238ad[_0x5cf2('0x31')]=_[_0x5cf2('0x32')](_0x221588,_0x5cf2('0x29'));_0x3238ad['query']=_[_0x5cf2('0x33')](_0x425cf8[_0x5cf2('0x34')]);_0x3238ad['filters']=_[_0x5cf2('0x35')](_0x3238ad['model'],_0x3238ad[_0x5cf2('0x34')]);_0x491f5c['attributes']=_[_0x5cf2('0x35')](_0x3238ad[_0x5cf2('0x31')],qs['fields'](_0x425cf8[_0x5cf2('0x34')][_0x5cf2('0x36')]));_0x491f5c['attributes']=_0x491f5c['attributes'][_0x5cf2('0x37')]?_0x491f5c[_0x5cf2('0x38')]:_0x3238ad[_0x5cf2('0x31')];if(!_0x425cf8[_0x5cf2('0x34')][_0x5cf2('0x39')]('nolimit')){_0x491f5c['limit']=qs[_0x5cf2('0x3a')](_0x425cf8[_0x5cf2('0x34')]['limit']);_0x491f5c['offset']=qs[_0x5cf2('0x1a')](_0x425cf8[_0x5cf2('0x34')][_0x5cf2('0x1a')]);}_0x491f5c[_0x5cf2('0x3b')]=qs[_0x5cf2('0x3c')](_0x425cf8[_0x5cf2('0x34')][_0x5cf2('0x3c')]);_0x491f5c[_0x5cf2('0x3d')]=qs['filters'](_[_0x5cf2('0x3e')](_0x425cf8['query'],_0x3238ad[_0x5cf2('0x3f')]),_0x221588);if(_0x425cf8[_0x5cf2('0x34')][_0x5cf2('0x40')]){_0x491f5c[_0x5cf2('0x3d')]=_[_0x5cf2('0x41')](_0x491f5c[_0x5cf2('0x3d')],{'$or':_[_0x5cf2('0x32')](_0x221588,function(_0x3078c3){if(_0x3078c3[_0x5cf2('0x2f')]!==_0x5cf2('0x42')){var _0x15dc02={};_0x15dc02[_0x3078c3['name']]={'$like':'%'+_0x425cf8[_0x5cf2('0x34')]['filter']+'%'};return _0x15dc02;}})});}_0x491f5c=_[_0x5cf2('0x41')]({},_0x491f5c,_0x425cf8['options']);var _0x1db275={'where':_0x491f5c['where']};return db[_0x5cf2('0x2c')]['count'](_0x1db275)[_0x5cf2('0x22')](function(_0x4aa0ef){_0x10c416[_0x5cf2('0x1c')]=_0x4aa0ef;if(_0x425cf8['query']['includeAll']){_0x491f5c[_0x5cf2('0x43')]=[{'all':!![]}];}return db['Sound'][_0x5cf2('0x44')](_0x491f5c);})[_0x5cf2('0x22')](function(_0x259a5d){_0x10c416[_0x5cf2('0x45')]=_0x259a5d;return _0x10c416;})[_0x5cf2('0x22')](respondWithFilteredResult(_0x3af023,_0x491f5c))[_0x5cf2('0x46')](handleError(_0x3af023,null));};exports[_0x5cf2('0x47')]=function(_0x4aa26a,_0x4f8471){var _0x46ed61={'raw':!![],'where':{'id':_0x4aa26a[_0x5cf2('0x48')]['id']}},_0xcb7f72={};_0xcb7f72['model']=_[_0x5cf2('0x33')](db[_0x5cf2('0x2c')][_0x5cf2('0x2d')]);_0xcb7f72[_0x5cf2('0x34')]=_[_0x5cf2('0x33')](_0x4aa26a['query']);_0xcb7f72[_0x5cf2('0x3f')]=_[_0x5cf2('0x35')](_0xcb7f72['model'],_0xcb7f72['query']);_0x46ed61[_0x5cf2('0x38')]=_[_0x5cf2('0x35')](_0xcb7f72[_0x5cf2('0x31')],qs[_0x5cf2('0x36')](_0x4aa26a[_0x5cf2('0x34')][_0x5cf2('0x36')]));_0x46ed61['attributes']=_0x46ed61[_0x5cf2('0x38')][_0x5cf2('0x37')]?_0x46ed61[_0x5cf2('0x38')]:_0xcb7f72[_0x5cf2('0x31')];if(_0x4aa26a[_0x5cf2('0x34')][_0x5cf2('0x49')]){_0x46ed61[_0x5cf2('0x43')]=[{'all':!![]}];}_0x46ed61=_[_0x5cf2('0x41')]({},_0x46ed61,_0x4aa26a['options']);return db[_0x5cf2('0x2c')]['find'](_0x46ed61)[_0x5cf2('0x22')](handleEntityNotFound(_0x4f8471,null))[_0x5cf2('0x22')](respondWithResult(_0x4f8471,null))[_0x5cf2('0x46')](handleError(_0x4f8471,null));};exports[_0x5cf2('0x4a')]=function(_0x3074f7,_0x4fe72d,_0x1f36b5){return db['Sound']['find']({'where':{'id':_0x3074f7['params']['id']},'attributes':[_0x5cf2('0x29'),_0x5cf2('0x4b'),_0x5cf2('0x4c')],'raw':!![]})[_0x5cf2('0x22')](handleEntityNotFound(_0x4fe72d,null))['then'](function(_0x2d03eb){if(_0x2d03eb){if(!fs[_0x5cf2('0x4d')](path[_0x5cf2('0x4e')](config[_0x5cf2('0x4f')],'server/files/sounds/converted',_0x2d03eb[_0x5cf2('0x4b')]+'.'+_0x2d03eb[_0x5cf2('0x4c')]))){throw new db[(_0x5cf2('0x50'))][(_0x5cf2('0x51'))](_0x5cf2('0x52'));}return _0x4fe72d[_0x5cf2('0x4a')](path[_0x5cf2('0x4e')](config[_0x5cf2('0x4f')],_0x5cf2('0x53'),util[_0x5cf2('0x54')](_0x5cf2('0x55'),_0x2d03eb[_0x5cf2('0x4b')],_0x2d03eb[_0x5cf2('0x4c')])),util[_0x5cf2('0x54')](_0x5cf2('0x55'),_0x2d03eb['name'],_0x2d03eb[_0x5cf2('0x4c')]));}return null;})[_0x5cf2('0x46')](handleError(_0x4fe72d,null));};exports[_0x5cf2('0x56')]=function(_0x1fd00d,_0xa58e8a,_0x594dfa){var _0x27fecf={'name':path[_0x5cf2('0x57')](_0x1fd00d['file']['originalname'],path[_0x5cf2('0x58')](_0x1fd00d[_0x5cf2('0x59')]['originalname'])),'save_name':path['basename'](_0x1fd00d[_0x5cf2('0x59')][_0x5cf2('0x5a')],path['extname'](_0x1fd00d[_0x5cf2('0x59')][_0x5cf2('0x5a')])),'original_format':path[_0x5cf2('0x58')](_0x1fd00d[_0x5cf2('0x59')]['originalname'])['substring'](0x1),'converted_format':_0x5cf2('0x5b')};var _0x5d0bcb=path[_0x5cf2('0x4e')](config['root'],_0x5cf2('0x5c'),_0x1fd00d[_0x5cf2('0x59')][_0x5cf2('0x5a')]);var _0x198764=path[_0x5cf2('0x4e')](config[_0x5cf2('0x4f')],'server/files/sounds/converted',util[_0x5cf2('0x54')](_0x5cf2('0x55'),path[_0x5cf2('0x57')](_0x1fd00d[_0x5cf2('0x59')][_0x5cf2('0x5a')],path['extname'](_0x1fd00d[_0x5cf2('0x59')][_0x5cf2('0x5a')])),_0x27fecf['converted_format']));logger[_0x5cf2('0x5d')]('Sound\x20upload\x20filepath:\x20%s',_0x5d0bcb);logger[_0x5cf2('0x5d')](_0x5cf2('0x5e'),_0x198764);try{fs['chmodSync'](_0x5d0bcb,parseInt(_0x5cf2('0x5f'),0x8));var _0x5ade53=sox[_0x5cf2('0x60')](_0x5d0bcb,_0x198764,{'sampleRate':0x1f40,'format':'wav','channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x5ade53['on'](_0x5cf2('0x27'),function(_0x518fb3){fs[_0x5cf2('0x61')](_0x5d0bcb);_0xa58e8a[_0x5cf2('0x18')](0x1f4)[_0x5cf2('0x2a')](_0x518fb3);});_0x5ade53['on'](_0x5cf2('0x62'),function(_0x3f4f8c){_0x27fecf[_0x5cf2('0x63')]=isNaN(_0x3f4f8c['duration'])?null:_0x3f4f8c[_0x5cf2('0x64')]*0x3e8;_0x27fecf['original_sampleCount']=isNaN(_0x3f4f8c[_0x5cf2('0x65')])?null:_0x3f4f8c[_0x5cf2('0x65')];_0x27fecf[_0x5cf2('0x66')]=isNaN(_0x3f4f8c['channelCount'])?null:_0x3f4f8c[_0x5cf2('0x67')];_0x27fecf['original_bitRate']=isNaN(_0x3f4f8c[_0x5cf2('0x68')])?null:_0x3f4f8c['bitRate'];_0x27fecf[_0x5cf2('0x69')]=isNaN(_0x3f4f8c[_0x5cf2('0x6a')])?null:_0x3f4f8c['sampleRate'];});_0x5ade53['on'](_0x5cf2('0x6b'),function(_0x1f565c){_0x27fecf[_0x5cf2('0x6c')]=isNaN(_0x1f565c['duration'])?null:_0x1f565c[_0x5cf2('0x64')]*0x3e8;_0x27fecf[_0x5cf2('0x6d')]=isNaN(_0x1f565c[_0x5cf2('0x65')])?null:_0x1f565c[_0x5cf2('0x65')];_0x27fecf[_0x5cf2('0x6e')]=isNaN(_0x1f565c[_0x5cf2('0x67')])?null:_0x1f565c[_0x5cf2('0x67')];_0x27fecf['converted_bitRate']=isNaN(_0x1f565c[_0x5cf2('0x68')])?null:_0x1f565c[_0x5cf2('0x68')];_0x27fecf['converted_sampleRate']=isNaN(_0x1f565c['sampleRate'])?null:_0x1f565c[_0x5cf2('0x6a')];});_0x5ade53['on']('end',function(){fs[_0x5cf2('0x6f')](_0x198764,parseInt(_0x5cf2('0x5f'),0x8));return db[_0x5cf2('0x2c')][_0x5cf2('0x56')](_0x27fecf)[_0x5cf2('0x22')](function(_0xe3bff){var _0x53d53d={'role':_0x1fd00d[_0x5cf2('0x70')][_0x5cf2('0x71')],'userProfileId':_0x1fd00d[_0x5cf2('0x70')][_0x5cf2('0x72')]};if(!_0x53d53d)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x53d53d['role']===_0x5cf2('0x73')){var _0x388186=_0xe3bff[_0x5cf2('0x24')]({'plain':!![]});return db[_0x5cf2('0x74')][_0x5cf2('0x75')]({'where':{'name':_0x5cf2('0x25'),'userProfileId':_0x53d53d['userProfileId']},'raw':!![]})[_0x5cf2('0x22')](function(_0x43e15d){if(_0x43e15d&&_0x43e15d[_0x5cf2('0x76')]===0x0){return db[_0x5cf2('0x26')]['create']({'name':_0x388186[_0x5cf2('0x29')],'resourceId':_0x388186['id'],'type':_0x43e15d[_0x5cf2('0x29')],'sectionId':_0x43e15d['id']},{})[_0x5cf2('0x22')](function(){return _0xe3bff;});}else{return _0xe3bff;}})[_0x5cf2('0x46')](function(_0x28a22d){logger['error'](_0x5cf2('0x77'),_0x28a22d);throw _0x28a22d;});}return _0xe3bff;})[_0x5cf2('0x22')](respondWithResult(_0xa58e8a,null))['catch'](handleError(_0xa58e8a,null));});_0x5ade53[_0x5cf2('0x78')]();}catch(_0x188b07){_0xa58e8a[_0x5cf2('0x18')](0x1f4)[_0x5cf2('0x2a')](_0x188b07);}};exports['update']=function(_0x11ab88,_0x1d9362,_0x72b21b){return db[_0x5cf2('0x2c')][_0x5cf2('0x75')]({'where':{'id':_0x11ab88[_0x5cf2('0x48')]['id']}})[_0x5cf2('0x22')](handleEntityNotFound(_0x1d9362,null))[_0x5cf2('0x22')](saveUpdates(_[_0x5cf2('0x3e')](_0x11ab88[_0x5cf2('0x70')],[_0x5cf2('0x29'),_0x5cf2('0x79')]),null))[_0x5cf2('0x22')](respondWithResult(_0x1d9362,null))['catch'](handleError(_0x1d9362,null));};exports[_0x5cf2('0x7a')]=function(_0x557809,_0x42e3b0,_0x5a3728){return db['Sound'][_0x5cf2('0x75')]({'where':{'id':_0x557809[_0x5cf2('0x48')]['id']}})[_0x5cf2('0x22')](function(_0x30cc65){if(_0x30cc65){return _0x30cc65[_0x5cf2('0x23')]();}})[_0x5cf2('0x22')](function(_0x3e33c2){var _0x174605=path[_0x5cf2('0x4e')](config['root'],'server/files/sounds/original',util[_0x5cf2('0x54')](_0x5cf2('0x55'),_0x3e33c2[_0x5cf2('0x4b')],_0x3e33c2[_0x5cf2('0x7b')]));var _0x4b817b=path['join'](config[_0x5cf2('0x4f')],_0x5cf2('0x53'),util['format'](_0x5cf2('0x55'),_0x3e33c2[_0x5cf2('0x4b')],_0x3e33c2[_0x5cf2('0x4c')]));fs[_0x5cf2('0x61')](_0x174605);fs[_0x5cf2('0x61')](_0x4b817b);return _0x3e33c2;})[_0x5cf2('0x22')](function(_0x2d6e04){if(_0x2d6e04){return _0x42e3b0[_0x5cf2('0x18')](0xcc)['end']();}})[_0x5cf2('0x22')](handleEntityNotFound(_0x42e3b0,null))[_0x5cf2('0x46')](handleError(_0x42e3b0,null));};
\ No newline at end of file
+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