818e44ec84cc285b3a1afb6378b0f640e2af7663
[motion-next.git] / server / api / mailSubstatus / mailSubstatus.controller.js
1 const a440_0x4600=['update','options','undefined','sort','destroy','rawAttributes','sendStatus','../../components/parsers/qs','offset','like','sequelize','merge','count','fieldName','rows','catch','filters','body','type','end','findOne','nolimit','json','status','key','intersection','map','attributes','params','model','../../mysqldb','query','lodash','length','filter','then','api','MailSubstatus','set','name','error','limit','../../config/logger','pick','fields','where','create','findAll','keys','describe','stack','includeAll'];(function(_0x68a29f,_0x4600de){const _0x1d4994=function(_0x22ebc8){while(--_0x22ebc8){_0x68a29f['push'](_0x68a29f['shift']());}};_0x1d4994(++_0x4600de);}(a440_0x4600,0xce));const a440_0x1d49=function(_0x68a29f,_0x4600de){_0x68a29f=_0x68a29f-0x0;let _0x1d4994=a440_0x4600[_0x68a29f];return _0x1d4994;};const _0x2c109d=a440_0x1d49;'use strict';const _=require(_0x2c109d('0x22')),qs=require(_0x2c109d('0x9')),logger=require(_0x2c109d('0x2c'))(_0x2c109d('0x26')),db=require(_0x2c109d('0x20'))['db'],{Op}=require(_0x2c109d('0xc'));function respondWithResult(_0x22ebc8,_0x3458c7){return _0x3458c7=_0x3458c7||0xc8,function(_0x22ab33){const _0x446f7c=a440_0x1d49;if(_0x22ab33)return _0x22ebc8[_0x446f7c('0x19')](_0x3458c7)[_0x446f7c('0x18')](_0x22ab33);};}function respondWithFilteredResult(_0x58b99d,_0x2a6b5e){return function(_0x2dfd4e){const _0x27d611=a440_0x1d49;if(_0x2dfd4e){const _0x58624d=_0x2dfd4e[_0x27d611('0xe')],_0x3b481c=_0x2a6b5e[_0x27d611('0xa')];let _0x1c9a94=_0x2a6b5e[_0x27d611('0xa')]+_0x2a6b5e[_0x27d611('0x2b')],_0x4fa491;return _0x1c9a94>=_0x58624d?(_0x1c9a94=_0x58624d,_0x4fa491=0xc8):_0x4fa491=0xce,_0x58b99d[_0x27d611('0x19')](_0x4fa491),_0x58b99d[_0x27d611('0x28')]('Content-Range',_0x3b481c+'-'+_0x1c9a94+'/'+_0x58624d)[_0x27d611('0x18')](_0x2dfd4e);}return null;};}function saveUpdates(_0x1530ab){return function(_0x53ce6f){if(_0x53ce6f)return _0x53ce6f['update'](_0x1530ab)['then'](function(_0xabec61){return _0xabec61;});return null;};}function removeEntity(_0x51e8e0){return function(_0x1b5f88){const _0x1ec230=a440_0x1d49;if(_0x1b5f88)return _0x1b5f88['destroy']()[_0x1ec230('0x25')](function(){const _0x1b03d8=_0x1ec230;_0x51e8e0[_0x1b03d8('0x19')](0xcc)[_0x1b03d8('0x15')]();});};}function handleEntityNotFound(_0x2b41f2){return function(_0x2d67e3){const _0x202b84=a440_0x1d49;return!_0x2d67e3&&_0x2b41f2[_0x202b84('0x8')](0x194),_0x2d67e3;};}function handleError(_0x34b66a,_0x30292f){return _0x30292f=_0x30292f||0x1f4,function(_0x5cedea){const _0x5f4f63=a440_0x1d49;logger[_0x5f4f63('0x2a')](_0x5cedea[_0x5f4f63('0x0')]),_0x5cedea[_0x5f4f63('0x29')]&&delete _0x5cedea[_0x5f4f63('0x29')],_0x34b66a['status'](_0x30292f)['send'](_0x5cedea);};}exports['index']=function(_0x212dd,_0x590891){const _0x5ff21f=_0x2c109d;let _0xa8e367={};const _0x45f07f={},_0x4534df={'count':0x0,'rows':[]},_0x42b72f=_[_0x5ff21f('0x1c')](db[_0x5ff21f('0x27')]['rawAttributes'],function(_0x444044){const _0x5cb455=_0x5ff21f;return{'name':_0x444044[_0x5cb455('0xf')],'type':_0x444044[_0x5cb455('0x14')][_0x5cb455('0x1a')]};});_0x45f07f[_0x5ff21f('0x1f')]=_[_0x5ff21f('0x1c')](_0x42b72f,_0x5ff21f('0x29')),_0x45f07f[_0x5ff21f('0x21')]=_[_0x5ff21f('0x32')](_0x212dd[_0x5ff21f('0x21')]),_0x45f07f[_0x5ff21f('0x12')]=_[_0x5ff21f('0x1b')](_0x45f07f[_0x5ff21f('0x1f')],_0x45f07f[_0x5ff21f('0x21')]),_0xa8e367[_0x5ff21f('0x1d')]=_[_0x5ff21f('0x1b')](_0x45f07f[_0x5ff21f('0x1f')],qs['fields'](_0x212dd[_0x5ff21f('0x21')][_0x5ff21f('0x2e')])),_0xa8e367[_0x5ff21f('0x1d')]=_0xa8e367[_0x5ff21f('0x1d')]['length']?_0xa8e367['attributes']:_0x45f07f[_0x5ff21f('0x1f')];typeof _0x212dd['query'][_0x5ff21f('0x17')]===_0x5ff21f('0x4')&&(_0xa8e367[_0x5ff21f('0x2b')]=qs['limit'](_0x212dd[_0x5ff21f('0x21')][_0x5ff21f('0x2b')]),_0xa8e367['offset']=qs['offset'](_0x212dd['query']['offset']));_0xa8e367['order']=qs[_0x5ff21f('0x5')](_0x212dd[_0x5ff21f('0x21')][_0x5ff21f('0x5')]),_0xa8e367[_0x5ff21f('0x2f')]=qs[_0x5ff21f('0x12')](_[_0x5ff21f('0x2d')](_0x212dd[_0x5ff21f('0x21')],_0x45f07f[_0x5ff21f('0x12')]),_0x42b72f);_0x212dd['query'][_0x5ff21f('0x24')]&&(_0xa8e367[_0x5ff21f('0x2f')]=_[_0x5ff21f('0xd')](_0xa8e367[_0x5ff21f('0x2f')],{[Op['or']]:_[_0x5ff21f('0x1c')](_0x42b72f,function(_0x1a960b){const _0x37d99e=_0x5ff21f;if(_0x1a960b[_0x37d99e('0x14')]!=='VIRTUAL'){const _0x8faf0f={};return _0x8faf0f[_0x1a960b[_0x37d99e('0x29')]]={[Op[_0x37d99e('0xb')]]:'%'+_0x212dd[_0x37d99e('0x21')]['filter']+'%'},_0x8faf0f;}})}));_0xa8e367=_['merge']({},_0xa8e367,_0x212dd['options']);const _0x263820={'where':_0xa8e367[_0x5ff21f('0x2f')]};return db['MailSubstatus'][_0x5ff21f('0xe')](_0x263820)[_0x5ff21f('0x25')](function(_0x1a55f7){const _0xbb02e4=_0x5ff21f;return _0x4534df[_0xbb02e4('0xe')]=_0x1a55f7,_0x212dd[_0xbb02e4('0x21')][_0xbb02e4('0x1')]&&(_0xa8e367['include']=[{'all':!![]}]),db['MailSubstatus'][_0xbb02e4('0x31')](_0xa8e367);})[_0x5ff21f('0x25')](function(_0x568515){const _0x4fb85d=_0x5ff21f;return _0x4534df[_0x4fb85d('0x10')]=_0x568515,_0x4534df;})['then'](respondWithFilteredResult(_0x590891,_0xa8e367))[_0x5ff21f('0x11')](handleError(_0x590891,null));},exports['show']=function(_0x4005db,_0x9a93f4){const _0x509a37=_0x2c109d;let _0x18f919={'raw':!![],'where':{'id':_0x4005db['params']['id']}};const _0x12763b={};return _0x12763b[_0x509a37('0x1f')]=_[_0x509a37('0x32')](db[_0x509a37('0x27')][_0x509a37('0x7')]),_0x12763b[_0x509a37('0x21')]=_[_0x509a37('0x32')](_0x4005db[_0x509a37('0x21')]),_0x12763b[_0x509a37('0x12')]=_[_0x509a37('0x1b')](_0x12763b['model'],_0x12763b[_0x509a37('0x21')]),_0x18f919[_0x509a37('0x1d')]=_[_0x509a37('0x1b')](_0x12763b[_0x509a37('0x1f')],qs[_0x509a37('0x2e')](_0x4005db[_0x509a37('0x21')]['fields'])),_0x18f919[_0x509a37('0x1d')]=_0x18f919['attributes'][_0x509a37('0x23')]?_0x18f919[_0x509a37('0x1d')]:_0x12763b[_0x509a37('0x1f')],_0x4005db['query'][_0x509a37('0x1')]&&(_0x18f919['include']=[{'all':!![]}]),_0x18f919=_[_0x509a37('0xd')]({},_0x18f919,_0x4005db[_0x509a37('0x3')]),db[_0x509a37('0x27')][_0x509a37('0x16')](_0x18f919)[_0x509a37('0x25')](handleEntityNotFound(_0x9a93f4,null))[_0x509a37('0x25')](respondWithResult(_0x9a93f4,null))['catch'](handleError(_0x9a93f4,null));},exports[_0x2c109d('0x30')]=function(_0x17a57e,_0x1ca211){const _0x326c7d=_0x2c109d;return db[_0x326c7d('0x27')]['create'](_0x17a57e[_0x326c7d('0x13')],{})[_0x326c7d('0x25')](respondWithResult(_0x1ca211,0xc9))['catch'](handleError(_0x1ca211,null));},exports[_0x2c109d('0x2')]=function(_0x48b408,_0x59df59){const _0x11d980=_0x2c109d;return _0x48b408[_0x11d980('0x13')]['id']&&delete _0x48b408['body']['id'],db[_0x11d980('0x27')]['findOne']({'where':{'id':_0x48b408['params']['id']}})[_0x11d980('0x25')](handleEntityNotFound(_0x59df59,null))['then'](saveUpdates(_0x48b408['body'],null))[_0x11d980('0x25')](respondWithResult(_0x59df59,null))[_0x11d980('0x11')](handleError(_0x59df59,null));},exports[_0x2c109d('0x6')]=function(_0x3a6daf,_0x215dd9){const _0x3c809c=_0x2c109d;return db[_0x3c809c('0x27')][_0x3c809c('0x16')]({'where':{'id':_0x3a6daf[_0x3c809c('0x1e')]['id']}})[_0x3c809c('0x25')](handleEntityNotFound(_0x215dd9,null))['then'](removeEntity(_0x215dd9,null))[_0x3c809c('0x11')](handleError(_0x215dd9,null));},exports[_0x2c109d('0x33')]=function(_0x2a4f3a,_0xb8830d){const _0x2df926=_0x2c109d;return db[_0x2df926('0x27')][_0x2df926('0x33')]()[_0x2df926('0x25')](respondWithResult(_0xb8830d,null))[_0x2df926('0x11')](handleError(_0xb8830d,null));};