31504352a707db18d72a0364e9c5546594dcbba4
[motion-next.git] / server / api / screenRecording / screenRecording.controller.js
1 const a534_0x265b=['limit','set','map','decryptFile','download','message','value','duration','send','root','../../config/logger','index','order','keys','uniqueid','intersection','length','catch','options','differenceBy','offset','ScreenRecording','describe','type','unlinkSync','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','filename','update','where','error','count','pick','sendStatus','error-middleware/errors','query','create','secrets','existsSync','server/files/screen_recordings','name','end','../../mysqldb','Content-Range','api','nolimit','fields','cancellazione\x20fisica\x20documento\x20%s','params','format','model','Entity\x20not\x20found','.cypher','merge','stack','filter','body','attributes','include','filters','createdAt','../../components/encryptor','key','status','json','includeAll','unlink','then','join','../../config/environment','File:\x20\x22','like','findAll','info','sort','%s.cypher','destroy','rawAttributes','findOne','closedAt','lodash'];(function(_0x300fbc,_0x265b43){const _0x2f56aa=function(_0x3c15d3){while(--_0x3c15d3){_0x300fbc['push'](_0x300fbc['shift']());}};_0x2f56aa(++_0x265b43);}(a534_0x265b,0x1d4));const a534_0x2f56=function(_0x300fbc,_0x265b43){_0x300fbc=_0x300fbc-0x0;let _0x2f56aa=a534_0x265b[_0x300fbc];return _0x2f56aa;};const _0x451b1f=a534_0x2f56;'use strict';const util=require('util'),path=require('path'),fs=require('fs'),_=require(_0x451b1f('0xb')),qs=require('../../components/parsers/qs'),logger=require(_0x451b1f('0x16'))(_0x451b1f('0x37')),config=require(_0x451b1f('0x0')),db=require(_0x451b1f('0x35'))['db'],{Op,ValidationError}=require('sequelize'),{InternalError}=require(_0x451b1f('0x2d'));function respondWithResult(_0x3c15d3,_0x487f5f){return _0x487f5f=_0x487f5f||0xc8,function(_0x319a49){const _0x3f83e7=a534_0x2f56;if(_0x319a49)return _0x3c15d3['status'](_0x487f5f)[_0x3f83e7('0x4b')](_0x319a49);};}function respondWithFilteredResult(_0x37f670,_0x135c01){return function(_0x5a7bb1){const _0x2f5fef=a534_0x2f56;if(_0x5a7bb1){const _0x479a29=_0x5a7bb1[_0x2f5fef('0x2a')],_0x2fbb36=_0x135c01['offset'];let _0x19e48a=_0x135c01[_0x2f5fef('0x20')]+_0x135c01[_0x2f5fef('0xc')],_0x33ed53;return _0x19e48a>=_0x479a29?(_0x19e48a=_0x479a29,_0x33ed53=0xc8):_0x33ed53=0xce,_0x37f670[_0x2f5fef('0x4a')](_0x33ed53),_0x37f670[_0x2f5fef('0xd')](_0x2f5fef('0x36'),_0x2fbb36+'-'+_0x19e48a+'/'+_0x479a29)['json'](_0x5a7bb1);}return null;};}function saveUpdates(_0xbe7f96){return function(_0x5500c9){const _0x33d4ab=a534_0x2f56;if(_0x5500c9)return _0x5500c9[_0x33d4ab('0x27')](_0xbe7f96)['then'](function(_0x3227c5){return _0x3227c5;});return null;};}function handleEntityNotFound(_0x1e4bec){return function(_0x5e7a88){const _0x5a48a4=a534_0x2f56;return!_0x5e7a88&&_0x1e4bec[_0x5a48a4('0x2c')](0x194),_0x5e7a88;};}function handleError(_0x11f8db,_0x2cdf70){return _0x2cdf70=_0x2cdf70||0x1f4,function(_0x3e3b86){const _0x3f8e0b=a534_0x2f56;logger[_0x3f8e0b('0x29')](_0x3e3b86[_0x3f8e0b('0x41')]),_0x3e3b86[_0x3f8e0b('0x33')]&&delete _0x3e3b86[_0x3f8e0b('0x33')],_0x11f8db[_0x3f8e0b('0x4a')](_0x2cdf70)[_0x3f8e0b('0x14')](_0x3e3b86);};}exports[_0x451b1f('0x17')]=function(_0x6078b8,_0x32516d){const _0x64b526=_0x451b1f;let _0x161e75={};const _0x19317d={},_0x1f31f2={'count':0x0,'rows':[]},_0x891420=_[_0x64b526('0xe')](db[_0x64b526('0x21')][_0x64b526('0x8')],function(_0x55b65f){const _0x111424=_0x64b526;return{'name':_0x55b65f['fieldName'],'type':_0x55b65f[_0x111424('0x23')][_0x111424('0x49')]};});_0x19317d['model']=_[_0x64b526('0x1f')](_[_0x64b526('0xe')](_0x891420,_0x64b526('0x33')),[_0x64b526('0x3c')]),_0x19317d[_0x64b526('0x2e')]=_[_0x64b526('0x19')](_0x6078b8[_0x64b526('0x2e')]),_0x19317d['filters']=_['intersection'](_0x19317d[_0x64b526('0x3d')],_0x19317d[_0x64b526('0x2e')]),_0x161e75[_0x64b526('0x44')]=_[_0x64b526('0x1b')](_0x19317d[_0x64b526('0x3d')],qs[_0x64b526('0x39')](_0x6078b8['query']['fields'])),_0x161e75[_0x64b526('0x44')]=_0x161e75['attributes'][_0x64b526('0x1c')]?_0x161e75[_0x64b526('0x44')]:_0x19317d[_0x64b526('0x3d')];typeof _0x6078b8['query'][_0x64b526('0x38')]==='undefined'&&(_0x161e75[_0x64b526('0xc')]=qs[_0x64b526('0xc')](_0x6078b8['query'][_0x64b526('0xc')]),_0x161e75[_0x64b526('0x20')]=qs[_0x64b526('0x20')](_0x6078b8[_0x64b526('0x2e')][_0x64b526('0x20')]));_0x161e75[_0x64b526('0x18')]=qs['sort'](_0x6078b8[_0x64b526('0x2e')][_0x64b526('0x5')]),_0x161e75['where']=qs[_0x64b526('0x46')](_[_0x64b526('0x2b')](_0x6078b8[_0x64b526('0x2e')],_0x19317d[_0x64b526('0x46')]),_0x891420);_0x6078b8[_0x64b526('0x2e')]['filter']&&(_0x161e75[_0x64b526('0x28')]=_[_0x64b526('0x40')](_0x161e75[_0x64b526('0x28')],{[Op['or']]:_[_0x64b526('0xe')](_0x891420,function(_0x172a4b){const _0x3c2815=_0x64b526;if(_0x172a4b[_0x3c2815('0x23')]!=='VIRTUAL'){const _0x4f5cbd={};return _0x4f5cbd[_0x172a4b[_0x3c2815('0x33')]]={[Op[_0x3c2815('0x2')]]:'%'+_0x6078b8[_0x3c2815('0x2e')][_0x3c2815('0x42')]+'%'},_0x4f5cbd;}})}));_0x161e75=_[_0x64b526('0x40')]({},_0x161e75,_0x6078b8[_0x64b526('0x1e')]);const _0x371803={'where':_0x161e75[_0x64b526('0x28')]};return db[_0x64b526('0x21')][_0x64b526('0x2a')](_0x371803)['then'](function(_0x1c76f5){const _0x31d6a8=_0x64b526;return _0x1f31f2['count']=_0x1c76f5,_0x6078b8[_0x31d6a8('0x2e')][_0x31d6a8('0x4c')]&&(_0x161e75[_0x31d6a8('0x45')]=[{'all':!![]}]),db['ScreenRecording'][_0x31d6a8('0x3')](_0x161e75);})[_0x64b526('0x4e')](function(_0x4ba34b){return _0x1f31f2['rows']=_0x4ba34b,_0x1f31f2;})[_0x64b526('0x4e')](respondWithFilteredResult(_0x32516d,_0x161e75))[_0x64b526('0x1d')](handleError(_0x32516d,null));},exports['show']=function(_0x1c4ec8,_0x5c464e){const _0x228ea7=_0x451b1f;let _0x3f8c3b={'raw':![],'where':{'id':_0x1c4ec8[_0x228ea7('0x3b')]['id']}};const _0x311831={};return _0x311831['model']=_[_0x228ea7('0x19')](db[_0x228ea7('0x21')][_0x228ea7('0x8')]),_0x311831[_0x228ea7('0x2e')]=_['keys'](_0x1c4ec8[_0x228ea7('0x2e')]),_0x311831[_0x228ea7('0x46')]=_[_0x228ea7('0x1b')](_0x311831[_0x228ea7('0x3d')],_0x311831[_0x228ea7('0x2e')]),_0x3f8c3b[_0x228ea7('0x44')]=_[_0x228ea7('0x1b')](_0x311831['model'],qs[_0x228ea7('0x39')](_0x1c4ec8[_0x228ea7('0x2e')][_0x228ea7('0x39')])),_0x3f8c3b[_0x228ea7('0x44')]=_0x3f8c3b[_0x228ea7('0x44')][_0x228ea7('0x1c')]?_0x3f8c3b['attributes']:_0x311831[_0x228ea7('0x3d')],_0x1c4ec8[_0x228ea7('0x2e')][_0x228ea7('0x4c')]&&(_0x3f8c3b[_0x228ea7('0x45')]=[{'all':!![]}]),_0x3f8c3b=_[_0x228ea7('0x40')]({},_0x3f8c3b,_0x1c4ec8[_0x228ea7('0x1e')]),db[_0x228ea7('0x21')]['findOne'](_0x3f8c3b)['then'](handleEntityNotFound(_0x5c464e,null))[_0x228ea7('0x4e')](respondWithResult(_0x5c464e,null))['catch'](handleError(_0x5c464e,null));},exports[_0x451b1f('0x2f')]=function(_0x26e58f,_0x13d0f9){const _0x38f611=_0x451b1f;return db[_0x38f611('0x21')]['create'](_0x26e58f[_0x38f611('0x43')],{})['then'](respondWithResult(_0x13d0f9,0xc9))[_0x38f611('0x1d')](handleError(_0x13d0f9,null));},exports['update']=function(_0x391103,_0x16a06d){const _0xb567c1=_0x451b1f;return _0x391103[_0xb567c1('0x43')]['id']&&delete _0x391103[_0xb567c1('0x43')]['id'],delete _0x391103[_0xb567c1('0x43')][_0xb567c1('0x13')],delete _0x391103[_0xb567c1('0x43')][_0xb567c1('0x47')],delete _0x391103[_0xb567c1('0x43')][_0xb567c1('0xa')],delete _0x391103[_0xb567c1('0x43')]['value'],db[_0xb567c1('0x21')][_0xb567c1('0x9')]({'where':{'id':_0x391103[_0xb567c1('0x3b')]['id']}})['then'](handleEntityNotFound(_0x16a06d,null))[_0xb567c1('0x4e')](saveUpdates(_0x391103[_0xb567c1('0x43')],null))[_0xb567c1('0x4e')](respondWithResult(_0x16a06d,null))[_0xb567c1('0x1d')](handleError(_0x16a06d,null));},exports[_0x451b1f('0x22')]=function(_0x474d25,_0xd5bbd0){const _0x59cf7b=_0x451b1f;return db[_0x59cf7b('0x21')][_0x59cf7b('0x22')]()[_0x59cf7b('0x4e')](respondWithResult(_0xd5bbd0,null))['catch'](handleError(_0xd5bbd0,null));},exports[_0x451b1f('0x10')]=function(_0x278072,_0x143cc2){const _0x3cd0eb=_0x451b1f,_0x1125f0=require(_0x3cd0eb('0x48'));let _0x5631a2=![];const _0x300af5={};return _0x278072[_0x3cd0eb('0x2e')][_0x3cd0eb('0x23')]&&_0x278072[_0x3cd0eb('0x2e')][_0x3cd0eb('0x23')]==='uniqueid'?_0x300af5[_0x3cd0eb('0x1a')]=_0x278072[_0x3cd0eb('0x3b')]['id']:_0x300af5['id']=_0x278072[_0x3cd0eb('0x3b')]['id'],db[_0x3cd0eb('0x21')]['findOne']({'where':_0x300af5,'attributes':['id','value'],'raw':!![]})[_0x3cd0eb('0x4e')](handleEntityNotFound(_0x143cc2,null))[_0x3cd0eb('0x4e')](function(_0x10540e){const _0x5e5d68=_0x3cd0eb;if(_0x10540e){const _0x1ce89e=path[_0x5e5d68('0x4f')](config[_0x5e5d68('0x15')],_0x5e5d68('0x32'),_0x10540e['value']),_0x511713=util[_0x5e5d68('0x3c')](_0x5e5d68('0x6'),_0x1ce89e);if(fs[_0x5e5d68('0x31')](_0x511713))return _0x5631a2=!![],_0x1125f0[_0x5e5d68('0xf')](_0x511713,_0x1ce89e,config[_0x5e5d68('0x30')]['recording'])['then'](function(){return _0x10540e;});return _0x10540e;}})[_0x3cd0eb('0x4e')](function(_0x32dd58){const _0x65ea32=_0x3cd0eb;if(_0x32dd58){const _0x17fd84=path[_0x65ea32('0x4f')](config[_0x65ea32('0x15')],'server/files/screen_recordings',_0x32dd58['value']);if(!fs[_0x65ea32('0x31')](_0x17fd84))throw new ValidationError('ScreenRecording\x20not\x20found');return _0x32dd58[_0x65ea32('0x26')]?_0x143cc2[_0x65ea32('0x10')](_0x17fd84,_0x32dd58['filename']+path['extname'](_0x17fd84),function(){const _0x4b9535=_0x65ea32;_0x5631a2&&fs[_0x4b9535('0x4d')](_0x17fd84);}):_0x143cc2[_0x65ea32('0x10')](_0x17fd84,function(){const _0x1d5b20=_0x65ea32;_0x5631a2&&fs[_0x1d5b20('0x4d')](_0x17fd84);});}})[_0x3cd0eb('0x1d')](function(_0x1eff53){const _0x55f438=_0x3cd0eb;if(_0x1eff53[_0x55f438('0x11')]==='ScreenRecording\x20not\x20found')_0x143cc2['status'](0x194)['send']('Not\x20found');else return handleError(_0x143cc2,null);});},exports[_0x451b1f('0x7')]=function(_0x123faf,_0x4148ac){const _0xa6753f=_0x451b1f;return db[_0xa6753f('0x21')][_0xa6753f('0x9')]({'where':{'id':_0x123faf[_0xa6753f('0x3b')]['id']}})[_0xa6753f('0x4e')](function(_0x1340f2){const _0x579503=_0xa6753f;if(!_0x1340f2)throw new ReferenceError(_0x579503('0x3e'));return _0x1340f2;})['then'](function(_0x1d0a9e){const _0x27fbf1=_0xa6753f;let _0x287f2f=path['join'](config[_0x27fbf1('0x15')],'server/files/screen_recordings',_0x1d0a9e[_0x27fbf1('0x12')]);return logger['info'](_0x27fbf1('0x3a'),_0x287f2f),!_['isNil'](_0x1d0a9e['value'])&&fs['existsSync'](_0x287f2f)&&(logger['info']('File:\x20\x22'+_0x287f2f+_0x27fbf1('0x25')),fs[_0x27fbf1('0x24')](_0x287f2f)),_0x287f2f=_0x287f2f+_0x27fbf1('0x3f'),!_['isNil'](_0x1d0a9e[_0x27fbf1('0x12')])&&fs['existsSync'](_0x287f2f)&&(logger[_0x27fbf1('0x4')](_0x27fbf1('0x1')+_0x287f2f+_0x27fbf1('0x25')),fs[_0x27fbf1('0x24')](_0x287f2f)),_0x1d0a9e;})[_0xa6753f('0x4e')](function(_0x4e042e){if(!_0x4e042e)throw new InternalError();return _0x4e042e['destroy']();})[_0xa6753f('0x4e')](function(){const _0x31137d=_0xa6753f;_0x4148ac[_0x31137d('0x4a')](0xcc)[_0x31137d('0x34')]();})[_0xa6753f('0x1d')](handleError(_0x4148ac,null));};