Built motion from commit ecf5ab8ec560fd4c6972692268e350fcef2f38e7. Version 3.0.0...
[motion-next.git] / server / api / screenRecording / screenRecording.controller.js
1 const a534_0x2ded=['filters','fieldName','Sequelize','format','rawAttributes','../../components/encryptor','util','existsSync','include','File:\x20\x22','message','query','model','pick','error-middleware/errors','type','rows','ValidationError','server/files/screen_recordings','filename','offset','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','download','duration','body','root','where','update','intersection','params','options','includeAll','limit','join','create','../../config/logger','value','sort','catch','%s.cypher','cancellazione\x20fisica\x20documento\x20%s','createdAt','findOne','undefined','destroy','recording','isNil','uniqueid','key','stack','ScreenRecording\x20not\x20found','info','merge','length','extname','json','Content-Range','Not\x20found','fields','nolimit','differenceBy','.cypher','closedAt','unlink','order','then','findAll','name','path','index','decryptFile','keys','end','status','count','../../config/environment','../../components/parsers/qs','map','ScreenRecording','attributes','lodash','sendStatus'];(function(_0x247bc9,_0x2deddb){const _0x73b609=function(_0x4688f4){while(--_0x4688f4){_0x247bc9['push'](_0x247bc9['shift']());}};_0x73b609(++_0x2deddb);}(a534_0x2ded,0x16f));const a534_0x73b6=function(_0x247bc9,_0x2deddb){_0x247bc9=_0x247bc9-0x0;let _0x73b609=a534_0x2ded[_0x247bc9];return _0x73b609;};const _0x3e4c4d=a534_0x73b6;'use strict';const util=require(_0x3e4c4d('0x31')),path=require(_0x3e4c4d('0x1d')),fs=require('fs'),_=require(_0x3e4c4d('0x29')),qs=require(_0x3e4c4d('0x25')),logger=require(_0x3e4c4d('0x4e'))('api'),config=require(_0x3e4c4d('0x24')),db=require('../../mysqldb')['db'],{Op}=require('sequelize'),{InternalError}=require(_0x3e4c4d('0x39'));function respondWithResult(_0x4688f4,_0xae27ac){return _0xae27ac=_0xae27ac||0xc8,function(_0x2576a1){const _0x461a8d=a534_0x73b6;if(_0x2576a1)return _0x4688f4[_0x461a8d('0x22')](_0xae27ac)[_0x461a8d('0x10')](_0x2576a1);};}function respondWithFilteredResult(_0x5bc3e4,_0x557450){return function(_0xb45cb6){const _0x2229ef=a534_0x73b6;if(_0xb45cb6){const _0x3878c5=_0xb45cb6[_0x2229ef('0x23')],_0xe94172=_0x557450[_0x2229ef('0x3f')];let _0x1b57f7=_0x557450[_0x2229ef('0x3f')]+_0x557450[_0x2229ef('0x4b')],_0x32d47d;return _0x1b57f7>=_0x3878c5?(_0x1b57f7=_0x3878c5,_0x32d47d=0xc8):_0x32d47d=0xce,_0x5bc3e4[_0x2229ef('0x22')](_0x32d47d),_0x5bc3e4['set'](_0x2229ef('0x11'),_0xe94172+'-'+_0x1b57f7+'/'+_0x3878c5)['json'](_0xb45cb6);}return null;};}function saveUpdates(_0x42c91f){return function(_0x2f1e4){const _0x2c96e0=a534_0x73b6;if(_0x2f1e4)return _0x2f1e4[_0x2c96e0('0x46')](_0x42c91f)[_0x2c96e0('0x1a')](function(_0x3a3ef2){return _0x3a3ef2;});return null;};}function handleEntityNotFound(_0x45d97e){return function(_0x453421){const _0x81a4e5=a534_0x73b6;return!_0x453421&&_0x45d97e[_0x81a4e5('0x2a')](0x194),_0x453421;};}function handleError(_0x29f8cf,_0x1c32cc){return _0x1c32cc=_0x1c32cc||0x1f4,function(_0xf0c97b){const _0x1828d0=a534_0x73b6;logger['error'](_0xf0c97b[_0x1828d0('0xa')]),_0xf0c97b[_0x1828d0('0x1c')]&&delete _0xf0c97b[_0x1828d0('0x1c')],_0x29f8cf[_0x1828d0('0x22')](_0x1c32cc)['send'](_0xf0c97b);};}exports[_0x3e4c4d('0x1e')]=function(_0x1c192e,_0x37c95e){const _0x1665f6=_0x3e4c4d;let _0x4db456={};const _0x3eb977={},_0x519556={'count':0x0,'rows':[]},_0x34fdd1=_[_0x1665f6('0x26')](db[_0x1665f6('0x27')][_0x1665f6('0x2f')],function(_0x4fc2a2){const _0xe89c98=_0x1665f6;return{'name':_0x4fc2a2[_0xe89c98('0x2c')],'type':_0x4fc2a2[_0xe89c98('0x3a')][_0xe89c98('0x9')]};});_0x3eb977[_0x1665f6('0x37')]=_[_0x1665f6('0x15')](_[_0x1665f6('0x26')](_0x34fdd1,_0x1665f6('0x1c')),[_0x1665f6('0x2e')]),_0x3eb977[_0x1665f6('0x36')]=_['keys'](_0x1c192e[_0x1665f6('0x36')]),_0x3eb977[_0x1665f6('0x2b')]=_[_0x1665f6('0x47')](_0x3eb977[_0x1665f6('0x37')],_0x3eb977[_0x1665f6('0x36')]),_0x4db456[_0x1665f6('0x28')]=_[_0x1665f6('0x47')](_0x3eb977[_0x1665f6('0x37')],qs['fields'](_0x1c192e[_0x1665f6('0x36')][_0x1665f6('0x13')])),_0x4db456[_0x1665f6('0x28')]=_0x4db456[_0x1665f6('0x28')][_0x1665f6('0xe')]?_0x4db456[_0x1665f6('0x28')]:_0x3eb977['model'];typeof _0x1c192e[_0x1665f6('0x36')][_0x1665f6('0x14')]===_0x1665f6('0x4')&&(_0x4db456[_0x1665f6('0x4b')]=qs[_0x1665f6('0x4b')](_0x1c192e['query'][_0x1665f6('0x4b')]),_0x4db456[_0x1665f6('0x3f')]=qs[_0x1665f6('0x3f')](_0x1c192e['query'][_0x1665f6('0x3f')]));_0x4db456[_0x1665f6('0x19')]=qs[_0x1665f6('0x50')](_0x1c192e[_0x1665f6('0x36')][_0x1665f6('0x50')]),_0x4db456[_0x1665f6('0x45')]=qs['filters'](_[_0x1665f6('0x38')](_0x1c192e[_0x1665f6('0x36')],_0x3eb977[_0x1665f6('0x2b')]),_0x34fdd1);_0x1c192e[_0x1665f6('0x36')]['filter']&&(_0x4db456[_0x1665f6('0x45')]=_['merge'](_0x4db456[_0x1665f6('0x45')],{[Op['or']]:_[_0x1665f6('0x26')](_0x34fdd1,function(_0x52dbaf){const _0x1c2254=_0x1665f6;if(_0x52dbaf[_0x1c2254('0x3a')]!=='VIRTUAL'){const _0x18332e={};return _0x18332e[_0x52dbaf[_0x1c2254('0x1c')]]={[Op['like']]:'%'+_0x1c192e['query']['filter']+'%'},_0x18332e;}})}));_0x4db456=_['merge']({},_0x4db456,_0x1c192e[_0x1665f6('0x49')]);const _0x28b5f7={'where':_0x4db456[_0x1665f6('0x45')]};return db[_0x1665f6('0x27')]['count'](_0x28b5f7)[_0x1665f6('0x1a')](function(_0x36d0ea){const _0x1891b8=_0x1665f6;return _0x519556[_0x1891b8('0x23')]=_0x36d0ea,_0x1c192e[_0x1891b8('0x36')][_0x1891b8('0x4a')]&&(_0x4db456['include']=[{'all':!![]}]),db['ScreenRecording'][_0x1891b8('0x1b')](_0x4db456);})[_0x1665f6('0x1a')](function(_0x7a0323){const _0x536ce6=_0x1665f6;return _0x519556[_0x536ce6('0x3b')]=_0x7a0323,_0x519556;})[_0x1665f6('0x1a')](respondWithFilteredResult(_0x37c95e,_0x4db456))['catch'](handleError(_0x37c95e,null));},exports['show']=function(_0x4fb6f0,_0x224b3f){const _0x10328e=_0x3e4c4d;let _0x2ad5f2={'raw':![],'where':{'id':_0x4fb6f0[_0x10328e('0x48')]['id']}};const _0xf1a679={};return _0xf1a679['model']=_[_0x10328e('0x20')](db[_0x10328e('0x27')][_0x10328e('0x2f')]),_0xf1a679[_0x10328e('0x36')]=_[_0x10328e('0x20')](_0x4fb6f0[_0x10328e('0x36')]),_0xf1a679[_0x10328e('0x2b')]=_['intersection'](_0xf1a679['model'],_0xf1a679['query']),_0x2ad5f2[_0x10328e('0x28')]=_[_0x10328e('0x47')](_0xf1a679['model'],qs['fields'](_0x4fb6f0[_0x10328e('0x36')][_0x10328e('0x13')])),_0x2ad5f2[_0x10328e('0x28')]=_0x2ad5f2[_0x10328e('0x28')]['length']?_0x2ad5f2[_0x10328e('0x28')]:_0xf1a679[_0x10328e('0x37')],_0x4fb6f0[_0x10328e('0x36')]['includeAll']&&(_0x2ad5f2[_0x10328e('0x33')]=[{'all':!![]}]),_0x2ad5f2=_[_0x10328e('0xd')]({},_0x2ad5f2,_0x4fb6f0[_0x10328e('0x49')]),db[_0x10328e('0x27')][_0x10328e('0x3')](_0x2ad5f2)['then'](handleEntityNotFound(_0x224b3f,null))[_0x10328e('0x1a')](respondWithResult(_0x224b3f,null))[_0x10328e('0x51')](handleError(_0x224b3f,null));},exports[_0x3e4c4d('0x4d')]=function(_0x5c97c7,_0xca0757){const _0x3aa36c=_0x3e4c4d;return db[_0x3aa36c('0x27')][_0x3aa36c('0x4d')](_0x5c97c7[_0x3aa36c('0x43')],{})[_0x3aa36c('0x1a')](respondWithResult(_0xca0757,0xc9))['catch'](handleError(_0xca0757,null));},exports['update']=function(_0x392505,_0x5adc80){const _0x1bff16=_0x3e4c4d;return _0x392505[_0x1bff16('0x43')]['id']&&delete _0x392505[_0x1bff16('0x43')]['id'],delete _0x392505[_0x1bff16('0x43')][_0x1bff16('0x42')],delete _0x392505[_0x1bff16('0x43')][_0x1bff16('0x2')],delete _0x392505[_0x1bff16('0x43')][_0x1bff16('0x17')],delete _0x392505['body'][_0x1bff16('0x4f')],db['ScreenRecording'][_0x1bff16('0x3')]({'where':{'id':_0x392505[_0x1bff16('0x48')]['id']}})[_0x1bff16('0x1a')](handleEntityNotFound(_0x5adc80,null))[_0x1bff16('0x1a')](saveUpdates(_0x392505['body'],null))[_0x1bff16('0x1a')](respondWithResult(_0x5adc80,null))[_0x1bff16('0x51')](handleError(_0x5adc80,null));},exports['describe']=function(_0xedc4de,_0x5934cd){const _0x38c8c6=_0x3e4c4d;return db[_0x38c8c6('0x27')]['describe']()['then'](respondWithResult(_0x5934cd,null))['catch'](handleError(_0x5934cd,null));},exports[_0x3e4c4d('0x41')]=function(_0xe55fa7,_0x933993){const _0x117ccd=_0x3e4c4d,_0x40ad2d=require(_0x117ccd('0x30'));let _0x223b97=![];const _0x9fd3da={};return _0xe55fa7[_0x117ccd('0x36')]['type']&&_0xe55fa7[_0x117ccd('0x36')][_0x117ccd('0x3a')]==='uniqueid'?_0x9fd3da[_0x117ccd('0x8')]=_0xe55fa7[_0x117ccd('0x48')]['id']:_0x9fd3da['id']=_0xe55fa7[_0x117ccd('0x48')]['id'],db[_0x117ccd('0x27')][_0x117ccd('0x3')]({'where':_0x9fd3da,'attributes':['id',_0x117ccd('0x4f')],'raw':!![]})[_0x117ccd('0x1a')](handleEntityNotFound(_0x933993,null))[_0x117ccd('0x1a')](function(_0xd4441a){const _0x570432=_0x117ccd;if(_0xd4441a){const _0x543334=path[_0x570432('0x4c')](config[_0x570432('0x44')],_0x570432('0x3d'),_0xd4441a[_0x570432('0x4f')]),_0x1f92a3=util['format'](_0x570432('0x0'),_0x543334);if(fs[_0x570432('0x32')](_0x1f92a3))return _0x223b97=!![],_0x40ad2d[_0x570432('0x1f')](_0x1f92a3,_0x543334,config['secrets'][_0x570432('0x6')])[_0x570432('0x1a')](function(){return _0xd4441a;});return _0xd4441a;}})[_0x117ccd('0x1a')](function(_0xa3eebd){const _0x4388c2=_0x117ccd;if(_0xa3eebd){const _0x1459be=path[_0x4388c2('0x4c')](config[_0x4388c2('0x44')],_0x4388c2('0x3d'),_0xa3eebd[_0x4388c2('0x4f')]);if(!fs[_0x4388c2('0x32')](_0x1459be))throw new db[(_0x4388c2('0x2d'))][(_0x4388c2('0x3c'))](_0x4388c2('0xb'));return _0xa3eebd[_0x4388c2('0x3e')]?_0x933993[_0x4388c2('0x41')](_0x1459be,_0xa3eebd[_0x4388c2('0x3e')]+path[_0x4388c2('0xf')](_0x1459be),function(){_0x223b97&&fs['unlink'](_0x1459be);}):_0x933993['download'](_0x1459be,function(){const _0x367e89=_0x4388c2;_0x223b97&&fs[_0x367e89('0x18')](_0x1459be);});}})[_0x117ccd('0x51')](function(_0x20e279){const _0x929674=_0x117ccd;if(_0x20e279[_0x929674('0x35')]===_0x929674('0xb'))_0x933993[_0x929674('0x22')](0x194)['send'](_0x929674('0x12'));else return handleError(_0x933993,null);});},exports[_0x3e4c4d('0x5')]=function(_0x45b0a2,_0x485c13){const _0x5c91c3=_0x3e4c4d;return db[_0x5c91c3('0x27')]['findOne']({'where':{'id':_0x45b0a2[_0x5c91c3('0x48')]['id']}})[_0x5c91c3('0x1a')](function(_0x4ff86a){if(!_0x4ff86a)throw new ReferenceError('Entity\x20not\x20found');return _0x4ff86a;})[_0x5c91c3('0x1a')](function(_0x39ac8a){const _0x229400=_0x5c91c3;let _0x20ba6e=path[_0x229400('0x4c')](config[_0x229400('0x44')],_0x229400('0x3d'),_0x39ac8a[_0x229400('0x4f')]);return logger[_0x229400('0xc')](_0x229400('0x1'),_0x20ba6e),!_['isNil'](_0x39ac8a[_0x229400('0x4f')])&&fs[_0x229400('0x32')](_0x20ba6e)&&(logger[_0x229400('0xc')](_0x229400('0x34')+_0x20ba6e+_0x229400('0x40')),fs['unlinkSync'](_0x20ba6e)),_0x20ba6e=_0x20ba6e+_0x229400('0x16'),!_[_0x229400('0x7')](_0x39ac8a[_0x229400('0x4f')])&&fs[_0x229400('0x32')](_0x20ba6e)&&(logger[_0x229400('0xc')](_0x229400('0x34')+_0x20ba6e+_0x229400('0x40')),fs['unlinkSync'](_0x20ba6e)),_0x39ac8a;})['then'](function(_0x43e188){if(!_0x43e188)throw new InternalError();return _0x43e188['destroy']();})['then'](function(){const _0x3cb3f6=_0x5c91c3;_0x485c13[_0x3cb3f6('0x22')](0xcc)[_0x3cb3f6('0x21')]();})[_0x5c91c3('0x51')](handleError(_0x485c13,null));};