Built motion from commit f651e4b0a7312c0adceb5e57d6684a801a3aaf0d. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueueReport / whatsappQueueReport.controller.js
1 const a815_0x1a49=['includeAll','WhatsappQueueReport','../../mysqldb','key','fields','findOne','keys','fieldName','create','destroy','Content-Range','nolimit','model','../../config/logger','length','type','then','order','sequelize','name','index','filters','status','sort','set','update','like','body','offset','catch','send','intersection','findAll','options','error','show','VIRTUAL','sendStatus','params','json','limit','api','rows','end','describe','where','stack','lodash','map','undefined','count','merge','rawAttributes','include','query','attributes'];(function(_0x2bfb8e,_0x1a4983){const _0x31281f=function(_0x132d1f){while(--_0x132d1f){_0x2bfb8e['push'](_0x2bfb8e['shift']());}};_0x31281f(++_0x1a4983);}(a815_0x1a49,0x17e));const a815_0x3128=function(_0x2bfb8e,_0x1a4983){_0x2bfb8e=_0x2bfb8e-0x0;let _0x31281f=a815_0x1a49[_0x2bfb8e];return _0x31281f;};const _0x3e634c=a815_0x3128;'use strict';const _=require(_0x3e634c('0x1')),qs=require('../../components/parsers/qs'),logger=require(_0x3e634c('0x17'))(_0x3e634c('0x33')),db=require(_0x3e634c('0xc'))['db'],{Op}=require(_0x3e634c('0x1c'));function respondWithResult(_0x132d1f,_0x238ab5){return _0x238ab5=_0x238ab5||0xc8,function(_0x1ccd27){const _0x53de93=a815_0x3128;if(_0x1ccd27)return _0x132d1f['status'](_0x238ab5)[_0x53de93('0x31')](_0x1ccd27);};}function respondWithFilteredResult(_0x1569d7,_0x2055c2){return function(_0x2dc91e){const _0x18c469=a815_0x3128;if(_0x2dc91e){const _0x2bfb69=_0x2dc91e[_0x18c469('0x4')],_0x21cb3e=_0x2055c2[_0x18c469('0x26')];let _0x533e04=_0x2055c2[_0x18c469('0x26')]+_0x2055c2['limit'],_0x5cfd1c;return _0x533e04>=_0x2bfb69?(_0x533e04=_0x2bfb69,_0x5cfd1c=0xc8):_0x5cfd1c=0xce,_0x1569d7['status'](_0x5cfd1c),_0x1569d7[_0x18c469('0x22')](_0x18c469('0x14'),_0x21cb3e+'-'+_0x533e04+'/'+_0x2bfb69)[_0x18c469('0x31')](_0x2dc91e);}return null;};}function saveUpdates(_0x1abe4f){return function(_0x3c197a){const _0x2684ff=a815_0x3128;if(_0x3c197a)return _0x3c197a[_0x2684ff('0x23')](_0x1abe4f)[_0x2684ff('0x1a')](function(_0x4839d3){return _0x4839d3;});return null;};}function removeEntity(_0x581382){return function(_0x352585){const _0x43592e=a815_0x3128;if(_0x352585)return _0x352585[_0x43592e('0x13')]()['then'](function(){const _0x44191c=_0x43592e;_0x581382[_0x44191c('0x20')](0xcc)[_0x44191c('0x35')]();});};}function handleEntityNotFound(_0x9b52e7){return function(_0x4ab9c5){const _0x5871d2=a815_0x3128;return!_0x4ab9c5&&_0x9b52e7[_0x5871d2('0x2f')](0x194),_0x4ab9c5;};}function handleError(_0x1e32e2,_0xe11ee4){return _0xe11ee4=_0xe11ee4||0x1f4,function(_0x461efc){const _0x212552=a815_0x3128;logger[_0x212552('0x2c')](_0x461efc[_0x212552('0x0')]),_0x461efc['name']&&delete _0x461efc[_0x212552('0x1d')],_0x1e32e2[_0x212552('0x20')](_0xe11ee4)[_0x212552('0x28')](_0x461efc);};}exports[_0x3e634c('0x1e')]=function(_0x170c49,_0x207d08){const _0x4613c6=_0x3e634c;let _0x106043={};const _0x33e470={},_0xc859a={'count':0x0,'rows':[]},_0x321dbe=_[_0x4613c6('0x2')](db[_0x4613c6('0xb')][_0x4613c6('0x6')],function(_0x3d525c){const _0x357471=_0x4613c6;return{'name':_0x3d525c[_0x357471('0x11')],'type':_0x3d525c[_0x357471('0x19')][_0x357471('0xd')]};});_0x33e470[_0x4613c6('0x16')]=_['map'](_0x321dbe,_0x4613c6('0x1d')),_0x33e470[_0x4613c6('0x8')]=_[_0x4613c6('0x10')](_0x170c49[_0x4613c6('0x8')]),_0x33e470[_0x4613c6('0x1f')]=_['intersection'](_0x33e470['model'],_0x33e470[_0x4613c6('0x8')]),_0x106043[_0x4613c6('0x9')]=_['intersection'](_0x33e470['model'],qs[_0x4613c6('0xe')](_0x170c49[_0x4613c6('0x8')][_0x4613c6('0xe')])),_0x106043[_0x4613c6('0x9')]=_0x106043[_0x4613c6('0x9')]['length']?_0x106043['attributes']:_0x33e470[_0x4613c6('0x16')];typeof _0x170c49['query'][_0x4613c6('0x15')]===_0x4613c6('0x3')&&(_0x106043[_0x4613c6('0x32')]=qs['limit'](_0x170c49['query']['limit']),_0x106043['offset']=qs[_0x4613c6('0x26')](_0x170c49[_0x4613c6('0x8')][_0x4613c6('0x26')]));_0x106043[_0x4613c6('0x1b')]=qs['sort'](_0x170c49[_0x4613c6('0x8')][_0x4613c6('0x21')]),_0x106043[_0x4613c6('0x37')]=qs['filters'](_['pick'](_0x170c49[_0x4613c6('0x8')],_0x33e470[_0x4613c6('0x1f')]),_0x321dbe);_0x170c49[_0x4613c6('0x8')]['filter']&&(_0x106043['where']=_[_0x4613c6('0x5')](_0x106043['where'],{[Op['or']]:_[_0x4613c6('0x2')](_0x321dbe,function(_0x50eaf3){const _0x189f00=_0x4613c6;if(_0x50eaf3[_0x189f00('0x19')]!==_0x189f00('0x2e')){const _0x3e3ece={};return _0x3e3ece[_0x50eaf3[_0x189f00('0x1d')]]={[Op[_0x189f00('0x24')]]:'%'+_0x170c49[_0x189f00('0x8')]['filter']+'%'},_0x3e3ece;}})}));_0x106043=_[_0x4613c6('0x5')]({},_0x106043,_0x170c49[_0x4613c6('0x2b')]);const _0x453f2d={'where':_0x106043[_0x4613c6('0x37')]};return db[_0x4613c6('0xb')][_0x4613c6('0x4')](_0x453f2d)[_0x4613c6('0x1a')](function(_0x1f6378){const _0x959f4f=_0x4613c6;return _0xc859a[_0x959f4f('0x4')]=_0x1f6378,_0x170c49[_0x959f4f('0x8')][_0x959f4f('0xa')]&&(_0x106043[_0x959f4f('0x7')]=[{'all':!![]}]),db[_0x959f4f('0xb')][_0x959f4f('0x2a')](_0x106043);})[_0x4613c6('0x1a')](function(_0x52d332){const _0x2222cc=_0x4613c6;return _0xc859a[_0x2222cc('0x34')]=_0x52d332,_0xc859a;})[_0x4613c6('0x1a')](respondWithFilteredResult(_0x207d08,_0x106043))[_0x4613c6('0x27')](handleError(_0x207d08,null));},exports[_0x3e634c('0x2d')]=function(_0x40945f,_0x2af5ef){const _0x54fd79=_0x3e634c;let _0x5b54b8={'raw':!![],'where':{'id':_0x40945f[_0x54fd79('0x30')]['id']}};const _0x981edb={};return _0x981edb['model']=_['keys'](db['WhatsappQueueReport'][_0x54fd79('0x6')]),_0x981edb['query']=_[_0x54fd79('0x10')](_0x40945f['query']),_0x981edb[_0x54fd79('0x1f')]=_['intersection'](_0x981edb[_0x54fd79('0x16')],_0x981edb[_0x54fd79('0x8')]),_0x5b54b8['attributes']=_[_0x54fd79('0x29')](_0x981edb[_0x54fd79('0x16')],qs['fields'](_0x40945f[_0x54fd79('0x8')][_0x54fd79('0xe')])),_0x5b54b8['attributes']=_0x5b54b8[_0x54fd79('0x9')][_0x54fd79('0x18')]?_0x5b54b8[_0x54fd79('0x9')]:_0x981edb[_0x54fd79('0x16')],_0x40945f[_0x54fd79('0x8')][_0x54fd79('0xa')]&&(_0x5b54b8['include']=[{'all':!![]}]),_0x5b54b8=_['merge']({},_0x5b54b8,_0x40945f[_0x54fd79('0x2b')]),db[_0x54fd79('0xb')][_0x54fd79('0xf')](_0x5b54b8)['then'](handleEntityNotFound(_0x2af5ef,null))['then'](respondWithResult(_0x2af5ef,null))['catch'](handleError(_0x2af5ef,null));},exports[_0x3e634c('0x12')]=function(_0x40e78b,_0x6845ea){const _0x386877=_0x3e634c;return db['WhatsappQueueReport'][_0x386877('0x12')](_0x40e78b[_0x386877('0x25')],{})[_0x386877('0x1a')](respondWithResult(_0x6845ea,0xc9))[_0x386877('0x27')](handleError(_0x6845ea,null));},exports[_0x3e634c('0x23')]=function(_0x48618d,_0x164fc5){const _0x2cd139=_0x3e634c;return _0x48618d[_0x2cd139('0x25')]['id']&&delete _0x48618d['body']['id'],db[_0x2cd139('0xb')]['findOne']({'where':{'id':_0x48618d[_0x2cd139('0x30')]['id']}})[_0x2cd139('0x1a')](handleEntityNotFound(_0x164fc5,null))[_0x2cd139('0x1a')](saveUpdates(_0x48618d['body'],null))['then'](respondWithResult(_0x164fc5,null))[_0x2cd139('0x27')](handleError(_0x164fc5,null));},exports[_0x3e634c('0x13')]=function(_0x38bb6b,_0xf6d9ea){const _0x4ed20c=_0x3e634c;return db[_0x4ed20c('0xb')][_0x4ed20c('0xf')]({'where':{'id':_0x38bb6b[_0x4ed20c('0x30')]['id']}})[_0x4ed20c('0x1a')](handleEntityNotFound(_0xf6d9ea,null))[_0x4ed20c('0x1a')](removeEntity(_0xf6d9ea,null))[_0x4ed20c('0x27')](handleError(_0xf6d9ea,null));},exports[_0x3e634c('0x36')]=function(_0x18f212,_0x39867d){const _0x2302f9=_0x3e634c;return db[_0x2302f9('0xb')][_0x2302f9('0x36')]()[_0x2302f9('0x1a')](respondWithResult(_0x39867d,null))[_0x2302f9('0x27')](handleError(_0x39867d,null));};