Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / whatsappApplication / whatsappApplication.controller.js
index f095f8b..fe3efc4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x13ed=['rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','options','count','includeAll','include','WhatsappApplication','findAll','rows','catch','show','params','keys','merge','find','create','body','destroy','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','then','error','stack','name','index','map'];(function(_0x76c797,_0x6e6570){var _0x39a216=function(_0x51b64c){while(--_0x51b64c){_0x76c797['push'](_0x76c797['shift']());}};_0x39a216(++_0x6e6570);}(_0x13ed,0xb3));var _0xd13e=function(_0x34d275,_0x5d84ee){_0x34d275=_0x34d275-0x0;var _0x1379cc=_0x13ed[_0x34d275];return _0x1379cc;};'use strict';var pdf=require(_0xd13e('0x0'));var emlformat=require(_0xd13e('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xd13e('0x2'));var jsonpatch=require(_0xd13e('0x3'));var rp=require(_0xd13e('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xd13e('0x5'));var util=require(_0xd13e('0x6'));var path=require(_0xd13e('0x7'));var sox=require(_0xd13e('0x8'));var csv=require(_0xd13e('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xd13e('0xa'));var squel=require(_0xd13e('0xb'));var crypto=require('crypto');var jsforce=require(_0xd13e('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xd13e('0x9'));var querystring=require(_0xd13e('0xd'));var Papa=require(_0xd13e('0xe'));var Redis=require(_0xd13e('0xf'));var authService=require(_0xd13e('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xd13e('0x11'));var hardwareService=require(_0xd13e('0x12'));var logger=require(_0xd13e('0x13'))(_0xd13e('0x14'));var utils=require(_0xd13e('0x15'));var config=require(_0xd13e('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x36b7b6,_0x5cffbf){_0x5cffbf=_0x5cffbf||0xcc;return function(_0x2a5f7e){if(_0x2a5f7e){return _0x36b7b6[_0xd13e('0x17')](_0x5cffbf);}return _0x36b7b6[_0xd13e('0x18')](_0x5cffbf)[_0xd13e('0x19')]();};}function respondWithResult(_0x7ffb18,_0x28a23a){_0x28a23a=_0x28a23a||0xc8;return function(_0xe3ece4){if(_0xe3ece4){return _0x7ffb18[_0xd13e('0x18')](_0x28a23a)[_0xd13e('0x1a')](_0xe3ece4);}};}function respondWithFilteredResult(_0x20a0a5,_0xe8e080){return function(_0x5662b2){if(_0x5662b2){var _0x219700=_0x5662b2['count'],_0x5b7ec5=_0xe8e080[_0xd13e('0x1b')],_0x141b1e=_0xe8e080[_0xd13e('0x1b')]+_0xe8e080[_0xd13e('0x1c')],_0x4b3ca5;if(_0x141b1e>=_0x219700){_0x141b1e=_0x219700;_0x4b3ca5=0xc8;}else{_0x4b3ca5=0xce;}_0x20a0a5[_0xd13e('0x18')](_0x4b3ca5);return _0x20a0a5[_0xd13e('0x1d')](_0xd13e('0x1e'),_0x5b7ec5+'-'+_0x141b1e+'/'+_0x219700)['json'](_0x5662b2);}return null;};}function patchUpdates(_0x387e95){return function(_0x505541){try{jsonpatch[_0xd13e('0x1f')](_0x505541,_0x387e95,!![]);}catch(_0x113377){return BPromise[_0xd13e('0x20')](_0x113377);}return _0x505541[_0xd13e('0x21')]();};}function saveUpdates(_0x14561b,_0x577e8f){return function(_0x3b42c3){if(_0x3b42c3){return _0x3b42c3['update'](_0x14561b)[_0xd13e('0x22')](function(_0x3decf6){return _0x3decf6;});}return null;};}function removeEntity(_0x530c63,_0x52f738){return function(_0x4e35af){if(_0x4e35af){return _0x4e35af['destroy']()[_0xd13e('0x22')](function(){_0x530c63[_0xd13e('0x18')](0xcc)[_0xd13e('0x19')]();});}};}function handleEntityNotFound(_0x43eb8b,_0x44d2de){return function(_0x2cc1a3){if(!_0x2cc1a3){_0x43eb8b[_0xd13e('0x17')](0x194);}return _0x2cc1a3;};}function handleError(_0x485c97,_0xc54f91){_0xc54f91=_0xc54f91||0x1f4;return function(_0x382fcb){logger[_0xd13e('0x23')](_0x382fcb[_0xd13e('0x24')]);if(_0x382fcb[_0xd13e('0x25')]){delete _0x382fcb[_0xd13e('0x25')];}_0x485c97[_0xd13e('0x18')](_0xc54f91)['send'](_0x382fcb);};}exports[_0xd13e('0x26')]=function(_0x1953a8,_0x3c542c){var _0x37577f={},_0x155501={},_0x466a28={'count':0x0,'rows':[]};var _0x3f43cb=_[_0xd13e('0x27')](db['WhatsappApplication'][_0xd13e('0x28')],function(_0x3330c1){return{'name':_0x3330c1[_0xd13e('0x29')],'type':_0x3330c1[_0xd13e('0x2a')][_0xd13e('0x2b')]};});_0x155501[_0xd13e('0x2c')]=_[_0xd13e('0x27')](_0x3f43cb,_0xd13e('0x25'));_0x155501['query']=_['keys'](_0x1953a8[_0xd13e('0x2d')]);_0x155501[_0xd13e('0x2e')]=_[_0xd13e('0x2f')](_0x155501[_0xd13e('0x2c')],_0x155501[_0xd13e('0x2d')]);_0x37577f[_0xd13e('0x30')]=_[_0xd13e('0x2f')](_0x155501[_0xd13e('0x2c')],qs[_0xd13e('0x31')](_0x1953a8[_0xd13e('0x2d')][_0xd13e('0x31')]));_0x37577f[_0xd13e('0x30')]=_0x37577f[_0xd13e('0x30')][_0xd13e('0x32')]?_0x37577f[_0xd13e('0x30')]:_0x155501['model'];if(!_0x1953a8[_0xd13e('0x2d')]['hasOwnProperty'](_0xd13e('0x33'))){_0x37577f['limit']=qs[_0xd13e('0x1c')](_0x1953a8['query'][_0xd13e('0x1c')]);_0x37577f['offset']=qs[_0xd13e('0x1b')](_0x1953a8[_0xd13e('0x2d')][_0xd13e('0x1b')]);}_0x37577f[_0xd13e('0x34')]=qs[_0xd13e('0x35')](_0x1953a8['query'][_0xd13e('0x35')]);_0x37577f[_0xd13e('0x36')]=qs[_0xd13e('0x2e')](_['pick'](_0x1953a8['query'],_0x155501[_0xd13e('0x2e')]),_0x3f43cb);if(_0x1953a8['query'][_0xd13e('0x37')]){_0x37577f[_0xd13e('0x36')]=_['merge'](_0x37577f[_0xd13e('0x36')],{'$or':_[_0xd13e('0x27')](_0x3f43cb,function(_0x2dfe0b){if(_0x2dfe0b[_0xd13e('0x2a')]!==_0xd13e('0x38')){var _0x28a0ec={};_0x28a0ec[_0x2dfe0b[_0xd13e('0x25')]]={'$like':'%'+_0x1953a8[_0xd13e('0x2d')][_0xd13e('0x37')]+'%'};return _0x28a0ec;}})});}_0x37577f=_['merge']({},_0x37577f,_0x1953a8[_0xd13e('0x39')]);var _0x359f58={'where':_0x37577f['where']};return db['WhatsappApplication'][_0xd13e('0x3a')](_0x359f58)[_0xd13e('0x22')](function(_0x17bca1){_0x466a28[_0xd13e('0x3a')]=_0x17bca1;if(_0x1953a8[_0xd13e('0x2d')][_0xd13e('0x3b')]){_0x37577f[_0xd13e('0x3c')]=[{'all':!![]}];}return db[_0xd13e('0x3d')][_0xd13e('0x3e')](_0x37577f);})['then'](function(_0x52e814){_0x466a28[_0xd13e('0x3f')]=_0x52e814;return _0x466a28;})['then'](respondWithFilteredResult(_0x3c542c,_0x37577f))[_0xd13e('0x40')](handleError(_0x3c542c,null));};exports[_0xd13e('0x41')]=function(_0x232862,_0x4bfded){var _0x2aa993={'raw':!![],'where':{'id':_0x232862[_0xd13e('0x42')]['id']}},_0x372d2a={};_0x372d2a[_0xd13e('0x2c')]=_[_0xd13e('0x43')](db[_0xd13e('0x3d')][_0xd13e('0x28')]);_0x372d2a[_0xd13e('0x2d')]=_['keys'](_0x232862[_0xd13e('0x2d')]);_0x372d2a[_0xd13e('0x2e')]=_[_0xd13e('0x2f')](_0x372d2a['model'],_0x372d2a[_0xd13e('0x2d')]);_0x2aa993[_0xd13e('0x30')]=_[_0xd13e('0x2f')](_0x372d2a['model'],qs[_0xd13e('0x31')](_0x232862[_0xd13e('0x2d')]['fields']));_0x2aa993['attributes']=_0x2aa993['attributes']['length']?_0x2aa993['attributes']:_0x372d2a[_0xd13e('0x2c')];if(_0x232862[_0xd13e('0x2d')][_0xd13e('0x3b')]){_0x2aa993['include']=[{'all':!![]}];}_0x2aa993=_[_0xd13e('0x44')]({},_0x2aa993,_0x232862[_0xd13e('0x39')]);return db['WhatsappApplication'][_0xd13e('0x45')](_0x2aa993)['then'](handleEntityNotFound(_0x4bfded,null))[_0xd13e('0x22')](respondWithResult(_0x4bfded,null))[_0xd13e('0x40')](handleError(_0x4bfded,null));};exports[_0xd13e('0x46')]=function(_0xb9e47e,_0x488707){return db[_0xd13e('0x3d')]['create'](_0xb9e47e[_0xd13e('0x47')],{})['then'](respondWithResult(_0x488707,0xc9))[_0xd13e('0x40')](handleError(_0x488707,null));};exports['update']=function(_0x223d19,_0x417e42){if(_0x223d19[_0xd13e('0x47')]['id']){delete _0x223d19[_0xd13e('0x47')]['id'];}return db['WhatsappApplication'][_0xd13e('0x45')]({'where':{'id':_0x223d19[_0xd13e('0x42')]['id']}})[_0xd13e('0x22')](handleEntityNotFound(_0x417e42,null))[_0xd13e('0x22')](saveUpdates(_0x223d19[_0xd13e('0x47')],null))[_0xd13e('0x22')](respondWithResult(_0x417e42,null))[_0xd13e('0x40')](handleError(_0x417e42,null));};exports[_0xd13e('0x48')]=function(_0x5c065d,_0x1fa0fa){return db[_0xd13e('0x3d')][_0xd13e('0x45')]({'where':{'id':_0x5c065d[_0xd13e('0x42')]['id']}})[_0xd13e('0x22')](handleEntityNotFound(_0x1fa0fa,null))['then'](removeEntity(_0x1fa0fa,null))[_0xd13e('0x40')](handleError(_0x1fa0fa,null));};
\ No newline at end of file
+var _0xa329=['merge','options','then','include','rows','catch','show','params','rawAttributes','includeAll','find','create','body','destroy','eml-format','rimraf','fast-json-patch','moment','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus','status','end','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','stack','name','send','index','map','WhatsappApplication','type','key','model','keys','query','filters','intersection','fields','attributes','sort','where','pick','VIRTUAL','filter'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xa329,0x162));var _0x9a32=function(_0x561915,_0x241e58){_0x561915=_0x561915-0x0;var _0xb86f7=_0xa329[_0x561915];return _0xb86f7;};'use strict';var emlformat=require(_0x9a32('0x0'));var rimraf=require(_0x9a32('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x9a32('0x2'));var rp=require('request-promise');var moment=require(_0x9a32('0x3'));var BPromise=require(_0x9a32('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x9a32('0x5'));var sox=require(_0x9a32('0x6'));var csv=require(_0x9a32('0x7'));var ejs=require(_0x9a32('0x8'));var fs=require('fs');var fs_extra=require(_0x9a32('0x9'));var _=require(_0x9a32('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x9a32('0xb'));var toCsv=require(_0x9a32('0x7'));var querystring=require('querystring');var Papa=require(_0x9a32('0xc'));var Redis=require(_0x9a32('0xd'));var authService=require(_0x9a32('0xe'));var qs=require(_0x9a32('0xf'));var as=require(_0x9a32('0x10'));var hardwareService=require(_0x9a32('0x11'));var logger=require('../../config/logger')(_0x9a32('0x12'));var utils=require(_0x9a32('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x9a32('0x14'))['db'];function respondWithStatusCode(_0x3eb0f1,_0x58184a){_0x58184a=_0x58184a||0xcc;return function(_0x48ae67){if(_0x48ae67){return _0x3eb0f1[_0x9a32('0x15')](_0x58184a);}return _0x3eb0f1[_0x9a32('0x16')](_0x58184a)[_0x9a32('0x17')]();};}function respondWithResult(_0x897c93,_0x52512b){_0x52512b=_0x52512b||0xc8;return function(_0x224747){if(_0x224747){return _0x897c93[_0x9a32('0x16')](_0x52512b)['json'](_0x224747);}};}function respondWithFilteredResult(_0x1f8314,_0x96a800){return function(_0x301fab){if(_0x301fab){var _0x448fd6=typeof _0x96a800[_0x9a32('0x18')]===_0x9a32('0x19')&&typeof _0x96a800['limit']===_0x9a32('0x19');var _0x31bd3e=_0x301fab[_0x9a32('0x1a')];var _0x4cfd70=_0x448fd6?0x0:_0x96a800[_0x9a32('0x18')];var _0x1448da=_0x448fd6?_0x301fab['count']:_0x96a800['offset']+_0x96a800[_0x9a32('0x1b')];var _0x56df79;if(_0x1448da>=_0x31bd3e){_0x1448da=_0x31bd3e;_0x56df79=0xc8;}else{_0x56df79=0xce;}_0x1f8314[_0x9a32('0x16')](_0x56df79);return _0x1f8314[_0x9a32('0x1c')](_0x9a32('0x1d'),_0x4cfd70+'-'+_0x1448da+'/'+_0x31bd3e)['json'](_0x301fab);}return null;};}function patchUpdates(_0x23abc6){return function(_0xd3f35f){try{jsonpatch[_0x9a32('0x1e')](_0xd3f35f,_0x23abc6,!![]);}catch(_0x4ca971){return BPromise[_0x9a32('0x1f')](_0x4ca971);}return _0xd3f35f[_0x9a32('0x20')]();};}function saveUpdates(_0x172cf0,_0x781c9){return function(_0x3b3e66){if(_0x3b3e66){return _0x3b3e66[_0x9a32('0x21')](_0x172cf0)['then'](function(_0x4e6e68){return _0x4e6e68;});}return null;};}function removeEntity(_0x44b3b4,_0x2cb1ff){return function(_0x109144){if(_0x109144){return _0x109144['destroy']()['then'](function(){_0x44b3b4[_0x9a32('0x16')](0xcc)[_0x9a32('0x17')]();});}};}function handleEntityNotFound(_0x301dac,_0x51889a){return function(_0x49531d){if(!_0x49531d){_0x301dac['sendStatus'](0x194);}return _0x49531d;};}function handleError(_0x3515bc,_0x5ae8b1){_0x5ae8b1=_0x5ae8b1||0x1f4;return function(_0x527159){logger['error'](_0x527159[_0x9a32('0x22')]);if(_0x527159[_0x9a32('0x23')]){delete _0x527159[_0x9a32('0x23')];}_0x3515bc[_0x9a32('0x16')](_0x5ae8b1)[_0x9a32('0x24')](_0x527159);};}exports[_0x9a32('0x25')]=function(_0x13787b,_0x15b394){var _0x41f755={},_0x35c1be={},_0x1a9353={'count':0x0,'rows':[]};var _0x50a7a9=_[_0x9a32('0x26')](db[_0x9a32('0x27')]['rawAttributes'],function(_0x3e9e85){return{'name':_0x3e9e85['fieldName'],'type':_0x3e9e85[_0x9a32('0x28')][_0x9a32('0x29')]};});_0x35c1be[_0x9a32('0x2a')]=_[_0x9a32('0x26')](_0x50a7a9,_0x9a32('0x23'));_0x35c1be['query']=_[_0x9a32('0x2b')](_0x13787b[_0x9a32('0x2c')]);_0x35c1be[_0x9a32('0x2d')]=_[_0x9a32('0x2e')](_0x35c1be[_0x9a32('0x2a')],_0x35c1be[_0x9a32('0x2c')]);_0x41f755['attributes']=_[_0x9a32('0x2e')](_0x35c1be[_0x9a32('0x2a')],qs[_0x9a32('0x2f')](_0x13787b[_0x9a32('0x2c')][_0x9a32('0x2f')]));_0x41f755['attributes']=_0x41f755[_0x9a32('0x30')]['length']?_0x41f755[_0x9a32('0x30')]:_0x35c1be['model'];if(!_0x13787b['query']['hasOwnProperty']('nolimit')){_0x41f755[_0x9a32('0x1b')]=qs[_0x9a32('0x1b')](_0x13787b['query'][_0x9a32('0x1b')]);_0x41f755[_0x9a32('0x18')]=qs[_0x9a32('0x18')](_0x13787b[_0x9a32('0x2c')][_0x9a32('0x18')]);}_0x41f755['order']=qs[_0x9a32('0x31')](_0x13787b[_0x9a32('0x2c')][_0x9a32('0x31')]);_0x41f755[_0x9a32('0x32')]=qs[_0x9a32('0x2d')](_[_0x9a32('0x33')](_0x13787b[_0x9a32('0x2c')],_0x35c1be[_0x9a32('0x2d')]),_0x50a7a9);if(_0x13787b[_0x9a32('0x2c')]['filter']){_0x41f755[_0x9a32('0x32')]=_['merge'](_0x41f755[_0x9a32('0x32')],{'$or':_[_0x9a32('0x26')](_0x50a7a9,function(_0x680a07){if(_0x680a07[_0x9a32('0x28')]!==_0x9a32('0x34')){var _0xa5fd1e={};_0xa5fd1e[_0x680a07[_0x9a32('0x23')]]={'$like':'%'+_0x13787b[_0x9a32('0x2c')][_0x9a32('0x35')]+'%'};return _0xa5fd1e;}})});}_0x41f755=_[_0x9a32('0x36')]({},_0x41f755,_0x13787b[_0x9a32('0x37')]);var _0x3122cb={'where':_0x41f755['where']};return db[_0x9a32('0x27')]['count'](_0x3122cb)[_0x9a32('0x38')](function(_0x328d3d){_0x1a9353['count']=_0x328d3d;if(_0x13787b['query']['includeAll']){_0x41f755[_0x9a32('0x39')]=[{'all':!![]}];}return db[_0x9a32('0x27')]['findAll'](_0x41f755);})[_0x9a32('0x38')](function(_0x551215){_0x1a9353[_0x9a32('0x3a')]=_0x551215;return _0x1a9353;})[_0x9a32('0x38')](respondWithFilteredResult(_0x15b394,_0x41f755))[_0x9a32('0x3b')](handleError(_0x15b394,null));};exports[_0x9a32('0x3c')]=function(_0x24e598,_0x1f4324){var _0x48c559={'raw':!![],'where':{'id':_0x24e598[_0x9a32('0x3d')]['id']}},_0x50a03d={};_0x50a03d[_0x9a32('0x2a')]=_[_0x9a32('0x2b')](db['WhatsappApplication'][_0x9a32('0x3e')]);_0x50a03d['query']=_[_0x9a32('0x2b')](_0x24e598[_0x9a32('0x2c')]);_0x50a03d[_0x9a32('0x2d')]=_['intersection'](_0x50a03d[_0x9a32('0x2a')],_0x50a03d[_0x9a32('0x2c')]);_0x48c559[_0x9a32('0x30')]=_[_0x9a32('0x2e')](_0x50a03d[_0x9a32('0x2a')],qs[_0x9a32('0x2f')](_0x24e598[_0x9a32('0x2c')][_0x9a32('0x2f')]));_0x48c559['attributes']=_0x48c559[_0x9a32('0x30')]['length']?_0x48c559[_0x9a32('0x30')]:_0x50a03d[_0x9a32('0x2a')];if(_0x24e598[_0x9a32('0x2c')][_0x9a32('0x3f')]){_0x48c559[_0x9a32('0x39')]=[{'all':!![]}];}_0x48c559=_[_0x9a32('0x36')]({},_0x48c559,_0x24e598[_0x9a32('0x37')]);return db[_0x9a32('0x27')][_0x9a32('0x40')](_0x48c559)[_0x9a32('0x38')](handleEntityNotFound(_0x1f4324,null))[_0x9a32('0x38')](respondWithResult(_0x1f4324,null))['catch'](handleError(_0x1f4324,null));};exports['create']=function(_0x35cd40,_0x4a876f){return db[_0x9a32('0x27')][_0x9a32('0x41')](_0x35cd40[_0x9a32('0x42')],{})[_0x9a32('0x38')](respondWithResult(_0x4a876f,0xc9))['catch'](handleError(_0x4a876f,null));};exports[_0x9a32('0x21')]=function(_0x253ebc,_0x195de1){if(_0x253ebc[_0x9a32('0x42')]['id']){delete _0x253ebc[_0x9a32('0x42')]['id'];}return db[_0x9a32('0x27')][_0x9a32('0x40')]({'where':{'id':_0x253ebc[_0x9a32('0x3d')]['id']}})[_0x9a32('0x38')](handleEntityNotFound(_0x195de1,null))['then'](saveUpdates(_0x253ebc[_0x9a32('0x42')],null))[_0x9a32('0x38')](respondWithResult(_0x195de1,null))[_0x9a32('0x3b')](handleError(_0x195de1,null));};exports[_0x9a32('0x43')]=function(_0x10ce6b,_0x33c13b){return db['WhatsappApplication'][_0x9a32('0x40')]({'where':{'id':_0x10ce6b['params']['id']}})[_0x9a32('0x38')](handleEntityNotFound(_0x33c13b,null))[_0x9a32('0x38')](removeEntity(_0x33c13b,null))[_0x9a32('0x3b')](handleError(_0x33c13b,null));};
\ No newline at end of file