ed764a98ccbc63f359576816dcd0b808a6ff2b4a
[motion-next.git] / server / api / squareRecording / squareRecording.controller.js
1 const a605_0x5db5=['sequelize','create','Content-Range','order','json','rawAttributes','extname','map','\x22\x20trovato\x20eseguo\x20la\x20cancellazione','.cypher','end','type','format','model','info','../../mysqldb','unlinkSync','uniqueid','destroy','SquareRecording\x20not\x20found','filename','existsSync','isNil','File:\x20\x22','key','nolimit','api','VIRTUAL','keys','pick','where','sort','then','show','length','like','limit','../../components/encryptor','recording','SquareRecording','catch','intersection','filter','name','secrets','findAll','error-middleware/errors','../../config/logger','index','Entity\x20not\x20found','status','%s.cypher','params','../../components/parsers/qs','offset','body','util','sendStatus','Not\x20found','cancellazione\x20fisica\x20documento\x20%s','attributes','error','message','fields','path','includeAll','include','send','options','../../config/environment','findOne','update','merge','savePath','query','filters','count'];(function(_0x486895,_0x5db5ba){const _0x56ef55=function(_0xe2f9b){while(--_0xe2f9b){_0x486895['push'](_0x486895['shift']());}};_0x56ef55(++_0x5db5ba);}(a605_0x5db5,0xb4));const a605_0x56ef=function(_0x486895,_0x5db5ba){_0x486895=_0x486895-0x0;let _0x56ef55=a605_0x5db5[_0x486895];return _0x56ef55;};const _0x3133df=a605_0x56ef;'use strict';const util=require(_0x3133df('0x1e')),path=require(_0x3133df('0x26')),fs=require('fs'),_=require('lodash'),qs=require(_0x3133df('0x1b')),logger=require(_0x3133df('0x15'))(_0x3133df('0x0')),config=require(_0x3133df('0x2b')),db=require(_0x3133df('0x42'))['db'],{Op,ValidationError}=require(_0x3133df('0x33')),{InternalError}=require(_0x3133df('0x14'));function respondWithResult(_0xe2f9b,_0xd45f45){return _0xd45f45=_0xd45f45||0xc8,function(_0x28b6f9){const _0x187903=a605_0x56ef;if(_0x28b6f9)return _0xe2f9b['status'](_0xd45f45)[_0x187903('0x37')](_0x28b6f9);};}function respondWithFilteredResult(_0x1755b7,_0x164358){return function(_0x535c51){const _0x43e58b=a605_0x56ef;if(_0x535c51){const _0x30fd9f=_0x535c51[_0x43e58b('0x32')],_0x15f7a8=_0x164358[_0x43e58b('0x1c')];let _0x3184a5=_0x164358[_0x43e58b('0x1c')]+_0x164358['limit'],_0x3c338d;return _0x3184a5>=_0x30fd9f?(_0x3184a5=_0x30fd9f,_0x3c338d=0xc8):_0x3c338d=0xce,_0x1755b7['status'](_0x3c338d),_0x1755b7['set'](_0x43e58b('0x35'),_0x15f7a8+'-'+_0x3184a5+'/'+_0x30fd9f)['json'](_0x535c51);}return null;};}function saveUpdates(_0x511f83){return function(_0x16e2a3){const _0x29ce39=a605_0x56ef;if(_0x16e2a3)return _0x16e2a3[_0x29ce39('0x2d')](_0x511f83)[_0x29ce39('0x6')](function(_0x1eb3f7){return _0x1eb3f7;});return null;};}function handleEntityNotFound(_0x5e32bf){return function(_0x598d52){const _0x1311b0=a605_0x56ef;return!_0x598d52&&_0x5e32bf[_0x1311b0('0x1f')](0x194),_0x598d52;};}function handleError(_0x458746,_0xdaf7e3){return _0xdaf7e3=_0xdaf7e3||0x1f4,function(_0x4ed69f){const _0x14e9cc=a605_0x56ef;logger[_0x14e9cc('0x23')](_0x4ed69f['stack']),_0x4ed69f['name']&&delete _0x4ed69f[_0x14e9cc('0x11')],_0x458746[_0x14e9cc('0x18')](_0xdaf7e3)['send'](_0x4ed69f);};}exports[_0x3133df('0x16')]=function(_0x36653c,_0xfe55b9){const _0xfb1336=_0x3133df;let _0x138238={};const _0x3b25a0={},_0x5bb93a={'count':0x0,'rows':[]},_0x2063ed=_[_0xfb1336('0x3a')](db[_0xfb1336('0xd')][_0xfb1336('0x38')],function(_0x1577a3){const _0x550dac=_0xfb1336;return{'name':_0x1577a3['fieldName'],'type':_0x1577a3[_0x550dac('0x3e')][_0x550dac('0x4b')]};});_0x3b25a0[_0xfb1336('0x40')]=_[_0xfb1336('0x3a')](_0x2063ed,_0xfb1336('0x11')),_0x3b25a0[_0xfb1336('0x30')]=_[_0xfb1336('0x2')](_0x36653c[_0xfb1336('0x30')]),_0x3b25a0['filters']=_[_0xfb1336('0xf')](_0x3b25a0[_0xfb1336('0x40')],_0x3b25a0[_0xfb1336('0x30')]),_0x138238[_0xfb1336('0x22')]=_[_0xfb1336('0xf')](_0x3b25a0['model'],qs[_0xfb1336('0x25')](_0x36653c[_0xfb1336('0x30')][_0xfb1336('0x25')])),_0x138238[_0xfb1336('0x22')]=_0x138238[_0xfb1336('0x22')][_0xfb1336('0x8')]?_0x138238[_0xfb1336('0x22')]:_0x3b25a0[_0xfb1336('0x40')];typeof _0x36653c[_0xfb1336('0x30')][_0xfb1336('0x4c')]==='undefined'&&(_0x138238['limit']=qs['limit'](_0x36653c[_0xfb1336('0x30')][_0xfb1336('0xa')]),_0x138238[_0xfb1336('0x1c')]=qs[_0xfb1336('0x1c')](_0x36653c['query'][_0xfb1336('0x1c')]));_0x138238[_0xfb1336('0x36')]=qs['sort'](_0x36653c[_0xfb1336('0x30')][_0xfb1336('0x5')]),_0x138238[_0xfb1336('0x4')]=qs[_0xfb1336('0x31')](_[_0xfb1336('0x3')](_0x36653c[_0xfb1336('0x30')],_0x3b25a0['filters']),_0x2063ed);_0x36653c[_0xfb1336('0x30')][_0xfb1336('0x10')]&&(_0x138238[_0xfb1336('0x4')]=_[_0xfb1336('0x2e')](_0x138238[_0xfb1336('0x4')],{[Op['or']]:_['map'](_0x2063ed,function(_0x1e0e51){const _0x9c448e=_0xfb1336;if(_0x1e0e51[_0x9c448e('0x3e')]!==_0x9c448e('0x1')){const _0x423dfd={};return _0x423dfd[_0x1e0e51['name']]={[Op[_0x9c448e('0x9')]]:'%'+_0x36653c['query'][_0x9c448e('0x10')]+'%'},_0x423dfd;}})}));_0x138238=_[_0xfb1336('0x2e')]({},_0x138238,_0x36653c[_0xfb1336('0x2a')]);const _0x533ad6={'where':_0x138238[_0xfb1336('0x4')]};return db[_0xfb1336('0xd')][_0xfb1336('0x32')](_0x533ad6)[_0xfb1336('0x6')](function(_0x505aa0){const _0x472ed6=_0xfb1336;return _0x5bb93a[_0x472ed6('0x32')]=_0x505aa0,_0x36653c[_0x472ed6('0x30')][_0x472ed6('0x27')]&&(_0x138238[_0x472ed6('0x28')]=[{'all':!![]}]),db[_0x472ed6('0xd')][_0x472ed6('0x13')](_0x138238);})[_0xfb1336('0x6')](function(_0x27e842){return _0x5bb93a['rows']=_0x27e842,_0x5bb93a;})['then'](respondWithFilteredResult(_0xfe55b9,_0x138238))[_0xfb1336('0xe')](handleError(_0xfe55b9,null));},exports[_0x3133df('0x7')]=function(_0x59169a,_0x55ddcd){const _0x55ba3f=_0x3133df;let _0xb4763e={'raw':!![],'where':{'id':_0x59169a['params']['id']}};const _0x1aecd3={};return _0x1aecd3[_0x55ba3f('0x40')]=_['keys'](db[_0x55ba3f('0xd')][_0x55ba3f('0x38')]),_0x1aecd3[_0x55ba3f('0x30')]=_[_0x55ba3f('0x2')](_0x59169a[_0x55ba3f('0x30')]),_0x1aecd3[_0x55ba3f('0x31')]=_['intersection'](_0x1aecd3['model'],_0x1aecd3[_0x55ba3f('0x30')]),_0xb4763e['attributes']=_[_0x55ba3f('0xf')](_0x1aecd3['model'],qs[_0x55ba3f('0x25')](_0x59169a[_0x55ba3f('0x30')][_0x55ba3f('0x25')])),_0xb4763e['attributes']=_0xb4763e[_0x55ba3f('0x22')][_0x55ba3f('0x8')]?_0xb4763e['attributes']:_0x1aecd3[_0x55ba3f('0x40')],_0x59169a[_0x55ba3f('0x30')][_0x55ba3f('0x27')]&&(_0xb4763e[_0x55ba3f('0x28')]=[{'all':!![]}]),_0xb4763e=_[_0x55ba3f('0x2e')]({},_0xb4763e,_0x59169a[_0x55ba3f('0x2a')]),db['SquareRecording'][_0x55ba3f('0x2c')](_0xb4763e)[_0x55ba3f('0x6')](handleEntityNotFound(_0x55ddcd,null))[_0x55ba3f('0x6')](respondWithResult(_0x55ddcd,null))[_0x55ba3f('0xe')](handleError(_0x55ddcd,null));},exports[_0x3133df('0x34')]=function(_0x5c3718,_0x34fd77){const _0x38929a=_0x3133df;return db[_0x38929a('0xd')][_0x38929a('0x34')](_0x5c3718['body'],{})['then'](respondWithResult(_0x34fd77,0xc9))[_0x38929a('0xe')](handleError(_0x34fd77,null));},exports[_0x3133df('0x2d')]=function(_0x14300d,_0x463660){const _0x507274=_0x3133df;return _0x14300d['body']['id']&&delete _0x14300d['body']['id'],db[_0x507274('0xd')]['findOne']({'where':{'id':_0x14300d['params']['id']}})[_0x507274('0x6')](handleEntityNotFound(_0x463660,null))[_0x507274('0x6')](saveUpdates(_0x14300d[_0x507274('0x1d')],null))['then'](respondWithResult(_0x463660,null))['catch'](handleError(_0x463660,null));},exports['download']=function(_0xb0ef8b,_0x1bb8b1){const _0x2752f8=_0x3133df,_0x39d8cb=require(_0x2752f8('0xb'));let _0x694564=![];const _0x927edb={};return _0xb0ef8b[_0x2752f8('0x30')][_0x2752f8('0x3e')]&&_0xb0ef8b['query'][_0x2752f8('0x3e')]===_0x2752f8('0x44')?_0x927edb[_0x2752f8('0x44')]=_0xb0ef8b[_0x2752f8('0x1a')]['id']:_0x927edb['id']=_0xb0ef8b[_0x2752f8('0x1a')]['id'],db[_0x2752f8('0xd')][_0x2752f8('0x2c')]({'where':_0x927edb,'attributes':['id',_0x2752f8('0x2f'),_0x2752f8('0x47')],'raw':!![]})[_0x2752f8('0x6')](handleEntityNotFound(_0x1bb8b1,null))[_0x2752f8('0x6')](function(_0x413538){const _0x295bcb=_0x2752f8;if(_0x413538){const _0x1126c9=_0x413538[_0x295bcb('0x2f')],_0x101e23=util[_0x295bcb('0x3f')](_0x295bcb('0x19'),_0x1126c9);if(fs[_0x295bcb('0x48')](_0x101e23))return _0x694564=!![],_0x39d8cb['decryptFile'](_0x101e23,_0x1126c9,config[_0x295bcb('0x12')][_0x295bcb('0xc')])[_0x295bcb('0x6')](function(){return _0x413538;});return _0x413538;}})[_0x2752f8('0x6')](function(_0x38d84a){const _0x1b0cfc=_0x2752f8;if(_0x38d84a){const _0x1a50b7=_0x38d84a[_0x1b0cfc('0x2f')];if(!fs[_0x1b0cfc('0x48')](_0x1a50b7))throw new ValidationError(_0x1b0cfc('0x46'));return _0x38d84a[_0x1b0cfc('0x47')]?_0x1bb8b1['download'](_0x1a50b7,_0x38d84a[_0x1b0cfc('0x47')]+path[_0x1b0cfc('0x39')](_0x1a50b7),function(){_0x694564&&fs['unlink'](_0x1a50b7);}):_0x1bb8b1['download'](_0x1a50b7,function(){_0x694564&&fs['unlink'](_0x1a50b7);});}})[_0x2752f8('0xe')](function(_0x194d94){const _0x58fdca=_0x2752f8;if(_0x194d94[_0x58fdca('0x24')]===_0x58fdca('0x46'))_0x1bb8b1[_0x58fdca('0x18')](0x194)[_0x58fdca('0x29')](_0x58fdca('0x20'));else return handleError(_0x1bb8b1,null);});},exports['destroy']=function(_0x369836,_0x3ee25c){const _0xf9a0c3=_0x3133df;return db['SquareRecording'][_0xf9a0c3('0x2c')]({'where':{'id':_0x369836[_0xf9a0c3('0x1a')]['id']}})[_0xf9a0c3('0x6')](function(_0x405e93){const _0x175b60=_0xf9a0c3;if(!_0x405e93)throw new ReferenceError(_0x175b60('0x17'));return _0x405e93;})[_0xf9a0c3('0x6')](function(_0x392fd8){const _0x3c8d5f=_0xf9a0c3;let _0x5171a0=_0x392fd8[_0x3c8d5f('0x2f')];return logger[_0x3c8d5f('0x41')](_0x3c8d5f('0x21'),_0x5171a0),!_[_0x3c8d5f('0x49')](_0x392fd8[_0x3c8d5f('0x2f')])&&fs[_0x3c8d5f('0x48')](_0x5171a0)&&(logger['info'](_0x3c8d5f('0x4a')+_0x5171a0+'\x22\x20trovato\x20eseguo\x20la\x20cancellazione'),fs[_0x3c8d5f('0x43')](_0x5171a0)),_0x5171a0=_0x5171a0+_0x3c8d5f('0x3c'),!_['isNil'](_0x392fd8[_0x3c8d5f('0x2f')])&&fs[_0x3c8d5f('0x48')](_0x5171a0)&&(logger['info']('File:\x20\x22'+_0x5171a0+_0x3c8d5f('0x3b')),fs[_0x3c8d5f('0x43')](_0x5171a0)),_0x392fd8;})['then'](function(_0x5297f2){const _0x558ed9=_0xf9a0c3;if(!_0x5297f2)throw new InternalError();return _0x5297f2[_0x558ed9('0x45')]();})['then'](function(){const _0x14614d=_0xf9a0c3;_0x3ee25c[_0x14614d('0x18')](0xcc)[_0x14614d('0x3d')]();})[_0xf9a0c3('0xe')](handleError(_0x3ee25c,null));};