Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueueReport / whatsappQueueReport.controller.js
1 const a815_0x3293=['merge','map','create','model','../../components/parsers/qs','pick','rawAttributes','where','body','end','then','sequelize','show','type','like','sendStatus','options','send','../../config/logger','undefined','index','attributes','fieldName','catch','status','name','WhatsappQueueReport','filter','limit','params','rows','update','query','error','fields','set','lodash','stack','nolimit','Content-Range','findOne','json','api','sort','destroy','intersection','length','key','describe','count','includeAll','filters','keys','VIRTUAL','offset'];(function(_0x49614a,_0x3293db){const _0x24786d=function(_0x5196ff){while(--_0x5196ff){_0x49614a['push'](_0x49614a['shift']());}};_0x24786d(++_0x3293db);}(a815_0x3293,0x12e));const a815_0x2478=function(_0x49614a,_0x3293db){_0x49614a=_0x49614a-0x0;let _0x24786d=a815_0x3293[_0x49614a];return _0x24786d;};const _0x671918=a815_0x2478;'use strict';const _=require(_0x671918('0x9')),qs=require(_0x671918('0x20')),logger=require(_0x671918('0x2e'))(_0x671918('0xf')),db=require('../../mysqldb')['db'],{Op}=require(_0x671918('0x27'));function respondWithResult(_0x5196ff,_0x415cab){return _0x415cab=_0x415cab||0xc8,function(_0x3222ae){const _0x12c30b=a815_0x2478;if(_0x3222ae)return _0x5196ff['status'](_0x415cab)[_0x12c30b('0xe')](_0x3222ae);};}function respondWithFilteredResult(_0x4669c0,_0x544cfd){return function(_0x4fb32c){const _0x36f276=a815_0x2478;if(_0x4fb32c){const _0x4682ee=_0x4fb32c[_0x36f276('0x16')],_0x375cfa=_0x544cfd[_0x36f276('0x1b')];let _0x3bca8a=_0x544cfd['offset']+_0x544cfd[_0x36f276('0x1')],_0x3db9af;return _0x3bca8a>=_0x4682ee?(_0x3bca8a=_0x4682ee,_0x3db9af=0xc8):_0x3db9af=0xce,_0x4669c0['status'](_0x3db9af),_0x4669c0[_0x36f276('0x8')](_0x36f276('0xc'),_0x375cfa+'-'+_0x3bca8a+'/'+_0x4682ee)[_0x36f276('0xe')](_0x4fb32c);}return null;};}function saveUpdates(_0x2b6d49){return function(_0x2f1b1b){const _0xfa063a=a815_0x2478;if(_0x2f1b1b)return _0x2f1b1b['update'](_0x2b6d49)[_0xfa063a('0x26')](function(_0xee9db5){return _0xee9db5;});return null;};}function removeEntity(_0x23bcdc){return function(_0x14ecdb){const _0x1fd373=a815_0x2478;if(_0x14ecdb)return _0x14ecdb[_0x1fd373('0x11')]()['then'](function(){const _0x4c2282=_0x1fd373;_0x23bcdc[_0x4c2282('0x34')](0xcc)[_0x4c2282('0x25')]();});};}function handleEntityNotFound(_0x1f8bce){return function(_0x27e245){const _0x5e70b7=a815_0x2478;return!_0x27e245&&_0x1f8bce[_0x5e70b7('0x2b')](0x194),_0x27e245;};}function handleError(_0x4b0c7b,_0x166233){return _0x166233=_0x166233||0x1f4,function(_0x337a67){const _0x57a377=a815_0x2478;logger[_0x57a377('0x6')](_0x337a67[_0x57a377('0xa')]),_0x337a67['name']&&delete _0x337a67['name'],_0x4b0c7b['status'](_0x166233)[_0x57a377('0x2d')](_0x337a67);};}exports[_0x671918('0x30')]=function(_0x1ea4c3,_0x54eff4){const _0x418874=_0x671918;let _0x19f4f1={};const _0x539275={},_0x3b0c7e={'count':0x0,'rows':[]},_0x3ddbbe=_[_0x418874('0x1d')](db['WhatsappQueueReport']['rawAttributes'],function(_0x16793f){const _0x5d7e71=_0x418874;return{'name':_0x16793f[_0x5d7e71('0x32')],'type':_0x16793f['type'][_0x5d7e71('0x14')]};});_0x539275[_0x418874('0x1f')]=_[_0x418874('0x1d')](_0x3ddbbe,_0x418874('0x35')),_0x539275[_0x418874('0x5')]=_[_0x418874('0x19')](_0x1ea4c3[_0x418874('0x5')]),_0x539275[_0x418874('0x18')]=_['intersection'](_0x539275[_0x418874('0x1f')],_0x539275[_0x418874('0x5')]),_0x19f4f1[_0x418874('0x31')]=_[_0x418874('0x12')](_0x539275[_0x418874('0x1f')],qs[_0x418874('0x7')](_0x1ea4c3[_0x418874('0x5')][_0x418874('0x7')])),_0x19f4f1[_0x418874('0x31')]=_0x19f4f1['attributes'][_0x418874('0x13')]?_0x19f4f1['attributes']:_0x539275[_0x418874('0x1f')];typeof _0x1ea4c3[_0x418874('0x5')][_0x418874('0xb')]===_0x418874('0x2f')&&(_0x19f4f1[_0x418874('0x1')]=qs['limit'](_0x1ea4c3['query']['limit']),_0x19f4f1[_0x418874('0x1b')]=qs[_0x418874('0x1b')](_0x1ea4c3[_0x418874('0x5')][_0x418874('0x1b')]));_0x19f4f1['order']=qs[_0x418874('0x10')](_0x1ea4c3[_0x418874('0x5')]['sort']),_0x19f4f1['where']=qs['filters'](_[_0x418874('0x21')](_0x1ea4c3[_0x418874('0x5')],_0x539275[_0x418874('0x18')]),_0x3ddbbe);_0x1ea4c3[_0x418874('0x5')][_0x418874('0x0')]&&(_0x19f4f1[_0x418874('0x23')]=_['merge'](_0x19f4f1[_0x418874('0x23')],{[Op['or']]:_[_0x418874('0x1d')](_0x3ddbbe,function(_0x249af5){const _0x362dc7=_0x418874;if(_0x249af5[_0x362dc7('0x29')]!==_0x362dc7('0x1a')){const _0xded538={};return _0xded538[_0x249af5[_0x362dc7('0x35')]]={[Op[_0x362dc7('0x2a')]]:'%'+_0x1ea4c3['query'][_0x362dc7('0x0')]+'%'},_0xded538;}})}));_0x19f4f1=_[_0x418874('0x1c')]({},_0x19f4f1,_0x1ea4c3[_0x418874('0x2c')]);const _0x3759a8={'where':_0x19f4f1[_0x418874('0x23')]};return db[_0x418874('0x36')][_0x418874('0x16')](_0x3759a8)[_0x418874('0x26')](function(_0x9c1829){const _0xfc695b=_0x418874;return _0x3b0c7e[_0xfc695b('0x16')]=_0x9c1829,_0x1ea4c3[_0xfc695b('0x5')]['includeAll']&&(_0x19f4f1['include']=[{'all':!![]}]),db[_0xfc695b('0x36')]['findAll'](_0x19f4f1);})['then'](function(_0x13a0c8){const _0x4abac3=_0x418874;return _0x3b0c7e[_0x4abac3('0x3')]=_0x13a0c8,_0x3b0c7e;})[_0x418874('0x26')](respondWithFilteredResult(_0x54eff4,_0x19f4f1))[_0x418874('0x33')](handleError(_0x54eff4,null));},exports[_0x671918('0x28')]=function(_0x138d59,_0x44503e){const _0x1b9d64=_0x671918;let _0x415faf={'raw':!![],'where':{'id':_0x138d59[_0x1b9d64('0x2')]['id']}};const _0x37cb7c={};return _0x37cb7c['model']=_['keys'](db['WhatsappQueueReport'][_0x1b9d64('0x22')]),_0x37cb7c[_0x1b9d64('0x5')]=_[_0x1b9d64('0x19')](_0x138d59['query']),_0x37cb7c[_0x1b9d64('0x18')]=_[_0x1b9d64('0x12')](_0x37cb7c[_0x1b9d64('0x1f')],_0x37cb7c[_0x1b9d64('0x5')]),_0x415faf['attributes']=_[_0x1b9d64('0x12')](_0x37cb7c[_0x1b9d64('0x1f')],qs[_0x1b9d64('0x7')](_0x138d59[_0x1b9d64('0x5')]['fields'])),_0x415faf['attributes']=_0x415faf[_0x1b9d64('0x31')]['length']?_0x415faf[_0x1b9d64('0x31')]:_0x37cb7c['model'],_0x138d59[_0x1b9d64('0x5')][_0x1b9d64('0x17')]&&(_0x415faf['include']=[{'all':!![]}]),_0x415faf=_[_0x1b9d64('0x1c')]({},_0x415faf,_0x138d59[_0x1b9d64('0x2c')]),db[_0x1b9d64('0x36')]['findOne'](_0x415faf)[_0x1b9d64('0x26')](handleEntityNotFound(_0x44503e,null))[_0x1b9d64('0x26')](respondWithResult(_0x44503e,null))[_0x1b9d64('0x33')](handleError(_0x44503e,null));},exports[_0x671918('0x1e')]=function(_0x490961,_0x525bdf){const _0x14f544=_0x671918;return db['WhatsappQueueReport']['create'](_0x490961[_0x14f544('0x24')],{})['then'](respondWithResult(_0x525bdf,0xc9))[_0x14f544('0x33')](handleError(_0x525bdf,null));},exports[_0x671918('0x4')]=function(_0x371ed5,_0x385e28){const _0x404a3f=_0x671918;return _0x371ed5[_0x404a3f('0x24')]['id']&&delete _0x371ed5[_0x404a3f('0x24')]['id'],db[_0x404a3f('0x36')][_0x404a3f('0xd')]({'where':{'id':_0x371ed5[_0x404a3f('0x2')]['id']}})[_0x404a3f('0x26')](handleEntityNotFound(_0x385e28,null))['then'](saveUpdates(_0x371ed5['body'],null))[_0x404a3f('0x26')](respondWithResult(_0x385e28,null))[_0x404a3f('0x33')](handleError(_0x385e28,null));},exports[_0x671918('0x11')]=function(_0xc41ea9,_0x1247f0){const _0x482388=_0x671918;return db['WhatsappQueueReport'][_0x482388('0xd')]({'where':{'id':_0xc41ea9[_0x482388('0x2')]['id']}})[_0x482388('0x26')](handleEntityNotFound(_0x1247f0,null))['then'](removeEntity(_0x1247f0,null))[_0x482388('0x33')](handleError(_0x1247f0,null));},exports[_0x671918('0x15')]=function(_0x5367c0,_0x4eb201){const _0x127f06=_0x671918;return db[_0x127f06('0x36')][_0x127f06('0x15')]()[_0x127f06('0x26')](respondWithResult(_0x4eb201,null))[_0x127f06('0x33')](handleError(_0x4eb201,null));};