79d65d7d6380e233c359050db4e65a6ad6282c5a
[motion-next.git] / server / api / schedule / schedule.controller.js
1 const a530_0x141c=['includeAll','Schedule','count','attributes','limit','key','options','length','stack','findOne','fields','filters','order','where','status','../../config/schedule','../../components/parsers/qs','type','body','undefined','VIRTUAL','destroy','offset','create','fieldName','sequelize','Content-Range','Unable\x20to\x20retrieve\x20the\x20current\x20user','show','update','filter','intersection','query','nolimit','end','../../config/logger','like','catch','run','json','lodash','merge','error','Scheduler','then','user','sort','sendStatus','pick','role','params','model','keys','get','rawAttributes','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','api','name','findAll','include','../../mysqldb','send','map'];(function(_0x51c6bc,_0x141c57){const _0x4d5cae=function(_0x4dadce){while(--_0x4dadce){_0x51c6bc['push'](_0x51c6bc['shift']());}};_0x4d5cae(++_0x141c57);}(a530_0x141c,0xd7));const a530_0x4d5c=function(_0x51c6bc,_0x141c57){_0x51c6bc=_0x51c6bc-0x0;let _0x4d5cae=a530_0x141c[_0x51c6bc];return _0x4d5cae;};const _0x13454e=a530_0x4d5c;'use strict';const _=require(_0x13454e('0x11')),qs=require(_0x13454e('0x39')),logger=require(_0x13454e('0xc'))(_0x13454e('0x22')),db=require(_0x13454e('0x26'))['db'],{Op}=require(_0x13454e('0x2'));function respondWithStatusCode(_0x4dadce,_0x4e7199){return _0x4e7199=_0x4e7199||0xcc,function(_0x3dd99b){const _0x207c80=a530_0x4d5c;if(_0x3dd99b)return _0x4dadce[_0x207c80('0x18')](_0x4e7199);return _0x4dadce[_0x207c80('0x37')](_0x4e7199)[_0x207c80('0xb')]();};}function respondWithResult(_0x1250bc,_0x3c51db){return _0x3c51db=_0x3c51db||0xc8,function(_0x596605){const _0x377840=a530_0x4d5c;if(_0x596605)return _0x1250bc[_0x377840('0x37')](_0x3c51db)[_0x377840('0x10')](_0x596605);};}function respondWithFilteredResult(_0x2a20e1,_0x5a99e9){return function(_0x27cfa8){const _0x21000e=a530_0x4d5c;if(_0x27cfa8){const _0x522dab=_0x27cfa8[_0x21000e('0x2b')],_0xffebcc=_0x5a99e9[_0x21000e('0x3f')];let _0x37b8be=_0x5a99e9[_0x21000e('0x3f')]+_0x5a99e9['limit'],_0x2c69ea;return _0x37b8be>=_0x522dab?(_0x37b8be=_0x522dab,_0x2c69ea=0xc8):_0x2c69ea=0xce,_0x2a20e1[_0x21000e('0x37')](_0x2c69ea),_0x2a20e1['set'](_0x21000e('0x3'),_0xffebcc+'-'+_0x37b8be+'/'+_0x522dab)[_0x21000e('0x10')](_0x27cfa8);}return null;};}function saveUpdates(_0x5895da){return function(_0x10a1ad){const _0x31c348=a530_0x4d5c;if(_0x10a1ad)return _0x10a1ad[_0x31c348('0x6')](_0x5895da)[_0x31c348('0x15')](function(_0x11af59){return _0x11af59;});return null;};}function removeEntity(_0x151be9){return function(_0x592e73){const _0x5ed1bd=a530_0x4d5c;if(_0x592e73)return _0x592e73[_0x5ed1bd('0x3e')]()[_0x5ed1bd('0x15')](function(){const _0x22164c=_0x5ed1bd,_0x7c04f5=_0x592e73[_0x22164c('0x1e')]({'plain':!![]}),_0x58998e=_0x22164c('0x14');return db[_0x22164c('0x20')]['destroy']({'where':{'type':_0x58998e,'resourceId':_0x7c04f5['id']}})[_0x22164c('0x15')](function(){return _0x592e73;});})[_0x5ed1bd('0x15')](function(){const _0x75be5b=_0x5ed1bd;_0x151be9[_0x75be5b('0x37')](0xcc)[_0x75be5b('0xb')]();});};}function handleEntityNotFound(_0x530d28){return function(_0x45c029){const _0x5cdaeb=a530_0x4d5c;return!_0x45c029&&_0x530d28[_0x5cdaeb('0x18')](0x194),_0x45c029;};}function handleError(_0x3ef944,_0x57208e){return _0x57208e=_0x57208e||0x1f4,function(_0x2343fa){const _0x3ee95b=a530_0x4d5c;logger[_0x3ee95b('0x13')](_0x2343fa[_0x3ee95b('0x31')]),_0x2343fa[_0x3ee95b('0x23')]&&delete _0x2343fa[_0x3ee95b('0x23')],_0x3ef944[_0x3ee95b('0x37')](_0x57208e)[_0x3ee95b('0x27')](_0x2343fa);};}exports['index']=function(_0x325e72,_0x253917){const _0x20d0e2=_0x13454e;let _0x4d2d00={};const _0x321485={},_0x35f923={'count':0x0,'rows':[]},_0x3fd05e=_[_0x20d0e2('0x28')](db[_0x20d0e2('0x2a')][_0x20d0e2('0x1f')],function(_0x3e6363){const _0x9e30e3=_0x20d0e2;return{'name':_0x3e6363[_0x9e30e3('0x1')],'type':_0x3e6363[_0x9e30e3('0x3a')][_0x9e30e3('0x2e')]};});_0x321485[_0x20d0e2('0x1c')]=_[_0x20d0e2('0x28')](_0x3fd05e,_0x20d0e2('0x23')),_0x321485[_0x20d0e2('0x9')]=_[_0x20d0e2('0x1d')](_0x325e72[_0x20d0e2('0x9')]),_0x321485[_0x20d0e2('0x34')]=_[_0x20d0e2('0x8')](_0x321485['model'],_0x321485[_0x20d0e2('0x9')]),_0x4d2d00[_0x20d0e2('0x2c')]=_[_0x20d0e2('0x8')](_0x321485['model'],qs['fields'](_0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0x33')])),_0x4d2d00[_0x20d0e2('0x2c')]=_0x4d2d00[_0x20d0e2('0x2c')][_0x20d0e2('0x30')]?_0x4d2d00['attributes']:_0x321485[_0x20d0e2('0x1c')];typeof _0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0xa')]===_0x20d0e2('0x3c')&&(_0x4d2d00[_0x20d0e2('0x2d')]=qs[_0x20d0e2('0x2d')](_0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0x2d')]),_0x4d2d00[_0x20d0e2('0x3f')]=qs['offset'](_0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0x3f')]));_0x4d2d00[_0x20d0e2('0x35')]=qs['sort'](_0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0x17')]),_0x4d2d00[_0x20d0e2('0x36')]=qs[_0x20d0e2('0x34')](_[_0x20d0e2('0x19')](_0x325e72[_0x20d0e2('0x9')],_0x321485[_0x20d0e2('0x34')]),_0x3fd05e);_0x325e72[_0x20d0e2('0x9')][_0x20d0e2('0x7')]&&(_0x4d2d00[_0x20d0e2('0x36')]=_[_0x20d0e2('0x12')](_0x4d2d00[_0x20d0e2('0x36')],{[Op['or']]:_[_0x20d0e2('0x28')](_0x3fd05e,function(_0x4c6038){const _0x7f36db=_0x20d0e2;if(_0x4c6038[_0x7f36db('0x3a')]!==_0x7f36db('0x3d')){const _0x2c3105={};return _0x2c3105[_0x4c6038[_0x7f36db('0x23')]]={[Op[_0x7f36db('0xd')]]:'%'+_0x325e72[_0x7f36db('0x9')][_0x7f36db('0x7')]+'%'},_0x2c3105;}})}));_0x4d2d00=_[_0x20d0e2('0x12')]({},_0x4d2d00,_0x325e72[_0x20d0e2('0x2f')]);const _0x27180b={'where':_0x4d2d00[_0x20d0e2('0x36')]};return db[_0x20d0e2('0x2a')][_0x20d0e2('0x2b')](_0x27180b)[_0x20d0e2('0x15')](function(_0xe32119){const _0x5bb14d=_0x20d0e2;return _0x35f923['count']=_0xe32119,_0x325e72['query'][_0x5bb14d('0x29')]&&(_0x4d2d00[_0x5bb14d('0x25')]=[{'all':!![]}]),db[_0x5bb14d('0x2a')][_0x5bb14d('0x24')](_0x4d2d00);})[_0x20d0e2('0x15')](function(_0x278bff){return _0x35f923['rows']=_0x278bff,_0x35f923;})[_0x20d0e2('0x15')](respondWithFilteredResult(_0x253917,_0x4d2d00))[_0x20d0e2('0xe')](handleError(_0x253917,null));},exports[_0x13454e('0x5')]=function(_0x1e7722,_0x278f12){const _0x2b8692=_0x13454e;let _0x41ff48={'raw':![],'where':{'id':_0x1e7722['params']['id']}};const _0x2d5ceb={};return _0x2d5ceb['model']=_[_0x2b8692('0x1d')](db[_0x2b8692('0x2a')]['rawAttributes']),_0x2d5ceb[_0x2b8692('0x9')]=_[_0x2b8692('0x1d')](_0x1e7722[_0x2b8692('0x9')]),_0x2d5ceb[_0x2b8692('0x34')]=_['intersection'](_0x2d5ceb[_0x2b8692('0x1c')],_0x2d5ceb[_0x2b8692('0x9')]),_0x41ff48[_0x2b8692('0x2c')]=_[_0x2b8692('0x8')](_0x2d5ceb['model'],qs[_0x2b8692('0x33')](_0x1e7722[_0x2b8692('0x9')][_0x2b8692('0x33')])),_0x41ff48[_0x2b8692('0x2c')]=_0x41ff48[_0x2b8692('0x2c')][_0x2b8692('0x30')]?_0x41ff48[_0x2b8692('0x2c')]:_0x2d5ceb[_0x2b8692('0x1c')],_0x1e7722[_0x2b8692('0x9')][_0x2b8692('0x29')]&&(_0x41ff48[_0x2b8692('0x25')]=[{'all':!![]}]),_0x41ff48=_[_0x2b8692('0x12')]({},_0x41ff48,_0x1e7722[_0x2b8692('0x2f')]),db[_0x2b8692('0x2a')][_0x2b8692('0x32')](_0x41ff48)[_0x2b8692('0x15')](handleEntityNotFound(_0x278f12,null))[_0x2b8692('0x15')](respondWithResult(_0x278f12,null))[_0x2b8692('0xe')](handleError(_0x278f12,null));},exports[_0x13454e('0x0')]=function(_0x2d356a,_0x35c7f9){const _0x32556e=_0x13454e;return db[_0x32556e('0x2a')][_0x32556e('0x0')](_0x2d356a[_0x32556e('0x3b')],{})[_0x32556e('0x15')](function(_0x9e23c2){const _0x573479=_0x32556e,_0x2510be=_0x2d356a[_0x573479('0x16')][_0x573479('0x1e')]({'plain':!![]});if(!_0x2510be)throw new Error(_0x573479('0x4'));if(_0x2510be[_0x573479('0x1a')]===_0x573479('0x16')){const _0x63d591=_0x9e23c2['get']({'plain':!![]}),_0x32fc70='Scheduler';return db['UserProfileSection'][_0x573479('0x32')]({'where':{'name':_0x32fc70,'userProfileId':_0x2510be['userProfileId']},'raw':!![]})[_0x573479('0x15')](function(_0xa855b7){const _0x59da97=_0x573479;return _0xa855b7&&_0xa855b7['autoAssociation']===0x0?db[_0x59da97('0x20')][_0x59da97('0x0')]({'name':_0x63d591['name'],'resourceId':_0x63d591['id'],'type':_0xa855b7[_0x59da97('0x23')],'sectionId':_0xa855b7['id']},{})[_0x59da97('0x15')](function(){return _0x9e23c2;}):_0x9e23c2;})[_0x573479('0xe')](function(_0x47fef6){const _0x42016d=_0x573479;logger['error'](_0x42016d('0x21'),_0x47fef6);throw _0x47fef6;});}return _0x9e23c2;})[_0x32556e('0x15')](respondWithResult(_0x35c7f9,0xc9))[_0x32556e('0xe')](handleError(_0x35c7f9,null));},exports[_0x13454e('0x6')]=function(_0x51f8ae,_0x459e1d){const _0x146f32=_0x13454e;return _0x51f8ae[_0x146f32('0x3b')]['id']&&delete _0x51f8ae['body']['id'],db[_0x146f32('0x2a')][_0x146f32('0x32')]({'where':{'id':_0x51f8ae[_0x146f32('0x1b')]['id']}})['then'](handleEntityNotFound(_0x459e1d,null))['then'](saveUpdates(_0x51f8ae[_0x146f32('0x3b')],null))[_0x146f32('0x15')](respondWithResult(_0x459e1d,null))['catch'](handleError(_0x459e1d,null));},exports['destroy']=function(_0x17eeff,_0x579a69){const _0x2b85dd=_0x13454e;return db[_0x2b85dd('0x2a')][_0x2b85dd('0x32')]({'where':{'id':_0x17eeff[_0x2b85dd('0x1b')]['id']}})[_0x2b85dd('0x15')](handleEntityNotFound(_0x579a69,null))[_0x2b85dd('0x15')](removeEntity(_0x579a69,null))[_0x2b85dd('0xe')](handleError(_0x579a69,null));},exports[_0x13454e('0xf')]=function(_0x2cd895,_0x3d57f4){const _0x21bf1e=_0x13454e,_0x2bde16=require(_0x21bf1e('0x38'));return db[_0x21bf1e('0x2a')][_0x21bf1e('0x32')]({'where':{'id':_0x2cd895[_0x21bf1e('0x1b')]['id']},'raw':!![]})[_0x21bf1e('0x15')](handleEntityNotFound(_0x3d57f4,null))[_0x21bf1e('0x15')](function(){const _0x28e4b5=_0x21bf1e;_0x2bde16['run'](_0x2cd895[_0x28e4b5('0x1b')]['id']);})[_0x21bf1e('0x15')](respondWithStatusCode(_0x3d57f4,null))['catch'](handleError(_0x3d57f4,null));};