Built motion from commit 459747fdfe53bbf13fbede61eeaffea1f1438f86. Version 3.0.0...
[motion-next.git] / server / api / pause / pause.controller.js
1 const a510_0x7745=['end','role','pick','then','findOne','count','fields','keys','send','attributes','like','../../components/parsers/qs','get','../../config/logger','name','fieldName','filter','include','Content-Range','offset','update','sendStatus','map','create','filters','sequelize','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','rawAttributes','limit','Pause','status','UserProfileSection','query','model','user','api','rows','stack','destroy','merge','json','set','undefined','includeAll','options','type','key','lodash','sort','length','params','Pauses','autoAssociation','where','body','intersection','findAll'];(function(_0x4ea69f,_0x77454c){const _0x753ae0=function(_0x1a9ed0){while(--_0x1a9ed0){_0x4ea69f['push'](_0x4ea69f['shift']());}};_0x753ae0(++_0x77454c);}(a510_0x7745,0x190));const a510_0x753a=function(_0x4ea69f,_0x77454c){_0x4ea69f=_0x4ea69f-0x0;let _0x753ae0=a510_0x7745[_0x4ea69f];return _0x753ae0;};const _0x10d0b7=a510_0x753a;'use strict';const _=require(_0x10d0b7('0x36')),qs=require(_0x10d0b7('0x11')),logger=require(_0x10d0b7('0x13'))(_0x10d0b7('0x2a')),db=require('../../mysqldb')['db'],{Op}=require(_0x10d0b7('0x1f'));function respondWithResult(_0x1a9ed0,_0xbd9182){return _0xbd9182=_0xbd9182||0xc8,function(_0x8bd969){const _0x38a10e=a510_0x753a;if(_0x8bd969)return _0x1a9ed0[_0x38a10e('0x25')](_0xbd9182)[_0x38a10e('0x2f')](_0x8bd969);};}function respondWithFilteredResult(_0xf7f7f9,_0x198cfa){return function(_0x5dd942){const _0x14e142=a510_0x753a;if(_0x5dd942){const _0xf6f87f=_0x5dd942[_0x14e142('0xb')],_0x2fde27=_0x198cfa['offset'];let _0x219e70=_0x198cfa[_0x14e142('0x19')]+_0x198cfa[_0x14e142('0x23')],_0x595e10;return _0x219e70>=_0xf6f87f?(_0x219e70=_0xf6f87f,_0x595e10=0xc8):_0x595e10=0xce,_0xf7f7f9[_0x14e142('0x25')](_0x595e10),_0xf7f7f9[_0x14e142('0x30')](_0x14e142('0x18'),_0x2fde27+'-'+_0x219e70+'/'+_0xf6f87f)['json'](_0x5dd942);}return null;};}function saveUpdates(_0x36246c){return function(_0x4237fd){const _0x4957fa=a510_0x753a;if(_0x4237fd)return _0x4237fd[_0x4957fa('0x1a')](_0x36246c)['then'](function(_0x2567bf){return _0x2567bf;});return null;};}function removeEntity(_0x5e16f3){return function(_0xb92408){const _0x4af31c=a510_0x753a;if(_0xb92408)return _0xb92408[_0x4af31c('0x2d')]()[_0x4af31c('0x9')](function(){const _0x4db7e8=_0x4af31c,_0x5ab593=_0xb92408[_0x4db7e8('0x12')]({'plain':!![]}),_0x2a0444=_0x4db7e8('0x0');return db['UserProfileResource'][_0x4db7e8('0x2d')]({'where':{'type':_0x2a0444,'resourceId':_0x5ab593['id']}})[_0x4db7e8('0x9')](function(){return _0xb92408;});})['then'](function(){const _0x4baa16=_0x4af31c;_0x5e16f3[_0x4baa16('0x25')](0xcc)[_0x4baa16('0x6')]();});};}function handleEntityNotFound(_0x27cc5f){return function(_0x31f6e2){const _0x1eac4e=a510_0x753a;return!_0x31f6e2&&_0x27cc5f[_0x1eac4e('0x1b')](0x194),_0x31f6e2;};}function handleError(_0x43e91a,_0xe0ded2){return _0xe0ded2=_0xe0ded2||0x1f4,function(_0x3c81b4){const _0x11f3fe=a510_0x753a;logger['error'](_0x3c81b4[_0x11f3fe('0x2c')]),_0x3c81b4[_0x11f3fe('0x14')]&&delete _0x3c81b4[_0x11f3fe('0x14')],_0x43e91a[_0x11f3fe('0x25')](_0xe0ded2)[_0x11f3fe('0xe')](_0x3c81b4);};}exports['index']=function(_0x59c50b,_0x1000e5){const _0x1c8232=_0x10d0b7;let _0x220b0a={};const _0x5ed089={},_0x41ec33={'count':0x0,'rows':[]},_0x4b1163=_[_0x1c8232('0x1c')](db['Pause'][_0x1c8232('0x22')],function(_0x4ae6d4){const _0x5e9a53=_0x1c8232;return{'name':_0x4ae6d4[_0x5e9a53('0x15')],'type':_0x4ae6d4[_0x5e9a53('0x34')][_0x5e9a53('0x35')]};});_0x5ed089['model']=_[_0x1c8232('0x1c')](_0x4b1163,'name'),_0x5ed089[_0x1c8232('0x27')]=_['keys'](_0x59c50b[_0x1c8232('0x27')]),_0x5ed089[_0x1c8232('0x1e')]=_[_0x1c8232('0x4')](_0x5ed089[_0x1c8232('0x28')],_0x5ed089[_0x1c8232('0x27')]),_0x220b0a[_0x1c8232('0xf')]=_[_0x1c8232('0x4')](_0x5ed089[_0x1c8232('0x28')],qs[_0x1c8232('0xc')](_0x59c50b[_0x1c8232('0x27')][_0x1c8232('0xc')])),_0x220b0a['attributes']=_0x220b0a['attributes'][_0x1c8232('0x38')]?_0x220b0a['attributes']:_0x5ed089[_0x1c8232('0x28')];typeof _0x59c50b[_0x1c8232('0x27')]['nolimit']===_0x1c8232('0x31')&&(_0x220b0a['limit']=qs[_0x1c8232('0x23')](_0x59c50b[_0x1c8232('0x27')][_0x1c8232('0x23')]),_0x220b0a[_0x1c8232('0x19')]=qs[_0x1c8232('0x19')](_0x59c50b[_0x1c8232('0x27')][_0x1c8232('0x19')]));_0x220b0a['order']=qs[_0x1c8232('0x37')](_0x59c50b[_0x1c8232('0x27')][_0x1c8232('0x37')]),_0x220b0a[_0x1c8232('0x2')]=qs[_0x1c8232('0x1e')](_[_0x1c8232('0x8')](_0x59c50b['query'],_0x5ed089[_0x1c8232('0x1e')]),_0x4b1163);_0x59c50b[_0x1c8232('0x27')][_0x1c8232('0x16')]&&(_0x220b0a[_0x1c8232('0x2')]=_[_0x1c8232('0x2e')](_0x220b0a[_0x1c8232('0x2')],{[Op['or']]:_['map'](_0x4b1163,function(_0x465351){const _0x5c04da=_0x1c8232;if(_0x465351[_0x5c04da('0x34')]!=='VIRTUAL'){const _0x9f52eb={};return _0x9f52eb[_0x465351[_0x5c04da('0x14')]]={[Op[_0x5c04da('0x10')]]:'%'+_0x59c50b['query'][_0x5c04da('0x16')]+'%'},_0x9f52eb;}})}));_0x220b0a=_[_0x1c8232('0x2e')]({},_0x220b0a,_0x59c50b[_0x1c8232('0x33')]);const _0x483b74={'where':_0x220b0a[_0x1c8232('0x2')]};return db[_0x1c8232('0x24')][_0x1c8232('0xb')](_0x483b74)[_0x1c8232('0x9')](function(_0x760940){const _0x54a7c2=_0x1c8232;return _0x41ec33[_0x54a7c2('0xb')]=_0x760940,_0x59c50b['query']['includeAll']&&(_0x220b0a['include']=[{'all':!![]}]),db[_0x54a7c2('0x24')][_0x54a7c2('0x5')](_0x220b0a);})[_0x1c8232('0x9')](function(_0x429b52){const _0x53b0c4=_0x1c8232;return _0x41ec33[_0x53b0c4('0x2b')]=_0x429b52,_0x41ec33;})[_0x1c8232('0x9')](respondWithFilteredResult(_0x1000e5,_0x220b0a))['catch'](handleError(_0x1000e5,null));},exports['show']=function(_0xf4a056,_0x518a6f){const _0x29fb6a=_0x10d0b7;let _0x5a9796={'raw':!![],'where':{'id':_0xf4a056[_0x29fb6a('0x39')]['id']}};const _0x5e7f7a={};return _0x5e7f7a[_0x29fb6a('0x28')]=_['keys'](db[_0x29fb6a('0x24')][_0x29fb6a('0x22')]),_0x5e7f7a[_0x29fb6a('0x27')]=_[_0x29fb6a('0xd')](_0xf4a056['query']),_0x5e7f7a['filters']=_[_0x29fb6a('0x4')](_0x5e7f7a[_0x29fb6a('0x28')],_0x5e7f7a[_0x29fb6a('0x27')]),_0x5a9796[_0x29fb6a('0xf')]=_['intersection'](_0x5e7f7a[_0x29fb6a('0x28')],qs[_0x29fb6a('0xc')](_0xf4a056[_0x29fb6a('0x27')][_0x29fb6a('0xc')])),_0x5a9796[_0x29fb6a('0xf')]=_0x5a9796[_0x29fb6a('0xf')]['length']?_0x5a9796['attributes']:_0x5e7f7a[_0x29fb6a('0x28')],_0xf4a056[_0x29fb6a('0x27')][_0x29fb6a('0x32')]&&(_0x5a9796[_0x29fb6a('0x17')]=[{'all':!![]}]),_0x5a9796=_[_0x29fb6a('0x2e')]({},_0x5a9796,_0xf4a056[_0x29fb6a('0x33')]),db[_0x29fb6a('0x24')][_0x29fb6a('0xa')](_0x5a9796)[_0x29fb6a('0x9')](handleEntityNotFound(_0x518a6f,null))['then'](respondWithResult(_0x518a6f,null))[_0x29fb6a('0x21')](handleError(_0x518a6f,null));},exports[_0x10d0b7('0x1d')]=function(_0x245205,_0x51f014){const _0x541d69=_0x10d0b7;return db[_0x541d69('0x24')][_0x541d69('0x1d')](_0x245205['body'],{})[_0x541d69('0x9')](function(_0x3df3c5){const _0x38188c=_0x541d69,_0x3d85df=_0x245205[_0x38188c('0x29')][_0x38188c('0x12')]({'plain':!![]});if(!_0x3d85df)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3d85df[_0x38188c('0x7')]===_0x38188c('0x29')){const _0x92dd38=_0x3df3c5[_0x38188c('0x12')]({'plain':!![]}),_0x4e75a9=_0x38188c('0x0');return db[_0x38188c('0x26')][_0x38188c('0xa')]({'where':{'name':_0x4e75a9,'userProfileId':_0x3d85df['userProfileId']},'raw':!![]})['then'](function(_0x2bdab3){const _0x1e2fd4=_0x38188c;return _0x2bdab3&&_0x2bdab3[_0x1e2fd4('0x1')]===0x0?db['UserProfileResource'][_0x1e2fd4('0x1d')]({'name':_0x92dd38[_0x1e2fd4('0x14')],'resourceId':_0x92dd38['id'],'type':_0x2bdab3[_0x1e2fd4('0x14')],'sectionId':_0x2bdab3['id']},{})['then'](function(){return _0x3df3c5;}):_0x3df3c5;})[_0x38188c('0x21')](function(_0x3029cc){const _0x56db52=_0x38188c;logger['error'](_0x56db52('0x20'),_0x3029cc);throw _0x3029cc;});}return _0x3df3c5;})[_0x541d69('0x9')](respondWithResult(_0x51f014,0xc9))[_0x541d69('0x21')](handleError(_0x51f014,null));},exports['update']=function(_0x1048bb,_0x329ebc){const _0x127559=_0x10d0b7;return _0x1048bb['body']['id']&&delete _0x1048bb[_0x127559('0x3')]['id'],db['Pause']['findOne']({'where':{'id':_0x1048bb[_0x127559('0x39')]['id']}})[_0x127559('0x9')](handleEntityNotFound(_0x329ebc,null))['then'](saveUpdates(_0x1048bb[_0x127559('0x3')],null))['then'](respondWithResult(_0x329ebc,null))[_0x127559('0x21')](handleError(_0x329ebc,null));},exports[_0x10d0b7('0x2d')]=function(_0x3fc956,_0x2930e9){const _0x339f14=_0x10d0b7;return db[_0x339f14('0x24')][_0x339f14('0xa')]({'where':{'id':_0x3fc956['params']['id']}})[_0x339f14('0x9')](handleEntityNotFound(_0x2930e9,null))[_0x339f14('0x9')](removeEntity(_0x2930e9,null))[_0x339f14('0x21')](handleError(_0x2930e9,null));};