Built motion from commit 129fb4d95212661e48f0db455e75d668addbaddf. Version 3.0.0...
[motion-next.git] / server / api / pause / pause.controller.js
1 const a612_0x206b=['sort','rawAttributes','key','update','includeAll','api','filters','include','findOne','../../config/logger','map','filter','Pauses','index','json','UserProfileSection','length','limit','offset','undefined','VIRTUAL','merge','end','fieldName','intersection','rows','status','body','type','show','get','UserProfileResource','lodash','name','then','options','Unable\x20to\x20retrieve\x20the\x20current\x20user','where','error','Content-Range','user','query','create','attributes','findAll','stack','model','keys','like','catch','Pause','nolimit','../../components/parsers/qs','count','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','send','sequelize','fields','set','params','sendStatus','pick','order','role'];(function(_0x1969a1,_0x10f0eb){const _0x206b84=function(_0x349f31){while(--_0x349f31){_0x1969a1['push'](_0x1969a1['shift']());}};_0x206b84(++_0x10f0eb);}(a612_0x206b,0x138));const a612_0x349f=function(_0x1969a1,_0x10f0eb){_0x1969a1=_0x1969a1-0xf1;let _0x206b84=a612_0x206b[_0x1969a1];return _0x206b84;};const a612_0x53cd9f=a612_0x349f;'use strict';const _=require(a612_0x53cd9f(0x119)),qs=require(a612_0x53cd9f(0x12d)),logger=require(a612_0x53cd9f(0x102))(a612_0x53cd9f(0xfe)),{db}=require('../../mysqldb'),{Op}=require(a612_0x53cd9f(0xf1));function respondWithResult(_0x528d63,_0x5aa66b){return _0x5aa66b=_0x5aa66b||0xc8,function(_0x6758b5){const _0x505abe=a612_0x349f;if(_0x6758b5)return _0x528d63[_0x505abe(0x113)](_0x5aa66b)[_0x505abe(0x107)](_0x6758b5);};}function respondWithFilteredResult(_0x4cda04,_0x1f89c3){return function(_0x27021a){const _0x58ca99=a612_0x349f;if(_0x27021a){const _0x253d69=_0x27021a['count'],_0x334119=_0x1f89c3['offset'];let _0x513a10=_0x1f89c3[_0x58ca99(0x10b)]+_0x1f89c3[_0x58ca99(0x10a)],_0x1a92e0;return _0x513a10>=_0x253d69?(_0x513a10=_0x253d69,_0x1a92e0=0xc8):_0x1a92e0=0xce,_0x4cda04[_0x58ca99(0x113)](_0x1a92e0),_0x4cda04[_0x58ca99(0xf3)](_0x58ca99(0x120),_0x334119+'-'+_0x513a10+'/'+_0x253d69)[_0x58ca99(0x107)](_0x27021a);}return null;};}function saveUpdates(_0x231e38){return function(_0x5b67b2){const _0x5c5d9f=a612_0x349f;if(_0x5b67b2)return _0x5b67b2[_0x5c5d9f(0xfc)](_0x231e38)[_0x5c5d9f(0x11b)](function(_0x12ad0b){return _0x12ad0b;});return null;};}function removeEntity(_0x24fbef){return function(_0x1f8966){const _0x74a319=a612_0x349f;if(_0x1f8966)return _0x1f8966['destroy']()[_0x74a319(0x11b)](function(){const _0x405293=_0x74a319,_0x62dc74=_0x1f8966[_0x405293(0x117)]({'plain':!![]}),_0x1f4709='Pauses';return db[_0x405293(0x118)]['destroy']({'where':{'type':_0x1f4709,'resourceId':_0x62dc74['id']}})[_0x405293(0x11b)](function(){return _0x1f8966;});})[_0x74a319(0x11b)](function(){const _0x406710=_0x74a319;_0x24fbef[_0x406710(0x113)](0xcc)[_0x406710(0x10f)]();});};}function handleEntityNotFound(_0x241100){return function(_0x28f653){const _0x408ba6=a612_0x349f;return!_0x28f653&&_0x241100[_0x408ba6(0xf5)](0x194),_0x28f653;};}function handleError(_0x6188d9,_0x4e2198){return _0x4e2198=_0x4e2198||0x1f4,function(_0x358f07){const _0x3e0fee=a612_0x349f;logger[_0x3e0fee(0x11f)](_0x358f07[_0x3e0fee(0x126)]),_0x358f07[_0x3e0fee(0x11a)]&&delete _0x358f07[_0x3e0fee(0x11a)],_0x6188d9[_0x3e0fee(0x113)](_0x4e2198)[_0x3e0fee(0x130)](_0x358f07);};}exports[a612_0x53cd9f(0x106)]=function(_0x37cc59,_0x35592e){const _0x41fba8=a612_0x53cd9f;let _0x1ba992={};const _0x5153e1={},_0x7fd17d={'count':0x0,'rows':[]},_0x50772c=_[_0x41fba8(0x103)](db[_0x41fba8(0x12b)][_0x41fba8(0xfa)],function(_0x44302f){const _0x34c0bc=_0x41fba8;return{'name':_0x44302f[_0x34c0bc(0x110)],'type':_0x44302f[_0x34c0bc(0x115)][_0x34c0bc(0xfb)]};});_0x5153e1['model']=_[_0x41fba8(0x103)](_0x50772c,_0x41fba8(0x11a)),_0x5153e1[_0x41fba8(0x122)]=_[_0x41fba8(0x128)](_0x37cc59['query']),_0x5153e1[_0x41fba8(0xff)]=_[_0x41fba8(0x111)](_0x5153e1[_0x41fba8(0x127)],_0x5153e1['query']),_0x1ba992[_0x41fba8(0x124)]=_[_0x41fba8(0x111)](_0x5153e1[_0x41fba8(0x127)],qs['fields'](_0x37cc59[_0x41fba8(0x122)][_0x41fba8(0xf2)])),_0x1ba992[_0x41fba8(0x124)]=_0x1ba992[_0x41fba8(0x124)][_0x41fba8(0x109)]?_0x1ba992['attributes']:_0x5153e1[_0x41fba8(0x127)];typeof _0x37cc59[_0x41fba8(0x122)][_0x41fba8(0x12c)]===_0x41fba8(0x10c)&&(_0x1ba992[_0x41fba8(0x10a)]=qs[_0x41fba8(0x10a)](_0x37cc59[_0x41fba8(0x122)][_0x41fba8(0x10a)]),_0x1ba992['offset']=qs[_0x41fba8(0x10b)](_0x37cc59[_0x41fba8(0x122)][_0x41fba8(0x10b)]));_0x1ba992[_0x41fba8(0xf7)]=qs['sort'](_0x37cc59[_0x41fba8(0x122)][_0x41fba8(0xf9)]),_0x1ba992[_0x41fba8(0x11e)]=qs[_0x41fba8(0xff)](_[_0x41fba8(0xf6)](_0x37cc59[_0x41fba8(0x122)],_0x5153e1[_0x41fba8(0xff)]),_0x50772c);_0x37cc59[_0x41fba8(0x122)][_0x41fba8(0x104)]&&(_0x1ba992['where']=_[_0x41fba8(0x10e)](_0x1ba992['where'],{[Op['or']]:_[_0x41fba8(0x103)](_0x50772c,function(_0x1b093a){const _0x24a35c=_0x41fba8;if(_0x1b093a[_0x24a35c(0x115)]!==_0x24a35c(0x10d)){const _0x9258e9={};return _0x9258e9[_0x1b093a[_0x24a35c(0x11a)]]={[Op[_0x24a35c(0x129)]]:'%'+_0x37cc59['query'][_0x24a35c(0x104)]+'%'},_0x9258e9;}})}));_0x1ba992=_[_0x41fba8(0x10e)]({},_0x1ba992,_0x37cc59[_0x41fba8(0x11c)]);const _0x559ee9={'where':_0x1ba992[_0x41fba8(0x11e)]};return db[_0x41fba8(0x12b)][_0x41fba8(0x12e)](_0x559ee9)['then'](function(_0x3bb59f){const _0x380951=_0x41fba8;return _0x7fd17d[_0x380951(0x12e)]=_0x3bb59f,_0x37cc59[_0x380951(0x122)]['includeAll']&&(_0x1ba992[_0x380951(0x100)]=[{'all':!![]}]),db[_0x380951(0x12b)][_0x380951(0x125)](_0x1ba992);})['then'](function(_0x177bf4){const _0x58055c=_0x41fba8;return _0x7fd17d[_0x58055c(0x112)]=_0x177bf4,_0x7fd17d;})['then'](respondWithFilteredResult(_0x35592e,_0x1ba992))['catch'](handleError(_0x35592e,null));},exports[a612_0x53cd9f(0x116)]=function(_0x3c2903,_0x2967a6){const _0x4f6488=a612_0x53cd9f;let _0x44fe7e={'raw':!![],'where':{'id':_0x3c2903[_0x4f6488(0xf4)]['id']}};const _0xd881d7={};return _0xd881d7[_0x4f6488(0x127)]=_[_0x4f6488(0x128)](db[_0x4f6488(0x12b)][_0x4f6488(0xfa)]),_0xd881d7[_0x4f6488(0x122)]=_[_0x4f6488(0x128)](_0x3c2903[_0x4f6488(0x122)]),_0xd881d7[_0x4f6488(0xff)]=_[_0x4f6488(0x111)](_0xd881d7[_0x4f6488(0x127)],_0xd881d7[_0x4f6488(0x122)]),_0x44fe7e[_0x4f6488(0x124)]=_[_0x4f6488(0x111)](_0xd881d7[_0x4f6488(0x127)],qs['fields'](_0x3c2903[_0x4f6488(0x122)][_0x4f6488(0xf2)])),_0x44fe7e[_0x4f6488(0x124)]=_0x44fe7e[_0x4f6488(0x124)]['length']?_0x44fe7e['attributes']:_0xd881d7[_0x4f6488(0x127)],_0x3c2903[_0x4f6488(0x122)][_0x4f6488(0xfd)]&&(_0x44fe7e[_0x4f6488(0x100)]=[{'all':!![]}]),_0x44fe7e=_[_0x4f6488(0x10e)]({},_0x44fe7e,_0x3c2903['options']),db[_0x4f6488(0x12b)][_0x4f6488(0x101)](_0x44fe7e)[_0x4f6488(0x11b)](handleEntityNotFound(_0x2967a6,null))[_0x4f6488(0x11b)](respondWithResult(_0x2967a6,null))[_0x4f6488(0x12a)](handleError(_0x2967a6,null));},exports[a612_0x53cd9f(0x123)]=function(_0x5e640e,_0x516208){const _0x474aea=a612_0x53cd9f;return db[_0x474aea(0x12b)][_0x474aea(0x123)](_0x5e640e[_0x474aea(0x114)],{})[_0x474aea(0x11b)](function(_0x2cd6af){const _0x50ffbb=_0x474aea,_0x18bb34=_0x5e640e[_0x50ffbb(0x121)][_0x50ffbb(0x117)]({'plain':!![]});if(!_0x18bb34)throw new Error(_0x50ffbb(0x11d));if(_0x18bb34[_0x50ffbb(0xf8)]==='user'){const _0x4d39af=_0x2cd6af[_0x50ffbb(0x117)]({'plain':!![]}),_0x32ef0c=_0x50ffbb(0x105);return db[_0x50ffbb(0x108)]['findOne']({'where':{'name':_0x32ef0c,'userProfileId':_0x18bb34['userProfileId']},'raw':!![]})[_0x50ffbb(0x11b)](function(_0x519ccd){const _0x2e32f4=_0x50ffbb;return _0x519ccd&&_0x519ccd['autoAssociation']===0x0?db[_0x2e32f4(0x118)][_0x2e32f4(0x123)]({'name':_0x4d39af[_0x2e32f4(0x11a)],'resourceId':_0x4d39af['id'],'type':_0x519ccd[_0x2e32f4(0x11a)],'sectionId':_0x519ccd['id']},{})['then'](function(){return _0x2cd6af;}):_0x2cd6af;})[_0x50ffbb(0x12a)](function(_0x46b5b3){const _0x5a06ea=_0x50ffbb;logger[_0x5a06ea(0x11f)](_0x5a06ea(0x12f),_0x46b5b3);throw _0x46b5b3;});}return _0x2cd6af;})[_0x474aea(0x11b)](respondWithResult(_0x516208,0xc9))[_0x474aea(0x12a)](handleError(_0x516208,null));},exports[a612_0x53cd9f(0xfc)]=function(_0x2d6aef,_0x442375){const _0x4bb0f7=a612_0x53cd9f;return _0x2d6aef[_0x4bb0f7(0x114)]['id']&&delete _0x2d6aef['body']['id'],db[_0x4bb0f7(0x12b)][_0x4bb0f7(0x101)]({'where':{'id':_0x2d6aef['params']['id']}})[_0x4bb0f7(0x11b)](handleEntityNotFound(_0x442375,null))['then'](saveUpdates(_0x2d6aef['body'],null))[_0x4bb0f7(0x11b)](respondWithResult(_0x442375,null))[_0x4bb0f7(0x12a)](handleError(_0x442375,null));},exports['destroy']=function(_0x253fa8,_0x59a111){const _0x3040d1=a612_0x53cd9f;return db['Pause'][_0x3040d1(0x101)]({'where':{'id':_0x253fa8[_0x3040d1(0xf4)]['id']}})[_0x3040d1(0x11b)](handleEntityNotFound(_0x59a111,null))[_0x3040d1(0x11b)](removeEntity(_0x59a111,null))[_0x3040d1(0x12a)](handleError(_0x59a111,null));};