57569f83e687eab032e928d90c65f5a5c8ee307f
[motion-next.git] / server / api / whatsappApplication / whatsappApplication.controller.js
1 const a790_0x4fc3=['type','attributes','model','offset','VIRTUAL','query','Content-Range','fields','../../mysqldb','status','sequelize','filter','WhatsappApplication','options','findAll','name','body','json','../../components/parsers/qs','merge','filters','error','length','nolimit','intersection','includeAll','count','map','then','order','where','sort','pick','show','set','limit','catch','findOne','rawAttributes','key','keys','../../config/logger','params','include'];(function(_0x182393,_0x4fc334){const _0x4476d1=function(_0xb16527){while(--_0xb16527){_0x182393['push'](_0x182393['shift']());}};_0x4476d1(++_0x4fc334);}(a790_0x4fc3,0xf5));const a790_0x4476=function(_0x182393,_0x4fc334){_0x182393=_0x182393-0x0;let _0x4476d1=a790_0x4fc3[_0x182393];return _0x4476d1;};const _0x51cbb5=a790_0x4476;'use strict';const _=require('lodash'),qs=require(_0x51cbb5('0x25')),logger=require(_0x51cbb5('0x10'))('api'),db=require(_0x51cbb5('0x1b'))['db'],{Op}=require(_0x51cbb5('0x1d'));function respondWithResult(_0xb16527,_0x5b28fa){return _0x5b28fa=_0x5b28fa||0xc8,function(_0x50a88b){const _0x2adbf4=a790_0x4476;if(_0x50a88b)return _0xb16527[_0x2adbf4('0x1c')](_0x5b28fa)['json'](_0x50a88b);};}function respondWithFilteredResult(_0x413bbe,_0x5f16b3){return function(_0xb32888){const _0x2446cd=a790_0x4476;if(_0xb32888){const _0x1f61b5=_0xb32888[_0x2446cd('0x1')],_0x51ad12=_0x5f16b3[_0x2446cd('0x16')];let _0x15cd02=_0x5f16b3[_0x2446cd('0x16')]+_0x5f16b3[_0x2446cd('0xa')],_0x51b850;return _0x15cd02>=_0x1f61b5?(_0x15cd02=_0x1f61b5,_0x51b850=0xc8):_0x51b850=0xce,_0x413bbe[_0x2446cd('0x1c')](_0x51b850),_0x413bbe[_0x2446cd('0x9')](_0x2446cd('0x19'),_0x51ad12+'-'+_0x15cd02+'/'+_0x1f61b5)[_0x2446cd('0x24')](_0xb32888);}return null;};}function saveUpdates(_0x53c7bd){return function(_0xb5f5ef){const _0x4dbb99=a790_0x4476;if(_0xb5f5ef)return _0xb5f5ef['update'](_0x53c7bd)[_0x4dbb99('0x3')](function(_0x39e5f6){return _0x39e5f6;});return null;};}function removeEntity(_0x16df9f){return function(_0x4aa6b8){const _0x3ff532=a790_0x4476;if(_0x4aa6b8)return _0x4aa6b8['destroy']()[_0x3ff532('0x3')](function(){_0x16df9f['status'](0xcc)['end']();});};}function handleEntityNotFound(_0xd4abbc){return function(_0x11a8ae){return!_0x11a8ae&&_0xd4abbc['sendStatus'](0x194),_0x11a8ae;};}function handleError(_0x3b8cfc,_0x192395){return _0x192395=_0x192395||0x1f4,function(_0x1d591e){const _0x175b8b=a790_0x4476;logger[_0x175b8b('0x28')](_0x1d591e['stack']),_0x1d591e[_0x175b8b('0x22')]&&delete _0x1d591e['name'],_0x3b8cfc['status'](_0x192395)['send'](_0x1d591e);};}exports['index']=function(_0x2d01d5,_0x2c1530){const _0x474618=_0x51cbb5;let _0x3ce2e0={};const _0x22eeba={},_0x13769c={'count':0x0,'rows':[]},_0x48b463=_['map'](db[_0x474618('0x1f')][_0x474618('0xd')],function(_0x147b2b){const _0x5029b3=_0x474618;return{'name':_0x147b2b['fieldName'],'type':_0x147b2b['type'][_0x5029b3('0xe')]};});_0x22eeba[_0x474618('0x15')]=_[_0x474618('0x2')](_0x48b463,_0x474618('0x22')),_0x22eeba[_0x474618('0x18')]=_[_0x474618('0xf')](_0x2d01d5['query']),_0x22eeba[_0x474618('0x27')]=_['intersection'](_0x22eeba[_0x474618('0x15')],_0x22eeba[_0x474618('0x18')]),_0x3ce2e0['attributes']=_[_0x474618('0x2b')](_0x22eeba[_0x474618('0x15')],qs['fields'](_0x2d01d5[_0x474618('0x18')][_0x474618('0x1a')])),_0x3ce2e0['attributes']=_0x3ce2e0[_0x474618('0x14')][_0x474618('0x29')]?_0x3ce2e0[_0x474618('0x14')]:_0x22eeba[_0x474618('0x15')];typeof _0x2d01d5[_0x474618('0x18')][_0x474618('0x2a')]==='undefined'&&(_0x3ce2e0[_0x474618('0xa')]=qs[_0x474618('0xa')](_0x2d01d5[_0x474618('0x18')]['limit']),_0x3ce2e0[_0x474618('0x16')]=qs['offset'](_0x2d01d5['query'][_0x474618('0x16')]));_0x3ce2e0[_0x474618('0x4')]=qs['sort'](_0x2d01d5[_0x474618('0x18')][_0x474618('0x6')]),_0x3ce2e0['where']=qs[_0x474618('0x27')](_[_0x474618('0x7')](_0x2d01d5[_0x474618('0x18')],_0x22eeba[_0x474618('0x27')]),_0x48b463);_0x2d01d5[_0x474618('0x18')][_0x474618('0x1e')]&&(_0x3ce2e0[_0x474618('0x5')]=_[_0x474618('0x26')](_0x3ce2e0['where'],{[Op['or']]:_[_0x474618('0x2')](_0x48b463,function(_0x4d85b0){const _0x1ec3cd=_0x474618;if(_0x4d85b0[_0x1ec3cd('0x13')]!==_0x1ec3cd('0x17')){const _0x1a3846={};return _0x1a3846[_0x4d85b0['name']]={[Op['like']]:'%'+_0x2d01d5['query'][_0x1ec3cd('0x1e')]+'%'},_0x1a3846;}})}));_0x3ce2e0=_['merge']({},_0x3ce2e0,_0x2d01d5[_0x474618('0x20')]);const _0x2b99bf={'where':_0x3ce2e0[_0x474618('0x5')]};return db[_0x474618('0x1f')][_0x474618('0x1')](_0x2b99bf)[_0x474618('0x3')](function(_0x30f784){const _0x283042=_0x474618;return _0x13769c[_0x283042('0x1')]=_0x30f784,_0x2d01d5[_0x283042('0x18')][_0x283042('0x0')]&&(_0x3ce2e0[_0x283042('0x12')]=[{'all':!![]}]),db[_0x283042('0x1f')][_0x283042('0x21')](_0x3ce2e0);})[_0x474618('0x3')](function(_0x4d99e0){return _0x13769c['rows']=_0x4d99e0,_0x13769c;})['then'](respondWithFilteredResult(_0x2c1530,_0x3ce2e0))[_0x474618('0xb')](handleError(_0x2c1530,null));},exports[_0x51cbb5('0x8')]=function(_0x24315c,_0x12e781){const _0x3a4cd6=_0x51cbb5;let _0xa803d={'raw':!![],'where':{'id':_0x24315c[_0x3a4cd6('0x11')]['id']}};const _0x50fb44={};return _0x50fb44[_0x3a4cd6('0x15')]=_[_0x3a4cd6('0xf')](db[_0x3a4cd6('0x1f')]['rawAttributes']),_0x50fb44[_0x3a4cd6('0x18')]=_[_0x3a4cd6('0xf')](_0x24315c[_0x3a4cd6('0x18')]),_0x50fb44[_0x3a4cd6('0x27')]=_['intersection'](_0x50fb44[_0x3a4cd6('0x15')],_0x50fb44[_0x3a4cd6('0x18')]),_0xa803d[_0x3a4cd6('0x14')]=_[_0x3a4cd6('0x2b')](_0x50fb44[_0x3a4cd6('0x15')],qs['fields'](_0x24315c[_0x3a4cd6('0x18')][_0x3a4cd6('0x1a')])),_0xa803d[_0x3a4cd6('0x14')]=_0xa803d['attributes'][_0x3a4cd6('0x29')]?_0xa803d[_0x3a4cd6('0x14')]:_0x50fb44[_0x3a4cd6('0x15')],_0x24315c[_0x3a4cd6('0x18')][_0x3a4cd6('0x0')]&&(_0xa803d[_0x3a4cd6('0x12')]=[{'all':!![]}]),_0xa803d=_[_0x3a4cd6('0x26')]({},_0xa803d,_0x24315c['options']),db[_0x3a4cd6('0x1f')][_0x3a4cd6('0xc')](_0xa803d)[_0x3a4cd6('0x3')](handleEntityNotFound(_0x12e781,null))[_0x3a4cd6('0x3')](respondWithResult(_0x12e781,null))['catch'](handleError(_0x12e781,null));},exports['create']=function(_0xfcc41b,_0x462008){const _0x11ac14=_0x51cbb5;return db['WhatsappApplication']['create'](_0xfcc41b['body'],{})[_0x11ac14('0x3')](respondWithResult(_0x462008,0xc9))['catch'](handleError(_0x462008,null));},exports['update']=function(_0x30ac4b,_0x2d1c2c){const _0x4b385e=_0x51cbb5;return _0x30ac4b[_0x4b385e('0x23')]['id']&&delete _0x30ac4b[_0x4b385e('0x23')]['id'],db['WhatsappApplication'][_0x4b385e('0xc')]({'where':{'id':_0x30ac4b[_0x4b385e('0x11')]['id']}})[_0x4b385e('0x3')](handleEntityNotFound(_0x2d1c2c,null))[_0x4b385e('0x3')](saveUpdates(_0x30ac4b[_0x4b385e('0x23')],null))[_0x4b385e('0x3')](respondWithResult(_0x2d1c2c,null))['catch'](handleError(_0x2d1c2c,null));},exports['destroy']=function(_0x3aabe3,_0x43c2a7){const _0x154389=_0x51cbb5;return db[_0x154389('0x1f')][_0x154389('0xc')]({'where':{'id':_0x3aabe3[_0x154389('0x11')]['id']}})[_0x154389('0x3')](handleEntityNotFound(_0x43c2a7,null))[_0x154389('0x3')](removeEntity(_0x43c2a7,null))['catch'](handleError(_0x43c2a7,null));};