3d323ef8b7c2dec07289de987981b32c8e8096f8
[motion-next.git] / server / api / squareMessage / squareMessage.controller.js
1 const a588_0x282f=['sequelize','where','set','rawAttributes','Content-Range','update','pick','end','offset','create','map','options','findOne','key','then','limit','order','error','intersection','destroy','includeAll','length','VIRTUAL','filters','json','fields','filter','../../config/logger','rows','../../mysqldb','like','model','send','findAll','SquareMessage','sort','include','catch','index','body','merge','api','name','params','status','attributes','query','show','keys','type','count','stack'];(function(_0x336269,_0x282f74){const _0x2b15ad=function(_0x36a84c){while(--_0x36a84c){_0x336269['push'](_0x336269['shift']());}};_0x2b15ad(++_0x282f74);}(a588_0x282f,0x133));const a588_0x2b15=function(_0x336269,_0x282f74){_0x336269=_0x336269-0x0;let _0x2b15ad=a588_0x282f[_0x336269];return _0x2b15ad;};const _0x32e49f=a588_0x2b15;'use strict';const _=require('lodash'),qs=require('../../components/parsers/qs'),logger=require(_0x32e49f('0x20'))(_0x32e49f('0x2e')),db=require(_0x32e49f('0x22'))['db'],{Op}=require(_0x32e49f('0x5'));function respondWithResult(_0x36a84c,_0x5972a1){return _0x5972a1=_0x5972a1||0xc8,function(_0x42f781){const _0x5ee0e4=a588_0x2b15;if(_0x42f781)return _0x36a84c[_0x5ee0e4('0x31')](_0x5972a1)['json'](_0x42f781);};}function respondWithFilteredResult(_0x2e53e5,_0x326357){return function(_0x5e86bb){const _0x44ea7d=a588_0x2b15;if(_0x5e86bb){const _0x19aba1=_0x5e86bb[_0x44ea7d('0x3')],_0x388a33=_0x326357[_0x44ea7d('0xd')];let _0x562d28=_0x326357[_0x44ea7d('0xd')]+_0x326357[_0x44ea7d('0x14')],_0x20e98e;return _0x562d28>=_0x19aba1?(_0x562d28=_0x19aba1,_0x20e98e=0xc8):_0x20e98e=0xce,_0x2e53e5[_0x44ea7d('0x31')](_0x20e98e),_0x2e53e5[_0x44ea7d('0x7')](_0x44ea7d('0x9'),_0x388a33+'-'+_0x562d28+'/'+_0x19aba1)[_0x44ea7d('0x1d')](_0x5e86bb);}return null;};}function saveUpdates(_0x3beb3d){return function(_0x3dee2f){const _0x18f313=a588_0x2b15;if(_0x3dee2f)return _0x3dee2f[_0x18f313('0xa')](_0x3beb3d)['then'](function(_0xafa1c8){return _0xafa1c8;});return null;};}function removeEntity(_0x170c1c){return function(_0x29df20){const _0x544145=a588_0x2b15;if(_0x29df20)return _0x29df20[_0x544145('0x18')]()[_0x544145('0x13')](function(){const _0x3f6207=_0x544145;_0x170c1c['status'](0xcc)[_0x3f6207('0xc')]();});};}function handleEntityNotFound(_0x47fb80){return function(_0x310ce3){return!_0x310ce3&&_0x47fb80['sendStatus'](0x194),_0x310ce3;};}function handleError(_0x3b2616,_0x2678eb){return _0x2678eb=_0x2678eb||0x1f4,function(_0xc6fd43){const _0x1c792=a588_0x2b15;logger[_0x1c792('0x16')](_0xc6fd43[_0x1c792('0x4')]),_0xc6fd43[_0x1c792('0x2f')]&&delete _0xc6fd43[_0x1c792('0x2f')],_0x3b2616[_0x1c792('0x31')](_0x2678eb)[_0x1c792('0x25')](_0xc6fd43);};}exports[_0x32e49f('0x2b')]=function(_0xcbbc22,_0x483078){const _0x14ffbc=_0x32e49f;let _0x32d805={};const _0x55113a={},_0x2aec0f={'count':0x0,'rows':[]},_0x1f1d39=_[_0x14ffbc('0xf')](db[_0x14ffbc('0x27')][_0x14ffbc('0x8')],function(_0x261f1d){const _0x717202=_0x14ffbc;return{'name':_0x261f1d['fieldName'],'type':_0x261f1d[_0x717202('0x2')][_0x717202('0x12')]};});_0x55113a[_0x14ffbc('0x24')]=_[_0x14ffbc('0xf')](_0x1f1d39,_0x14ffbc('0x2f')),_0x55113a['query']=_[_0x14ffbc('0x1')](_0xcbbc22[_0x14ffbc('0x33')]),_0x55113a[_0x14ffbc('0x1c')]=_['intersection'](_0x55113a[_0x14ffbc('0x24')],_0x55113a['query']),_0x32d805[_0x14ffbc('0x32')]=_[_0x14ffbc('0x17')](_0x55113a[_0x14ffbc('0x24')],qs[_0x14ffbc('0x1e')](_0xcbbc22['query'][_0x14ffbc('0x1e')])),_0x32d805[_0x14ffbc('0x32')]=_0x32d805['attributes']['length']?_0x32d805[_0x14ffbc('0x32')]:_0x55113a[_0x14ffbc('0x24')];typeof _0xcbbc22['query']['nolimit']==='undefined'&&(_0x32d805['limit']=qs[_0x14ffbc('0x14')](_0xcbbc22['query'][_0x14ffbc('0x14')]),_0x32d805[_0x14ffbc('0xd')]=qs[_0x14ffbc('0xd')](_0xcbbc22[_0x14ffbc('0x33')]['offset']));_0x32d805[_0x14ffbc('0x15')]=qs[_0x14ffbc('0x28')](_0xcbbc22[_0x14ffbc('0x33')][_0x14ffbc('0x28')]),_0x32d805['where']=qs[_0x14ffbc('0x1c')](_[_0x14ffbc('0xb')](_0xcbbc22[_0x14ffbc('0x33')],_0x55113a[_0x14ffbc('0x1c')]),_0x1f1d39);_0xcbbc22['query']['filter']&&(_0x32d805[_0x14ffbc('0x6')]=_[_0x14ffbc('0x2d')](_0x32d805[_0x14ffbc('0x6')],{[Op['or']]:_[_0x14ffbc('0xf')](_0x1f1d39,function(_0x29f683){const _0xae3103=_0x14ffbc;if(_0x29f683[_0xae3103('0x2')]!==_0xae3103('0x1b')){const _0x9162a2={};return _0x9162a2[_0x29f683[_0xae3103('0x2f')]]={[Op[_0xae3103('0x23')]]:'%'+_0xcbbc22['query'][_0xae3103('0x1f')]+'%'},_0x9162a2;}})}));_0x32d805=_['merge']({},_0x32d805,_0xcbbc22[_0x14ffbc('0x10')]);const _0x2458d2={'where':_0x32d805[_0x14ffbc('0x6')]};return db[_0x14ffbc('0x27')]['count'](_0x2458d2)[_0x14ffbc('0x13')](function(_0x23c919){const _0x6f6f0d=_0x14ffbc;return _0x2aec0f[_0x6f6f0d('0x3')]=_0x23c919,_0xcbbc22['query'][_0x6f6f0d('0x19')]&&(_0x32d805['include']=[{'all':!![]}]),db[_0x6f6f0d('0x27')][_0x6f6f0d('0x26')](_0x32d805);})[_0x14ffbc('0x13')](function(_0x4b17e8){const _0x518247=_0x14ffbc;return _0x2aec0f[_0x518247('0x21')]=_0x4b17e8,_0x2aec0f;})[_0x14ffbc('0x13')](respondWithFilteredResult(_0x483078,_0x32d805))['catch'](handleError(_0x483078,null));},exports[_0x32e49f('0x0')]=function(_0x5a8147,_0x46df18){const _0x2b1945=_0x32e49f;let _0x35a53f={'raw':!![],'where':{'id':_0x5a8147['params']['id']}};const _0x309607={};return _0x309607[_0x2b1945('0x24')]=_[_0x2b1945('0x1')](db[_0x2b1945('0x27')][_0x2b1945('0x8')]),_0x309607[_0x2b1945('0x33')]=_[_0x2b1945('0x1')](_0x5a8147['query']),_0x309607[_0x2b1945('0x1c')]=_[_0x2b1945('0x17')](_0x309607[_0x2b1945('0x24')],_0x309607[_0x2b1945('0x33')]),_0x35a53f[_0x2b1945('0x32')]=_[_0x2b1945('0x17')](_0x309607[_0x2b1945('0x24')],qs[_0x2b1945('0x1e')](_0x5a8147[_0x2b1945('0x33')][_0x2b1945('0x1e')])),_0x35a53f['attributes']=_0x35a53f[_0x2b1945('0x32')][_0x2b1945('0x1a')]?_0x35a53f[_0x2b1945('0x32')]:_0x309607[_0x2b1945('0x24')],_0x5a8147['query'][_0x2b1945('0x19')]&&(_0x35a53f[_0x2b1945('0x29')]=[{'all':!![]}]),_0x35a53f=_[_0x2b1945('0x2d')]({},_0x35a53f,_0x5a8147[_0x2b1945('0x10')]),db[_0x2b1945('0x27')]['findOne'](_0x35a53f)[_0x2b1945('0x13')](handleEntityNotFound(_0x46df18,null))[_0x2b1945('0x13')](respondWithResult(_0x46df18,null))[_0x2b1945('0x2a')](handleError(_0x46df18,null));},exports[_0x32e49f('0xe')]=function(_0x5a5ed3,_0x3dd2a6){const _0x40d011=_0x32e49f;return db['SquareMessage']['create'](_0x5a5ed3['body'],{})[_0x40d011('0x13')](respondWithResult(_0x3dd2a6,0xc9))[_0x40d011('0x2a')](handleError(_0x3dd2a6,null));},exports[_0x32e49f('0xa')]=function(_0x4c1557,_0x4fa9d3){const _0x11183c=_0x32e49f;return _0x4c1557[_0x11183c('0x2c')]['id']&&delete _0x4c1557[_0x11183c('0x2c')]['id'],db[_0x11183c('0x27')][_0x11183c('0x11')]({'where':{'id':_0x4c1557[_0x11183c('0x30')]['id']}})[_0x11183c('0x13')](handleEntityNotFound(_0x4fa9d3,null))[_0x11183c('0x13')](saveUpdates(_0x4c1557['body'],null))['then'](respondWithResult(_0x4fa9d3,null))[_0x11183c('0x2a')](handleError(_0x4fa9d3,null));},exports[_0x32e49f('0x18')]=function(_0x761d9,_0x5a9f1f){const _0x4302cf=_0x32e49f;return db['SquareMessage'][_0x4302cf('0x11')]({'where':{'id':_0x761d9['params']['id']}})[_0x4302cf('0x13')](handleEntityNotFound(_0x5a9f1f,null))['then'](removeEntity(_0x5a9f1f,null))[_0x4302cf('0x2a')](handleError(_0x5a9f1f,null));};