Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / sound / sound.controller.js
index 9919eff..30106e2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfcc0=['converted_channelCount','converted_bitRate','body','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','Sounds','autoAssociation','UserProfileResource','description','server/files/sounds/original','original_format','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','end','status','offset','undefined','count','limit','set','Content-Range','json','apply','reject','save','update','then','destroy','get','sendStatus','error','name','send','Sound','rawAttributes','type','key','model','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','merge','map','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','download','converted_format','existsSync','root','server/files/sounds/converted','save_name','Sequelize','ValidationError','Sound\x20not\x20found','join','format','create','basename','originalname','extname','file','wav','%s.%s','filename','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','unlinkSync','src','original_duration','duration','sampleCount','original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','converted_duration'];(function(_0x2c582c,_0x4b4e0e){var _0x1d5935=function(_0xb643eb){while(--_0xb643eb){_0x2c582c['push'](_0x2c582c['shift']());}};_0x1d5935(++_0x4b4e0e);}(_0xfcc0,0x8c));var _0x0fcc=function(_0x34404a,_0x132ae6){_0x34404a=_0x34404a-0x0;var _0x1cbc17=_0xfcc0[_0x34404a];return _0x1cbc17;};'use strict';var emlformat=require(_0x0fcc('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0fcc('0x1'));var jsonpatch=require(_0x0fcc('0x2'));var rp=require(_0x0fcc('0x3'));var moment=require(_0x0fcc('0x4'));var BPromise=require(_0x0fcc('0x5'));var Mustache=require(_0x0fcc('0x6'));var util=require(_0x0fcc('0x7'));var path=require(_0x0fcc('0x8'));var sox=require(_0x0fcc('0x9'));var csv=require(_0x0fcc('0xa'));var ejs=require(_0x0fcc('0xb'));var fs=require('fs');var fs_extra=require(_0x0fcc('0xc'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x0fcc('0xd'));var jsforce=require(_0x0fcc('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x0fcc('0xa'));var querystring=require(_0x0fcc('0xf'));var Papa=require(_0x0fcc('0x10'));var Redis=require('ioredis');var authService=require(_0x0fcc('0x11'));var qs=require(_0x0fcc('0x12'));var as=require(_0x0fcc('0x13'));var hardwareService=require(_0x0fcc('0x14'));var logger=require(_0x0fcc('0x15'))(_0x0fcc('0x16'));var utils=require(_0x0fcc('0x17'));var config=require(_0x0fcc('0x18'));var licenseUtil=require(_0x0fcc('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2a4a96,_0x2b348d){_0x2b348d=_0x2b348d||0xcc;return function(_0x33dc85){if(_0x33dc85){return _0x2a4a96['sendStatus'](_0x2b348d);}return _0x2a4a96['status'](_0x2b348d)[_0x0fcc('0x1a')]();};}function respondWithResult(_0x181c6c,_0x59f70c){_0x59f70c=_0x59f70c||0xc8;return function(_0x6f6eb3){if(_0x6f6eb3){return _0x181c6c[_0x0fcc('0x1b')](_0x59f70c)['json'](_0x6f6eb3);}};}function respondWithFilteredResult(_0xd909c6,_0x148ff6){return function(_0x16c514){if(_0x16c514){var _0x53ccb0=typeof _0x148ff6[_0x0fcc('0x1c')]===_0x0fcc('0x1d')&&typeof _0x148ff6['limit']===_0x0fcc('0x1d');var _0x265457=_0x16c514[_0x0fcc('0x1e')];var _0x341475=_0x53ccb0?0x0:_0x148ff6[_0x0fcc('0x1c')];var _0xb88c57=_0x53ccb0?_0x16c514[_0x0fcc('0x1e')]:_0x148ff6[_0x0fcc('0x1c')]+_0x148ff6[_0x0fcc('0x1f')];var _0xe4b0b0;if(_0xb88c57>=_0x265457){_0xb88c57=_0x265457;_0xe4b0b0=0xc8;}else{_0xe4b0b0=0xce;}_0xd909c6[_0x0fcc('0x1b')](_0xe4b0b0);return _0xd909c6[_0x0fcc('0x20')](_0x0fcc('0x21'),_0x341475+'-'+_0xb88c57+'/'+_0x265457)[_0x0fcc('0x22')](_0x16c514);}return null;};}function patchUpdates(_0x4928fd){return function(_0x1f5210){try{jsonpatch[_0x0fcc('0x23')](_0x1f5210,_0x4928fd,!![]);}catch(_0x9640e0){return BPromise[_0x0fcc('0x24')](_0x9640e0);}return _0x1f5210[_0x0fcc('0x25')]();};}function saveUpdates(_0x4bc2af,_0x4962f0){return function(_0x1c0dbe){if(_0x1c0dbe){return _0x1c0dbe[_0x0fcc('0x26')](_0x4bc2af)[_0x0fcc('0x27')](function(_0x25b4a2){return _0x25b4a2;});}return null;};}function removeEntity(_0x4380fd,_0x5a54f9){return function(_0x30a173){if(_0x30a173){return _0x30a173[_0x0fcc('0x28')]()[_0x0fcc('0x27')](function(){var _0x1e7b4d=_0x30a173[_0x0fcc('0x29')]({'plain':!![]});var _0x49c219='Sounds';return db['UserProfileResource'][_0x0fcc('0x28')]({'where':{'type':_0x49c219,'resourceId':_0x1e7b4d['id']}})[_0x0fcc('0x27')](function(){return _0x30a173;});})['then'](function(){_0x4380fd[_0x0fcc('0x1b')](0xcc)[_0x0fcc('0x1a')]();});}};}function handleEntityNotFound(_0x1a294b,_0x2eba11){return function(_0x36684f){if(!_0x36684f){_0x1a294b[_0x0fcc('0x2a')](0x194);}return _0x36684f;};}function handleError(_0xa205ec,_0x19c9df){_0x19c9df=_0x19c9df||0x1f4;return function(_0x3530ec){logger[_0x0fcc('0x2b')](_0x3530ec['stack']);if(_0x3530ec[_0x0fcc('0x2c')]){delete _0x3530ec[_0x0fcc('0x2c')];}_0xa205ec[_0x0fcc('0x1b')](_0x19c9df)[_0x0fcc('0x2d')](_0x3530ec);};}exports['index']=function(_0x453ac0,_0x385451){var _0x244d72={},_0x5c7b35={},_0x112d50={'count':0x0,'rows':[]};var _0x453d03=_['map'](db[_0x0fcc('0x2e')][_0x0fcc('0x2f')],function(_0x34b633){return{'name':_0x34b633['fieldName'],'type':_0x34b633[_0x0fcc('0x30')][_0x0fcc('0x31')]};});_0x5c7b35[_0x0fcc('0x32')]=_['map'](_0x453d03,'name');_0x5c7b35['query']=_[_0x0fcc('0x33')](_0x453ac0[_0x0fcc('0x34')]);_0x5c7b35[_0x0fcc('0x35')]=_[_0x0fcc('0x36')](_0x5c7b35[_0x0fcc('0x32')],_0x5c7b35[_0x0fcc('0x34')]);_0x244d72[_0x0fcc('0x37')]=_[_0x0fcc('0x36')](_0x5c7b35['model'],qs[_0x0fcc('0x38')](_0x453ac0[_0x0fcc('0x34')]['fields']));_0x244d72['attributes']=_0x244d72['attributes'][_0x0fcc('0x39')]?_0x244d72[_0x0fcc('0x37')]:_0x5c7b35[_0x0fcc('0x32')];if(!_0x453ac0[_0x0fcc('0x34')]['hasOwnProperty'](_0x0fcc('0x3a'))){_0x244d72['limit']=qs[_0x0fcc('0x1f')](_0x453ac0['query'][_0x0fcc('0x1f')]);_0x244d72[_0x0fcc('0x1c')]=qs[_0x0fcc('0x1c')](_0x453ac0[_0x0fcc('0x34')]['offset']);}_0x244d72[_0x0fcc('0x3b')]=qs[_0x0fcc('0x3c')](_0x453ac0[_0x0fcc('0x34')][_0x0fcc('0x3c')]);_0x244d72[_0x0fcc('0x3d')]=qs[_0x0fcc('0x35')](_['pick'](_0x453ac0[_0x0fcc('0x34')],_0x5c7b35[_0x0fcc('0x35')]),_0x453d03);if(_0x453ac0['query'][_0x0fcc('0x3e')]){_0x244d72[_0x0fcc('0x3d')]=_[_0x0fcc('0x3f')](_0x244d72[_0x0fcc('0x3d')],{'$or':_[_0x0fcc('0x40')](_0x453d03,function(_0x17a21d){if(_0x17a21d[_0x0fcc('0x30')]!==_0x0fcc('0x41')){var _0x477ac7={};_0x477ac7[_0x17a21d[_0x0fcc('0x2c')]]={'$like':'%'+_0x453ac0['query']['filter']+'%'};return _0x477ac7;}})});}_0x244d72=_[_0x0fcc('0x3f')]({},_0x244d72,_0x453ac0[_0x0fcc('0x42')]);var _0x77a6a4={'where':_0x244d72[_0x0fcc('0x3d')]};return db['Sound'][_0x0fcc('0x1e')](_0x77a6a4)['then'](function(_0x20a922){_0x112d50['count']=_0x20a922;if(_0x453ac0[_0x0fcc('0x34')][_0x0fcc('0x43')]){_0x244d72[_0x0fcc('0x44')]=[{'all':!![]}];}return db[_0x0fcc('0x2e')][_0x0fcc('0x45')](_0x244d72);})[_0x0fcc('0x27')](function(_0x474568){_0x112d50[_0x0fcc('0x46')]=_0x474568;return _0x112d50;})[_0x0fcc('0x27')](respondWithFilteredResult(_0x385451,_0x244d72))[_0x0fcc('0x47')](handleError(_0x385451,null));};exports[_0x0fcc('0x48')]=function(_0x111868,_0x102f70){var _0x143af3={'raw':!![],'where':{'id':_0x111868[_0x0fcc('0x49')]['id']}},_0x107e33={};_0x107e33[_0x0fcc('0x32')]=_[_0x0fcc('0x33')](db[_0x0fcc('0x2e')][_0x0fcc('0x2f')]);_0x107e33[_0x0fcc('0x34')]=_[_0x0fcc('0x33')](_0x111868[_0x0fcc('0x34')]);_0x107e33[_0x0fcc('0x35')]=_[_0x0fcc('0x36')](_0x107e33['model'],_0x107e33[_0x0fcc('0x34')]);_0x143af3[_0x0fcc('0x37')]=_[_0x0fcc('0x36')](_0x107e33[_0x0fcc('0x32')],qs[_0x0fcc('0x38')](_0x111868[_0x0fcc('0x34')][_0x0fcc('0x38')]));_0x143af3[_0x0fcc('0x37')]=_0x143af3[_0x0fcc('0x37')]['length']?_0x143af3[_0x0fcc('0x37')]:_0x107e33[_0x0fcc('0x32')];if(_0x111868[_0x0fcc('0x34')][_0x0fcc('0x43')]){_0x143af3[_0x0fcc('0x44')]=[{'all':!![]}];}_0x143af3=_[_0x0fcc('0x3f')]({},_0x143af3,_0x111868[_0x0fcc('0x42')]);return db[_0x0fcc('0x2e')][_0x0fcc('0x4a')](_0x143af3)[_0x0fcc('0x27')](handleEntityNotFound(_0x102f70,null))[_0x0fcc('0x27')](respondWithResult(_0x102f70,null))[_0x0fcc('0x47')](handleError(_0x102f70,null));};exports[_0x0fcc('0x4b')]=function(_0x2ff59d,_0x7070c1,_0x2f8d78){return db[_0x0fcc('0x2e')][_0x0fcc('0x4a')]({'where':{'id':_0x2ff59d[_0x0fcc('0x49')]['id']},'attributes':[_0x0fcc('0x2c'),'save_name',_0x0fcc('0x4c')],'raw':!![]})['then'](handleEntityNotFound(_0x7070c1,null))[_0x0fcc('0x27')](function(_0x105f92){if(_0x105f92){if(!fs[_0x0fcc('0x4d')](path['join'](config[_0x0fcc('0x4e')],_0x0fcc('0x4f'),_0x105f92[_0x0fcc('0x50')]+'.'+_0x105f92[_0x0fcc('0x4c')]))){throw new db[(_0x0fcc('0x51'))][(_0x0fcc('0x52'))](_0x0fcc('0x53'));}return _0x7070c1[_0x0fcc('0x4b')](path[_0x0fcc('0x54')](config[_0x0fcc('0x4e')],_0x0fcc('0x4f'),util[_0x0fcc('0x55')]('%s.%s',_0x105f92['save_name'],_0x105f92[_0x0fcc('0x4c')])),util['format']('%s.%s',_0x105f92[_0x0fcc('0x2c')],_0x105f92[_0x0fcc('0x4c')]));}return null;})['catch'](handleError(_0x7070c1,null));};exports[_0x0fcc('0x56')]=function(_0x4014f4,_0x3e1212,_0x567d90){var _0x5f0cd2={'name':path[_0x0fcc('0x57')](_0x4014f4['file'][_0x0fcc('0x58')],path[_0x0fcc('0x59')](_0x4014f4['file'][_0x0fcc('0x58')])),'save_name':path[_0x0fcc('0x57')](_0x4014f4['file']['filename'],path[_0x0fcc('0x59')](_0x4014f4['file']['filename'])),'original_format':path[_0x0fcc('0x59')](_0x4014f4[_0x0fcc('0x5a')]['originalname'])['substring'](0x1),'converted_format':_0x0fcc('0x5b')};var _0xb277b=path[_0x0fcc('0x54')](config[_0x0fcc('0x4e')],'server/files/sounds/original',_0x4014f4[_0x0fcc('0x5a')]['filename']);var _0x482dc4=path[_0x0fcc('0x54')](config[_0x0fcc('0x4e')],'server/files/sounds/converted',util[_0x0fcc('0x55')](_0x0fcc('0x5c'),path[_0x0fcc('0x57')](_0x4014f4[_0x0fcc('0x5a')]['filename'],path[_0x0fcc('0x59')](_0x4014f4[_0x0fcc('0x5a')][_0x0fcc('0x5d')])),_0x5f0cd2[_0x0fcc('0x4c')]));logger[_0x0fcc('0x5e')](_0x0fcc('0x5f'),_0xb277b);logger[_0x0fcc('0x5e')](_0x0fcc('0x60'),_0x482dc4);try{fs[_0x0fcc('0x61')](_0xb277b,parseInt(_0x0fcc('0x62'),0x8));var _0x4146dc=sox[_0x0fcc('0x63')](_0xb277b,_0x482dc4,{'sampleRate':0x1f40,'format':_0x0fcc('0x5b'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x4146dc['on']('error',function(_0x5b60d7){fs[_0x0fcc('0x64')](_0xb277b);_0x3e1212[_0x0fcc('0x1b')](0x1f4)['send'](_0x5b60d7);});_0x4146dc['on'](_0x0fcc('0x65'),function(_0x4f6316){_0x5f0cd2[_0x0fcc('0x66')]=isNaN(_0x4f6316[_0x0fcc('0x67')])?null:_0x4f6316[_0x0fcc('0x67')]*0x3e8;_0x5f0cd2['original_sampleCount']=isNaN(_0x4f6316[_0x0fcc('0x68')])?null:_0x4f6316[_0x0fcc('0x68')];_0x5f0cd2[_0x0fcc('0x69')]=isNaN(_0x4f6316[_0x0fcc('0x6a')])?null:_0x4f6316['channelCount'];_0x5f0cd2[_0x0fcc('0x6b')]=isNaN(_0x4f6316[_0x0fcc('0x6c')])?null:_0x4f6316[_0x0fcc('0x6c')];_0x5f0cd2[_0x0fcc('0x6d')]=isNaN(_0x4f6316[_0x0fcc('0x6e')])?null:_0x4f6316[_0x0fcc('0x6e')];});_0x4146dc['on']('dest',function(_0x436d4b){_0x5f0cd2[_0x0fcc('0x6f')]=isNaN(_0x436d4b[_0x0fcc('0x67')])?null:_0x436d4b[_0x0fcc('0x67')]*0x3e8;_0x5f0cd2['converted_sampleCount']=isNaN(_0x436d4b[_0x0fcc('0x68')])?null:_0x436d4b[_0x0fcc('0x68')];_0x5f0cd2[_0x0fcc('0x70')]=isNaN(_0x436d4b[_0x0fcc('0x6a')])?null:_0x436d4b['channelCount'];_0x5f0cd2[_0x0fcc('0x71')]=isNaN(_0x436d4b[_0x0fcc('0x6c')])?null:_0x436d4b[_0x0fcc('0x6c')];_0x5f0cd2['converted_sampleRate']=isNaN(_0x436d4b[_0x0fcc('0x6e')])?null:_0x436d4b['sampleRate'];});_0x4146dc['on'](_0x0fcc('0x1a'),function(){fs['chmodSync'](_0x482dc4,parseInt(_0x0fcc('0x62'),0x8));return db[_0x0fcc('0x2e')][_0x0fcc('0x56')](_0x5f0cd2)[_0x0fcc('0x27')](function(_0x1816eb){var _0x1a9a34={'role':_0x4014f4[_0x0fcc('0x72')]['role'],'userProfileId':_0x4014f4[_0x0fcc('0x72')][_0x0fcc('0x73')]};if(!_0x1a9a34)throw new Error(_0x0fcc('0x74'));if(_0x1a9a34[_0x0fcc('0x75')]===_0x0fcc('0x76')){var _0x41de51=_0x1816eb[_0x0fcc('0x29')]({'plain':!![]});return db[_0x0fcc('0x77')][_0x0fcc('0x4a')]({'where':{'name':_0x0fcc('0x78'),'userProfileId':_0x1a9a34[_0x0fcc('0x73')]},'raw':!![]})['then'](function(_0x1ad5fb){if(_0x1ad5fb&&_0x1ad5fb[_0x0fcc('0x79')]===0x0){return db[_0x0fcc('0x7a')][_0x0fcc('0x56')]({'name':_0x41de51[_0x0fcc('0x2c')],'resourceId':_0x41de51['id'],'type':_0x1ad5fb[_0x0fcc('0x2c')],'sectionId':_0x1ad5fb['id']},{})['then'](function(){return _0x1816eb;});}else{return _0x1816eb;}})[_0x0fcc('0x47')](function(_0x5065a3){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5065a3);throw _0x5065a3;});}return _0x1816eb;})['then'](respondWithResult(_0x3e1212,null))[_0x0fcc('0x47')](handleError(_0x3e1212,null));});_0x4146dc['start']();}catch(_0x5e33a1){_0x3e1212['status'](0x1f4)[_0x0fcc('0x2d')](_0x5e33a1);}};exports[_0x0fcc('0x26')]=function(_0x5f059e,_0x46066b,_0x5bf66e){return db['Sound']['find']({'where':{'id':_0x5f059e['params']['id']}})[_0x0fcc('0x27')](handleEntityNotFound(_0x46066b,null))[_0x0fcc('0x27')](saveUpdates(_['pick'](_0x5f059e[_0x0fcc('0x72')],[_0x0fcc('0x2c'),_0x0fcc('0x7b')]),null))[_0x0fcc('0x27')](respondWithResult(_0x46066b,null))[_0x0fcc('0x47')](handleError(_0x46066b,null));};exports['delete']=function(_0x4846e9,_0xc78d92,_0x2a761e){return db['Sound']['find']({'where':{'id':_0x4846e9[_0x0fcc('0x49')]['id']}})['then'](function(_0x4b204e){if(_0x4b204e){return _0x4b204e[_0x0fcc('0x28')]();}})[_0x0fcc('0x27')](function(_0x26cd21){var _0x57a62e=path[_0x0fcc('0x54')](config[_0x0fcc('0x4e')],_0x0fcc('0x7c'),util['format'](_0x0fcc('0x5c'),_0x26cd21[_0x0fcc('0x50')],_0x26cd21[_0x0fcc('0x7d')]));var _0x321ba8=path[_0x0fcc('0x54')](config[_0x0fcc('0x4e')],'server/files/sounds/converted',util['format'](_0x0fcc('0x5c'),_0x26cd21[_0x0fcc('0x50')],_0x26cd21[_0x0fcc('0x4c')]));fs['unlinkSync'](_0x57a62e);fs[_0x0fcc('0x64')](_0x321ba8);return _0x26cd21;})[_0x0fcc('0x27')](function(_0x3b24e8){if(_0x3b24e8){return _0xc78d92['status'](0xcc)['end']();}})[_0x0fcc('0x27')](handleEntityNotFound(_0xc78d92,null))[_0x0fcc('0x47')](handleError(_0xc78d92,null));};
\ No newline at end of file
+var _0x6edf=['original_channelCount','channelCount','original_bitRate','bitRate','original_sampleRate','sampleRate','converted_duration','sampleCount','converted_channelCount','converted_bitRate','converted_sampleRate','create','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','delete','destroy','server/files/sounds/original','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','limit','offset','set','Content-Range','reject','save','then','get','Sounds','UserProfileResource','end','send','index','map','Sound','rawAttributes','fieldName','model','name','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','VIRTUAL','options','count','includeAll','include','findAll','rows','catch','show','params','find','download','save_name','converted_format','existsSync','join','root','server/files/sounds/converted','Sequelize','ValidationError','Sound\x20not\x20found','%s.%s','format','basename','file','originalname','extname','substring','wav','filename','info','Sound\x20upload\x20filepath:\x20%s','Sound\x20upload\x20destination:\x20%s','chmodSync','0777','transcode','error','unlinkSync','src','original_duration','duration','original_sampleCount'];(function(_0x4ed520,_0x21be63){var _0x4415a6=function(_0x14b151){while(--_0x14b151){_0x4ed520['push'](_0x4ed520['shift']());}};_0x4415a6(++_0x21be63);}(_0x6edf,0x1a1));var _0xf6ed=function(_0x3bd1d6,_0x137d1e){_0x3bd1d6=_0x3bd1d6-0x0;var _0x5ea198=_0x6edf[_0x3bd1d6];return _0x5ea198;};'use strict';var emlformat=require(_0xf6ed('0x0'));var rimraf=require(_0xf6ed('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf6ed('0x2'));var rp=require(_0xf6ed('0x3'));var moment=require(_0xf6ed('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf6ed('0x5'));var util=require(_0xf6ed('0x6'));var path=require(_0xf6ed('0x7'));var sox=require(_0xf6ed('0x8'));var csv=require(_0xf6ed('0x9'));var ejs=require(_0xf6ed('0xa'));var fs=require('fs');var fs_extra=require(_0xf6ed('0xb'));var _=require(_0xf6ed('0xc'));var squel=require(_0xf6ed('0xd'));var crypto=require(_0xf6ed('0xe'));var jsforce=require(_0xf6ed('0xf'));var deskjs=require(_0xf6ed('0x10'));var toCsv=require(_0xf6ed('0x9'));var querystring=require(_0xf6ed('0x11'));var Papa=require(_0xf6ed('0x12'));var Redis=require(_0xf6ed('0x13'));var authService=require(_0xf6ed('0x14'));var qs=require(_0xf6ed('0x15'));var as=require(_0xf6ed('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf6ed('0x17'))(_0xf6ed('0x18'));var utils=require('../../config/utils');var config=require(_0xf6ed('0x19'));var licenseUtil=require(_0xf6ed('0x1a'));var db=require(_0xf6ed('0x1b'))['db'];function respondWithStatusCode(_0x4b0dd7,_0x3a0c49){_0x3a0c49=_0x3a0c49||0xcc;return function(_0x34b1cd){if(_0x34b1cd){return _0x4b0dd7[_0xf6ed('0x1c')](_0x3a0c49);}return _0x4b0dd7[_0xf6ed('0x1d')](_0x3a0c49)['end']();};}function respondWithResult(_0xedab73,_0xd81459){_0xd81459=_0xd81459||0xc8;return function(_0x373a84){if(_0x373a84){return _0xedab73[_0xf6ed('0x1d')](_0xd81459)[_0xf6ed('0x1e')](_0x373a84);}};}function respondWithFilteredResult(_0x3d0c78,_0x58525f){return function(_0x8fa267){if(_0x8fa267){var _0x50b776=typeof _0x58525f['offset']==='undefined'&&typeof _0x58525f[_0xf6ed('0x1f')]==='undefined';var _0x138b62=_0x8fa267['count'];var _0xdb0229=_0x50b776?0x0:_0x58525f[_0xf6ed('0x20')];var _0x47a0c4=_0x50b776?_0x8fa267['count']:_0x58525f['offset']+_0x58525f['limit'];var _0x701ee8;if(_0x47a0c4>=_0x138b62){_0x47a0c4=_0x138b62;_0x701ee8=0xc8;}else{_0x701ee8=0xce;}_0x3d0c78[_0xf6ed('0x1d')](_0x701ee8);return _0x3d0c78[_0xf6ed('0x21')](_0xf6ed('0x22'),_0xdb0229+'-'+_0x47a0c4+'/'+_0x138b62)[_0xf6ed('0x1e')](_0x8fa267);}return null;};}function patchUpdates(_0x73a9bb){return function(_0x10cea4){try{jsonpatch['apply'](_0x10cea4,_0x73a9bb,!![]);}catch(_0x279d62){return BPromise[_0xf6ed('0x23')](_0x279d62);}return _0x10cea4[_0xf6ed('0x24')]();};}function saveUpdates(_0x5f30b8,_0x338b1e){return function(_0x2354b1){if(_0x2354b1){return _0x2354b1['update'](_0x5f30b8)[_0xf6ed('0x25')](function(_0x14b604){return _0x14b604;});}return null;};}function removeEntity(_0x23e1d0,_0x3eac8c){return function(_0x561c5e){if(_0x561c5e){return _0x561c5e['destroy']()[_0xf6ed('0x25')](function(){var _0x5013d4=_0x561c5e[_0xf6ed('0x26')]({'plain':!![]});var _0x5493bc=_0xf6ed('0x27');return db[_0xf6ed('0x28')]['destroy']({'where':{'type':_0x5493bc,'resourceId':_0x5013d4['id']}})[_0xf6ed('0x25')](function(){return _0x561c5e;});})['then'](function(){_0x23e1d0[_0xf6ed('0x1d')](0xcc)[_0xf6ed('0x29')]();});}};}function handleEntityNotFound(_0x3cfdb6,_0x1c0987){return function(_0x4a5ba1){if(!_0x4a5ba1){_0x3cfdb6[_0xf6ed('0x1c')](0x194);}return _0x4a5ba1;};}function handleError(_0x53bfd4,_0x5f481d){_0x5f481d=_0x5f481d||0x1f4;return function(_0x272358){logger['error'](_0x272358['stack']);if(_0x272358['name']){delete _0x272358['name'];}_0x53bfd4[_0xf6ed('0x1d')](_0x5f481d)[_0xf6ed('0x2a')](_0x272358);};}exports[_0xf6ed('0x2b')]=function(_0x369617,_0x46977c){var _0x52908e={},_0x3fad8e={},_0x4cc35f={'count':0x0,'rows':[]};var _0x2d577a=_[_0xf6ed('0x2c')](db[_0xf6ed('0x2d')][_0xf6ed('0x2e')],function(_0x4e6f53){return{'name':_0x4e6f53[_0xf6ed('0x2f')],'type':_0x4e6f53['type']['key']};});_0x3fad8e[_0xf6ed('0x30')]=_['map'](_0x2d577a,_0xf6ed('0x31'));_0x3fad8e['query']=_[_0xf6ed('0x32')](_0x369617[_0xf6ed('0x33')]);_0x3fad8e[_0xf6ed('0x34')]=_[_0xf6ed('0x35')](_0x3fad8e[_0xf6ed('0x30')],_0x3fad8e[_0xf6ed('0x33')]);_0x52908e[_0xf6ed('0x36')]=_[_0xf6ed('0x35')](_0x3fad8e[_0xf6ed('0x30')],qs['fields'](_0x369617[_0xf6ed('0x33')][_0xf6ed('0x37')]));_0x52908e[_0xf6ed('0x36')]=_0x52908e[_0xf6ed('0x36')][_0xf6ed('0x38')]?_0x52908e[_0xf6ed('0x36')]:_0x3fad8e[_0xf6ed('0x30')];if(!_0x369617['query'][_0xf6ed('0x39')]('nolimit')){_0x52908e['limit']=qs[_0xf6ed('0x1f')](_0x369617['query'][_0xf6ed('0x1f')]);_0x52908e[_0xf6ed('0x20')]=qs[_0xf6ed('0x20')](_0x369617[_0xf6ed('0x33')]['offset']);}_0x52908e[_0xf6ed('0x3a')]=qs[_0xf6ed('0x3b')](_0x369617[_0xf6ed('0x33')][_0xf6ed('0x3b')]);_0x52908e[_0xf6ed('0x3c')]=qs[_0xf6ed('0x34')](_[_0xf6ed('0x3d')](_0x369617[_0xf6ed('0x33')],_0x3fad8e['filters']),_0x2d577a);if(_0x369617[_0xf6ed('0x33')][_0xf6ed('0x3e')]){_0x52908e[_0xf6ed('0x3c')]=_[_0xf6ed('0x3f')](_0x52908e[_0xf6ed('0x3c')],{'$or':_[_0xf6ed('0x2c')](_0x2d577a,function(_0xcc42ab){if(_0xcc42ab[_0xf6ed('0x40')]!==_0xf6ed('0x41')){var _0x3c2c1f={};_0x3c2c1f[_0xcc42ab[_0xf6ed('0x31')]]={'$like':'%'+_0x369617[_0xf6ed('0x33')][_0xf6ed('0x3e')]+'%'};return _0x3c2c1f;}})});}_0x52908e=_[_0xf6ed('0x3f')]({},_0x52908e,_0x369617[_0xf6ed('0x42')]);var _0x117d52={'where':_0x52908e['where']};return db[_0xf6ed('0x2d')][_0xf6ed('0x43')](_0x117d52)[_0xf6ed('0x25')](function(_0x57bc64){_0x4cc35f[_0xf6ed('0x43')]=_0x57bc64;if(_0x369617[_0xf6ed('0x33')][_0xf6ed('0x44')]){_0x52908e[_0xf6ed('0x45')]=[{'all':!![]}];}return db[_0xf6ed('0x2d')][_0xf6ed('0x46')](_0x52908e);})['then'](function(_0x2f2186){_0x4cc35f[_0xf6ed('0x47')]=_0x2f2186;return _0x4cc35f;})['then'](respondWithFilteredResult(_0x46977c,_0x52908e))[_0xf6ed('0x48')](handleError(_0x46977c,null));};exports[_0xf6ed('0x49')]=function(_0x4b7c70,_0xa11163){var _0x59e4d6={'raw':!![],'where':{'id':_0x4b7c70[_0xf6ed('0x4a')]['id']}},_0x107587={};_0x107587[_0xf6ed('0x30')]=_[_0xf6ed('0x32')](db[_0xf6ed('0x2d')][_0xf6ed('0x2e')]);_0x107587[_0xf6ed('0x33')]=_['keys'](_0x4b7c70[_0xf6ed('0x33')]);_0x107587[_0xf6ed('0x34')]=_[_0xf6ed('0x35')](_0x107587[_0xf6ed('0x30')],_0x107587[_0xf6ed('0x33')]);_0x59e4d6[_0xf6ed('0x36')]=_[_0xf6ed('0x35')](_0x107587[_0xf6ed('0x30')],qs[_0xf6ed('0x37')](_0x4b7c70[_0xf6ed('0x33')][_0xf6ed('0x37')]));_0x59e4d6[_0xf6ed('0x36')]=_0x59e4d6[_0xf6ed('0x36')]['length']?_0x59e4d6[_0xf6ed('0x36')]:_0x107587['model'];if(_0x4b7c70[_0xf6ed('0x33')][_0xf6ed('0x44')]){_0x59e4d6[_0xf6ed('0x45')]=[{'all':!![]}];}_0x59e4d6=_[_0xf6ed('0x3f')]({},_0x59e4d6,_0x4b7c70['options']);return db[_0xf6ed('0x2d')][_0xf6ed('0x4b')](_0x59e4d6)['then'](handleEntityNotFound(_0xa11163,null))[_0xf6ed('0x25')](respondWithResult(_0xa11163,null))['catch'](handleError(_0xa11163,null));};exports[_0xf6ed('0x4c')]=function(_0x1f1862,_0x2fef65,_0x749245){return db[_0xf6ed('0x2d')][_0xf6ed('0x4b')]({'where':{'id':_0x1f1862[_0xf6ed('0x4a')]['id']},'attributes':['name',_0xf6ed('0x4d'),_0xf6ed('0x4e')],'raw':!![]})[_0xf6ed('0x25')](handleEntityNotFound(_0x2fef65,null))[_0xf6ed('0x25')](function(_0x373288){if(_0x373288){if(!fs[_0xf6ed('0x4f')](path[_0xf6ed('0x50')](config[_0xf6ed('0x51')],_0xf6ed('0x52'),_0x373288[_0xf6ed('0x4d')]+'.'+_0x373288['converted_format']))){throw new db[(_0xf6ed('0x53'))][(_0xf6ed('0x54'))](_0xf6ed('0x55'));}return _0x2fef65[_0xf6ed('0x4c')](path['join'](config[_0xf6ed('0x51')],_0xf6ed('0x52'),util['format'](_0xf6ed('0x56'),_0x373288[_0xf6ed('0x4d')],_0x373288['converted_format'])),util[_0xf6ed('0x57')](_0xf6ed('0x56'),_0x373288[_0xf6ed('0x31')],_0x373288[_0xf6ed('0x4e')]));}return null;})[_0xf6ed('0x48')](handleError(_0x2fef65,null));};exports['create']=function(_0x40e44c,_0x410aae,_0x4bba38){var _0x56999c={'name':path[_0xf6ed('0x58')](_0x40e44c[_0xf6ed('0x59')]['originalname'],path['extname'](_0x40e44c['file'][_0xf6ed('0x5a')])),'save_name':path[_0xf6ed('0x58')](_0x40e44c[_0xf6ed('0x59')]['filename'],path['extname'](_0x40e44c[_0xf6ed('0x59')]['filename'])),'original_format':path[_0xf6ed('0x5b')](_0x40e44c[_0xf6ed('0x59')][_0xf6ed('0x5a')])[_0xf6ed('0x5c')](0x1),'converted_format':_0xf6ed('0x5d')};var _0x27fedf=path[_0xf6ed('0x50')](config[_0xf6ed('0x51')],'server/files/sounds/original',_0x40e44c['file']['filename']);var _0x4d2534=path[_0xf6ed('0x50')](config[_0xf6ed('0x51')],_0xf6ed('0x52'),util[_0xf6ed('0x57')](_0xf6ed('0x56'),path[_0xf6ed('0x58')](_0x40e44c[_0xf6ed('0x59')][_0xf6ed('0x5e')],path[_0xf6ed('0x5b')](_0x40e44c['file'][_0xf6ed('0x5e')])),_0x56999c[_0xf6ed('0x4e')]));logger[_0xf6ed('0x5f')](_0xf6ed('0x60'),_0x27fedf);logger['info'](_0xf6ed('0x61'),_0x4d2534);try{fs[_0xf6ed('0x62')](_0x27fedf,parseInt(_0xf6ed('0x63'),0x8));var _0x5681e9=sox[_0xf6ed('0x64')](_0x27fedf,_0x4d2534,{'sampleRate':0x1f40,'format':_0xf6ed('0x5d'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x5681e9['on'](_0xf6ed('0x65'),function(_0x229e70){fs[_0xf6ed('0x66')](_0x27fedf);_0x410aae[_0xf6ed('0x1d')](0x1f4)[_0xf6ed('0x2a')](_0x229e70);});_0x5681e9['on'](_0xf6ed('0x67'),function(_0x2a3750){_0x56999c[_0xf6ed('0x68')]=isNaN(_0x2a3750[_0xf6ed('0x69')])?null:_0x2a3750[_0xf6ed('0x69')]*0x3e8;_0x56999c[_0xf6ed('0x6a')]=isNaN(_0x2a3750['sampleCount'])?null:_0x2a3750['sampleCount'];_0x56999c[_0xf6ed('0x6b')]=isNaN(_0x2a3750[_0xf6ed('0x6c')])?null:_0x2a3750[_0xf6ed('0x6c')];_0x56999c[_0xf6ed('0x6d')]=isNaN(_0x2a3750[_0xf6ed('0x6e')])?null:_0x2a3750[_0xf6ed('0x6e')];_0x56999c[_0xf6ed('0x6f')]=isNaN(_0x2a3750[_0xf6ed('0x70')])?null:_0x2a3750[_0xf6ed('0x70')];});_0x5681e9['on']('dest',function(_0x59f0bc){_0x56999c[_0xf6ed('0x71')]=isNaN(_0x59f0bc[_0xf6ed('0x69')])?null:_0x59f0bc['duration']*0x3e8;_0x56999c['converted_sampleCount']=isNaN(_0x59f0bc[_0xf6ed('0x72')])?null:_0x59f0bc['sampleCount'];_0x56999c[_0xf6ed('0x73')]=isNaN(_0x59f0bc['channelCount'])?null:_0x59f0bc[_0xf6ed('0x6c')];_0x56999c[_0xf6ed('0x74')]=isNaN(_0x59f0bc['bitRate'])?null:_0x59f0bc[_0xf6ed('0x6e')];_0x56999c[_0xf6ed('0x75')]=isNaN(_0x59f0bc[_0xf6ed('0x70')])?null:_0x59f0bc['sampleRate'];});_0x5681e9['on'](_0xf6ed('0x29'),function(){fs[_0xf6ed('0x62')](_0x4d2534,parseInt(_0xf6ed('0x63'),0x8));return db[_0xf6ed('0x2d')][_0xf6ed('0x76')](_0x56999c)['then'](function(_0x5ad409){var _0x5cdc25={'role':_0x40e44c[_0xf6ed('0x77')][_0xf6ed('0x78')],'userProfileId':_0x40e44c[_0xf6ed('0x77')]['userProfileId']};if(!_0x5cdc25)throw new Error(_0xf6ed('0x79'));if(_0x5cdc25[_0xf6ed('0x78')]===_0xf6ed('0x7a')){var _0x36814a=_0x5ad409[_0xf6ed('0x26')]({'plain':!![]});return db[_0xf6ed('0x7b')][_0xf6ed('0x4b')]({'where':{'name':_0xf6ed('0x27'),'userProfileId':_0x5cdc25[_0xf6ed('0x7c')]},'raw':!![]})[_0xf6ed('0x25')](function(_0x55dede){if(_0x55dede&&_0x55dede[_0xf6ed('0x7d')]===0x0){return db[_0xf6ed('0x28')][_0xf6ed('0x76')]({'name':_0x36814a[_0xf6ed('0x31')],'resourceId':_0x36814a['id'],'type':_0x55dede['name'],'sectionId':_0x55dede['id']},{})[_0xf6ed('0x25')](function(){return _0x5ad409;});}else{return _0x5ad409;}})['catch'](function(_0x57efaa){logger[_0xf6ed('0x65')](_0xf6ed('0x7e'),_0x57efaa);throw _0x57efaa;});}return _0x5ad409;})['then'](respondWithResult(_0x410aae,null))[_0xf6ed('0x48')](handleError(_0x410aae,null));});_0x5681e9['start']();}catch(_0x4ab280){_0x410aae[_0xf6ed('0x1d')](0x1f4)[_0xf6ed('0x2a')](_0x4ab280);}};exports[_0xf6ed('0x7f')]=function(_0x56877d,_0x27e05a,_0x1228c5){return db[_0xf6ed('0x2d')][_0xf6ed('0x4b')]({'where':{'id':_0x56877d['params']['id']}})[_0xf6ed('0x25')](handleEntityNotFound(_0x27e05a,null))[_0xf6ed('0x25')](saveUpdates(_[_0xf6ed('0x3d')](_0x56877d[_0xf6ed('0x77')],[_0xf6ed('0x31'),'description']),null))[_0xf6ed('0x25')](respondWithResult(_0x27e05a,null))[_0xf6ed('0x48')](handleError(_0x27e05a,null));};exports[_0xf6ed('0x80')]=function(_0x1d8669,_0x3dae54,_0x496af2){return db[_0xf6ed('0x2d')][_0xf6ed('0x4b')]({'where':{'id':_0x1d8669[_0xf6ed('0x4a')]['id']}})[_0xf6ed('0x25')](function(_0x1a2ed6){if(_0x1a2ed6){return _0x1a2ed6[_0xf6ed('0x81')]();}})[_0xf6ed('0x25')](function(_0x1fd40d){var _0x5bd01f=path[_0xf6ed('0x50')](config[_0xf6ed('0x51')],_0xf6ed('0x82'),util['format']('%s.%s',_0x1fd40d[_0xf6ed('0x4d')],_0x1fd40d['original_format']));var _0x4d6054=path[_0xf6ed('0x50')](config[_0xf6ed('0x51')],_0xf6ed('0x52'),util[_0xf6ed('0x57')]('%s.%s',_0x1fd40d[_0xf6ed('0x4d')],_0x1fd40d[_0xf6ed('0x4e')]));fs[_0xf6ed('0x66')](_0x5bd01f);fs[_0xf6ed('0x66')](_0x4d6054);return _0x1fd40d;})[_0xf6ed('0x25')](function(_0x45972c){if(_0x45972c){return _0x3dae54[_0xf6ed('0x1d')](0xcc)[_0xf6ed('0x29')]();}})[_0xf6ed('0x25')](handleEntityNotFound(_0x3dae54,null))[_0xf6ed('0x48')](handleError(_0x3dae54,null));};
\ No newline at end of file