Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / whatsappTransferReport / whatsappTransferReport.controller.js
index 4200208..74b506f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb68b=['eml-format','rimraf','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','sendStatus','status','end','offset','limit','json','reject','then','error','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','WhatsappTransferReport','count','findAll','rows','show','params','includeAll','include','options','catch','create','body','update','find','describe','html-pdf'];(function(_0x3e667f,_0x201abb){var _0x494856=function(_0x30989e){while(--_0x30989e){_0x3e667f['push'](_0x3e667f['shift']());}};_0x494856(++_0x201abb);}(_0xb68b,0x10b));var _0xbb68=function(_0x599f41,_0x4db732){_0x599f41=_0x599f41-0x0;var _0x2e4d58=_0xb68b[_0x599f41];return _0x2e4d58;};'use strict';var pdf=require(_0xbb68('0x0'));var emlformat=require(_0xbb68('0x1'));var rimraf=require(_0xbb68('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbb68('0x3'));var rp=require('request-promise');var moment=require(_0xbb68('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbb68('0x5'));var util=require(_0xbb68('0x6'));var path=require(_0xbb68('0x7'));var sox=require(_0xbb68('0x8'));var csv=require(_0xbb68('0x9'));var ejs=require(_0xbb68('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbb68('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xbb68('0x9'));var querystring=require(_0xbb68('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xbb68('0xd'));var qs=require(_0xbb68('0xe'));var as=require(_0xbb68('0xf'));var hardwareService=require(_0xbb68('0x10'));var logger=require(_0xbb68('0x11'))(_0xbb68('0x12'));var utils=require(_0xbb68('0x13'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x49cc64,_0x46c906){_0x46c906=_0x46c906||0xcc;return function(_0x496062){if(_0x496062){return _0x49cc64[_0xbb68('0x14')](_0x46c906);}return _0x49cc64[_0xbb68('0x15')](_0x46c906)[_0xbb68('0x16')]();};}function respondWithResult(_0x1dac0c,_0x1fac3f){_0x1fac3f=_0x1fac3f||0xc8;return function(_0x41eed9){if(_0x41eed9){return _0x1dac0c[_0xbb68('0x15')](_0x1fac3f)['json'](_0x41eed9);}};}function respondWithFilteredResult(_0xdd2138,_0x3aa426){return function(_0x4ce220){if(_0x4ce220){var _0x1814e1=_0x4ce220['count'],_0x262ab5=_0x3aa426[_0xbb68('0x17')],_0x4063c9=_0x3aa426[_0xbb68('0x17')]+_0x3aa426[_0xbb68('0x18')],_0xbe3e13;if(_0x4063c9>=_0x1814e1){_0x4063c9=_0x1814e1;_0xbe3e13=0xc8;}else{_0xbe3e13=0xce;}_0xdd2138[_0xbb68('0x15')](_0xbe3e13);return _0xdd2138['set']('Content-Range',_0x262ab5+'-'+_0x4063c9+'/'+_0x1814e1)[_0xbb68('0x19')](_0x4ce220);}return null;};}function patchUpdates(_0x5bc341){return function(_0x2027f5){try{jsonpatch['apply'](_0x2027f5,_0x5bc341,!![]);}catch(_0x42dcef){return BPromise[_0xbb68('0x1a')](_0x42dcef);}return _0x2027f5['save']();};}function saveUpdates(_0x5b55d3,_0x348c79){return function(_0x31004d){if(_0x31004d){return _0x31004d['update'](_0x5b55d3)[_0xbb68('0x1b')](function(_0x19a3b7){return _0x19a3b7;});}return null;};}function removeEntity(_0x4e6ed5,_0x222915){return function(_0xcf25ca){if(_0xcf25ca){return _0xcf25ca['destroy']()['then'](function(){_0x4e6ed5['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x356455,_0x43a2ee){return function(_0x5e8619){if(!_0x5e8619){_0x356455[_0xbb68('0x14')](0x194);}return _0x5e8619;};}function handleError(_0x3265aa,_0x342802){_0x342802=_0x342802||0x1f4;return function(_0x4bb284){logger[_0xbb68('0x1c')](_0x4bb284['stack']);if(_0x4bb284[_0xbb68('0x1d')]){delete _0x4bb284['name'];}_0x3265aa[_0xbb68('0x15')](_0x342802)[_0xbb68('0x1e')](_0x4bb284);};}exports[_0xbb68('0x1f')]=function(_0x1dbe4d,_0x1119df){var _0x4090aa={},_0x5beeea={},_0x4a27f4={'count':0x0,'rows':[]};var _0x245b2e=_[_0xbb68('0x20')](db['WhatsappTransferReport'][_0xbb68('0x21')],function(_0x1f48b3){return{'name':_0x1f48b3[_0xbb68('0x22')],'type':_0x1f48b3[_0xbb68('0x23')][_0xbb68('0x24')]};});_0x5beeea[_0xbb68('0x25')]=_[_0xbb68('0x20')](_0x245b2e,_0xbb68('0x1d'));_0x5beeea[_0xbb68('0x26')]=_[_0xbb68('0x27')](_0x1dbe4d[_0xbb68('0x26')]);_0x5beeea[_0xbb68('0x28')]=_[_0xbb68('0x29')](_0x5beeea['model'],_0x5beeea[_0xbb68('0x26')]);_0x4090aa[_0xbb68('0x2a')]=_[_0xbb68('0x29')](_0x5beeea['model'],qs[_0xbb68('0x2b')](_0x1dbe4d['query'][_0xbb68('0x2b')]));_0x4090aa[_0xbb68('0x2a')]=_0x4090aa['attributes'][_0xbb68('0x2c')]?_0x4090aa[_0xbb68('0x2a')]:_0x5beeea['model'];if(!_0x1dbe4d[_0xbb68('0x26')][_0xbb68('0x2d')]('nolimit')){_0x4090aa['limit']=qs[_0xbb68('0x18')](_0x1dbe4d['query']['limit']);_0x4090aa['offset']=qs[_0xbb68('0x17')](_0x1dbe4d[_0xbb68('0x26')]['offset']);}_0x4090aa[_0xbb68('0x2e')]=qs['sort'](_0x1dbe4d[_0xbb68('0x26')][_0xbb68('0x2f')]);_0x4090aa[_0xbb68('0x30')]=qs['filters'](_[_0xbb68('0x31')](_0x1dbe4d[_0xbb68('0x26')],_0x5beeea[_0xbb68('0x28')]),_0x245b2e);if(_0x1dbe4d[_0xbb68('0x26')][_0xbb68('0x32')]){_0x4090aa[_0xbb68('0x30')]=_[_0xbb68('0x33')](_0x4090aa[_0xbb68('0x30')],{'$or':_[_0xbb68('0x20')](_0x245b2e,function(_0x3202b0){if(_0x3202b0[_0xbb68('0x23')]!=='VIRTUAL'){var _0x4c173b={};_0x4c173b[_0x3202b0[_0xbb68('0x1d')]]={'$like':'%'+_0x1dbe4d[_0xbb68('0x26')]['filter']+'%'};return _0x4c173b;}})});}_0x4090aa=_['merge']({},_0x4090aa,_0x1dbe4d['options']);var _0x20f098={'where':_0x4090aa[_0xbb68('0x30')]};return db[_0xbb68('0x34')][_0xbb68('0x35')](_0x20f098)[_0xbb68('0x1b')](function(_0x19ffd5){_0x4a27f4[_0xbb68('0x35')]=_0x19ffd5;if(_0x1dbe4d['query']['includeAll']){_0x4090aa['include']=[{'all':!![]}];}return db['WhatsappTransferReport'][_0xbb68('0x36')](_0x4090aa);})[_0xbb68('0x1b')](function(_0x39c7a8){_0x4a27f4[_0xbb68('0x37')]=_0x39c7a8;return _0x4a27f4;})[_0xbb68('0x1b')](respondWithFilteredResult(_0x1119df,_0x4090aa))['catch'](handleError(_0x1119df,null));};exports[_0xbb68('0x38')]=function(_0xf7c14f,_0x23bf3d){var _0x29b4ce={'raw':!![],'where':{'id':_0xf7c14f[_0xbb68('0x39')]['id']}},_0x5001e3={};_0x5001e3[_0xbb68('0x25')]=_[_0xbb68('0x27')](db['WhatsappTransferReport'][_0xbb68('0x21')]);_0x5001e3[_0xbb68('0x26')]=_[_0xbb68('0x27')](_0xf7c14f[_0xbb68('0x26')]);_0x5001e3[_0xbb68('0x28')]=_[_0xbb68('0x29')](_0x5001e3[_0xbb68('0x25')],_0x5001e3['query']);_0x29b4ce[_0xbb68('0x2a')]=_[_0xbb68('0x29')](_0x5001e3[_0xbb68('0x25')],qs['fields'](_0xf7c14f['query']['fields']));_0x29b4ce[_0xbb68('0x2a')]=_0x29b4ce['attributes'][_0xbb68('0x2c')]?_0x29b4ce[_0xbb68('0x2a')]:_0x5001e3[_0xbb68('0x25')];if(_0xf7c14f[_0xbb68('0x26')][_0xbb68('0x3a')]){_0x29b4ce[_0xbb68('0x3b')]=[{'all':!![]}];}_0x29b4ce=_[_0xbb68('0x33')]({},_0x29b4ce,_0xf7c14f[_0xbb68('0x3c')]);return db['WhatsappTransferReport']['find'](_0x29b4ce)[_0xbb68('0x1b')](handleEntityNotFound(_0x23bf3d,null))[_0xbb68('0x1b')](respondWithResult(_0x23bf3d,null))[_0xbb68('0x3d')](handleError(_0x23bf3d,null));};exports['create']=function(_0x10af51,_0x5baea1){return db[_0xbb68('0x34')][_0xbb68('0x3e')](_0x10af51[_0xbb68('0x3f')],{})[_0xbb68('0x1b')](respondWithResult(_0x5baea1,0xc9))[_0xbb68('0x3d')](handleError(_0x5baea1,null));};exports[_0xbb68('0x40')]=function(_0x1d9656,_0x213d40){if(_0x1d9656[_0xbb68('0x3f')]['id']){delete _0x1d9656[_0xbb68('0x3f')]['id'];}return db[_0xbb68('0x34')][_0xbb68('0x41')]({'where':{'id':_0x1d9656['params']['id']}})[_0xbb68('0x1b')](handleEntityNotFound(_0x213d40,null))[_0xbb68('0x1b')](saveUpdates(_0x1d9656[_0xbb68('0x3f')],null))['then'](respondWithResult(_0x213d40,null))['catch'](handleError(_0x213d40,null));};exports['destroy']=function(_0x558c95,_0x391e33){return db[_0xbb68('0x34')][_0xbb68('0x41')]({'where':{'id':_0x558c95[_0xbb68('0x39')]['id']}})['then'](handleEntityNotFound(_0x391e33,null))[_0xbb68('0x1b')](removeEntity(_0x391e33,null))[_0xbb68('0x3d')](handleError(_0x391e33,null));};exports[_0xbb68('0x42')]=function(_0x2c50f7,_0x594aae){return db[_0xbb68('0x34')]['describe']()[_0xbb68('0x1b')](respondWithResult(_0x594aae,null))[_0xbb68('0x3d')](handleError(_0x594aae,null));};
\ No newline at end of file
+var _0x52a7=['request-promise','moment','bluebird','mustache','util','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','end','stack','name','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','WhatsappTransferReport','includeAll','findAll','catch','show','params','find','create','body','destroy','zip-dir','fast-json-patch'];(function(_0xbc9261,_0x42ba9d){var _0x2c0487=function(_0x47e243){while(--_0x47e243){_0xbc9261['push'](_0xbc9261['shift']());}};_0x2c0487(++_0x42ba9d);}(_0x52a7,0x16b));var _0x752a=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0x52a7[_0x40a045];return _0x1a687c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x752a('0x0'));var jsonpatch=require(_0x752a('0x1'));var rp=require(_0x752a('0x2'));var moment=require(_0x752a('0x3'));var BPromise=require(_0x752a('0x4'));var Mustache=require(_0x752a('0x5'));var util=require(_0x752a('0x6'));var path=require('path');var sox=require(_0x752a('0x7'));var csv=require(_0x752a('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x752a('0x9'));var _=require('lodash');var squel=require(_0x752a('0xa'));var crypto=require(_0x752a('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x752a('0xc'));var toCsv=require('to-csv');var querystring=require(_0x752a('0xd'));var Papa=require(_0x752a('0xe'));var Redis=require(_0x752a('0xf'));var authService=require(_0x752a('0x10'));var qs=require(_0x752a('0x11'));var as=require(_0x752a('0x12'));var hardwareService=require(_0x752a('0x13'));var logger=require('../../config/logger')(_0x752a('0x14'));var utils=require(_0x752a('0x15'));var config=require(_0x752a('0x16'));var licenseUtil=require(_0x752a('0x17'));var db=require(_0x752a('0x18'))['db'];function respondWithStatusCode(_0x1fd312,_0x387cf4){_0x387cf4=_0x387cf4||0xcc;return function(_0x5bdad1){if(_0x5bdad1){return _0x1fd312[_0x752a('0x19')](_0x387cf4);}return _0x1fd312[_0x752a('0x1a')](_0x387cf4)['end']();};}function respondWithResult(_0x12aefd,_0x47d693){_0x47d693=_0x47d693||0xc8;return function(_0x9ea6e0){if(_0x9ea6e0){return _0x12aefd[_0x752a('0x1a')](_0x47d693)[_0x752a('0x1b')](_0x9ea6e0);}};}function respondWithFilteredResult(_0x1091e5,_0x2ad947){return function(_0x1d967a){if(_0x1d967a){var _0x4e2b56=typeof _0x2ad947[_0x752a('0x1c')]===_0x752a('0x1d')&&typeof _0x2ad947[_0x752a('0x1e')]===_0x752a('0x1d');var _0x52f175=_0x1d967a[_0x752a('0x1f')];var _0x4973ef=_0x4e2b56?0x0:_0x2ad947[_0x752a('0x1c')];var _0x3db53d=_0x4e2b56?_0x1d967a[_0x752a('0x1f')]:_0x2ad947[_0x752a('0x1c')]+_0x2ad947[_0x752a('0x1e')];var _0x5248c2;if(_0x3db53d>=_0x52f175){_0x3db53d=_0x52f175;_0x5248c2=0xc8;}else{_0x5248c2=0xce;}_0x1091e5[_0x752a('0x1a')](_0x5248c2);return _0x1091e5[_0x752a('0x20')](_0x752a('0x21'),_0x4973ef+'-'+_0x3db53d+'/'+_0x52f175)[_0x752a('0x1b')](_0x1d967a);}return null;};}function patchUpdates(_0x9056a5){return function(_0x4d276d){try{jsonpatch['apply'](_0x4d276d,_0x9056a5,!![]);}catch(_0x30cb6c){return BPromise[_0x752a('0x22')](_0x30cb6c);}return _0x4d276d[_0x752a('0x23')]();};}function saveUpdates(_0x24c10c,_0x58f48b){return function(_0xb71478){if(_0xb71478){return _0xb71478[_0x752a('0x24')](_0x24c10c)[_0x752a('0x25')](function(_0x2cf269){return _0x2cf269;});}return null;};}function removeEntity(_0x2f0d04,_0x54cdbf){return function(_0x3ba924){if(_0x3ba924){return _0x3ba924['destroy']()[_0x752a('0x25')](function(){_0x2f0d04[_0x752a('0x1a')](0xcc)[_0x752a('0x26')]();});}};}function handleEntityNotFound(_0x3ca500,_0xf1ff32){return function(_0x5b1f1a){if(!_0x5b1f1a){_0x3ca500['sendStatus'](0x194);}return _0x5b1f1a;};}function handleError(_0xd6ba41,_0x50fb40){_0x50fb40=_0x50fb40||0x1f4;return function(_0xf7e979){logger['error'](_0xf7e979[_0x752a('0x27')]);if(_0xf7e979[_0x752a('0x28')]){delete _0xf7e979[_0x752a('0x28')];}_0xd6ba41['status'](_0x50fb40)['send'](_0xf7e979);};}exports['index']=function(_0x455e3a,_0x38d78f){var _0x2f5059={},_0x4db606={},_0x520183={'count':0x0,'rows':[]};var _0x17495f=_[_0x752a('0x29')](db['WhatsappTransferReport'][_0x752a('0x2a')],function(_0x43c946){return{'name':_0x43c946[_0x752a('0x2b')],'type':_0x43c946[_0x752a('0x2c')]['key']};});_0x4db606[_0x752a('0x2d')]=_['map'](_0x17495f,_0x752a('0x28'));_0x4db606[_0x752a('0x2e')]=_[_0x752a('0x2f')](_0x455e3a[_0x752a('0x2e')]);_0x4db606[_0x752a('0x30')]=_[_0x752a('0x31')](_0x4db606[_0x752a('0x2d')],_0x4db606[_0x752a('0x2e')]);_0x2f5059['attributes']=_[_0x752a('0x31')](_0x4db606[_0x752a('0x2d')],qs[_0x752a('0x32')](_0x455e3a[_0x752a('0x2e')]['fields']));_0x2f5059['attributes']=_0x2f5059[_0x752a('0x33')][_0x752a('0x34')]?_0x2f5059[_0x752a('0x33')]:_0x4db606[_0x752a('0x2d')];if(!_0x455e3a['query'][_0x752a('0x35')](_0x752a('0x36'))){_0x2f5059[_0x752a('0x1e')]=qs[_0x752a('0x1e')](_0x455e3a['query'][_0x752a('0x1e')]);_0x2f5059[_0x752a('0x1c')]=qs[_0x752a('0x1c')](_0x455e3a[_0x752a('0x2e')][_0x752a('0x1c')]);}_0x2f5059[_0x752a('0x37')]=qs[_0x752a('0x38')](_0x455e3a[_0x752a('0x2e')][_0x752a('0x38')]);_0x2f5059['where']=qs[_0x752a('0x30')](_[_0x752a('0x39')](_0x455e3a[_0x752a('0x2e')],_0x4db606[_0x752a('0x30')]),_0x17495f);if(_0x455e3a['query'][_0x752a('0x3a')]){_0x2f5059[_0x752a('0x3b')]=_[_0x752a('0x3c')](_0x2f5059[_0x752a('0x3b')],{'$or':_['map'](_0x17495f,function(_0x4563be){if(_0x4563be['type']!==_0x752a('0x3d')){var _0x585bf3={};_0x585bf3[_0x4563be[_0x752a('0x28')]]={'$like':'%'+_0x455e3a[_0x752a('0x2e')]['filter']+'%'};return _0x585bf3;}})});}_0x2f5059=_['merge']({},_0x2f5059,_0x455e3a[_0x752a('0x3e')]);var _0x13a128={'where':_0x2f5059[_0x752a('0x3b')]};return db[_0x752a('0x3f')]['count'](_0x13a128)['then'](function(_0x25f24e){_0x520183['count']=_0x25f24e;if(_0x455e3a[_0x752a('0x2e')][_0x752a('0x40')]){_0x2f5059['include']=[{'all':!![]}];}return db[_0x752a('0x3f')][_0x752a('0x41')](_0x2f5059);})[_0x752a('0x25')](function(_0x2c8a36){_0x520183['rows']=_0x2c8a36;return _0x520183;})[_0x752a('0x25')](respondWithFilteredResult(_0x38d78f,_0x2f5059))[_0x752a('0x42')](handleError(_0x38d78f,null));};exports[_0x752a('0x43')]=function(_0x89fe1f,_0x3f44b6){var _0x45f4a8={'raw':!![],'where':{'id':_0x89fe1f[_0x752a('0x44')]['id']}},_0x4fc67f={};_0x4fc67f['model']=_[_0x752a('0x2f')](db[_0x752a('0x3f')][_0x752a('0x2a')]);_0x4fc67f[_0x752a('0x2e')]=_[_0x752a('0x2f')](_0x89fe1f[_0x752a('0x2e')]);_0x4fc67f[_0x752a('0x30')]=_[_0x752a('0x31')](_0x4fc67f[_0x752a('0x2d')],_0x4fc67f[_0x752a('0x2e')]);_0x45f4a8[_0x752a('0x33')]=_[_0x752a('0x31')](_0x4fc67f['model'],qs[_0x752a('0x32')](_0x89fe1f['query'][_0x752a('0x32')]));_0x45f4a8[_0x752a('0x33')]=_0x45f4a8[_0x752a('0x33')][_0x752a('0x34')]?_0x45f4a8[_0x752a('0x33')]:_0x4fc67f['model'];if(_0x89fe1f['query'][_0x752a('0x40')]){_0x45f4a8['include']=[{'all':!![]}];}_0x45f4a8=_[_0x752a('0x3c')]({},_0x45f4a8,_0x89fe1f['options']);return db[_0x752a('0x3f')][_0x752a('0x45')](_0x45f4a8)[_0x752a('0x25')](handleEntityNotFound(_0x3f44b6,null))['then'](respondWithResult(_0x3f44b6,null))[_0x752a('0x42')](handleError(_0x3f44b6,null));};exports['create']=function(_0x320ce8,_0x407214){return db['WhatsappTransferReport'][_0x752a('0x46')](_0x320ce8['body'],{})[_0x752a('0x25')](respondWithResult(_0x407214,0xc9))['catch'](handleError(_0x407214,null));};exports[_0x752a('0x24')]=function(_0x35be0c,_0x16b5ba){if(_0x35be0c[_0x752a('0x47')]['id']){delete _0x35be0c['body']['id'];}return db[_0x752a('0x3f')][_0x752a('0x45')]({'where':{'id':_0x35be0c[_0x752a('0x44')]['id']}})[_0x752a('0x25')](handleEntityNotFound(_0x16b5ba,null))[_0x752a('0x25')](saveUpdates(_0x35be0c[_0x752a('0x47')],null))['then'](respondWithResult(_0x16b5ba,null))[_0x752a('0x42')](handleError(_0x16b5ba,null));};exports[_0x752a('0x48')]=function(_0xc4413c,_0x53b2fe){return db['WhatsappTransferReport'][_0x752a('0x45')]({'where':{'id':_0xc4413c['params']['id']}})[_0x752a('0x25')](handleEntityNotFound(_0x53b2fe,null))[_0x752a('0x25')](removeEntity(_0x53b2fe,null))[_0x752a('0x42')](handleError(_0x53b2fe,null));};exports['describe']=function(_0x19a999,_0x57b656){return db['WhatsappTransferReport']['describe']()[_0x752a('0x25')](respondWithResult(_0x57b656,null))['catch'](handleError(_0x57b656,null));};
\ No newline at end of file