Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / whatsappTransferReport / whatsappTransferReport.controller.js
index bfdbb6e..539bd51 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd18e=['then','error','stack','name','send','index','map','WhatsappTransferReport','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','show','params','keys','includeAll','find','catch','create','body','update','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','status','end','json','count','offset','limit','set','Content-Range','apply','save'];(function(_0x520866,_0x3af494){var _0x2e5dbe=function(_0x502742){while(--_0x502742){_0x520866['push'](_0x520866['shift']());}};_0x2e5dbe(++_0x3af494);}(_0xd18e,0xba));var _0xed18=function(_0x8688f3,_0x5cfce8){_0x8688f3=_0x8688f3-0x0;var _0x57c1d4=_0xd18e[_0x8688f3];return _0x57c1d4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xed18('0x0'));var zipdir=require(_0xed18('0x1'));var jsonpatch=require(_0xed18('0x2'));var rp=require(_0xed18('0x3'));var moment=require(_0xed18('0x4'));var BPromise=require(_0xed18('0x5'));var Mustache=require(_0xed18('0x6'));var util=require(_0xed18('0x7'));var path=require(_0xed18('0x8'));var sox=require(_0xed18('0x9'));var csv=require(_0xed18('0xa'));var ejs=require(_0xed18('0xb'));var fs=require('fs');var fs_extra=require(_0xed18('0xc'));var _=require('lodash');var squel=require(_0xed18('0xd'));var crypto=require(_0xed18('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xed18('0xf'));var toCsv=require(_0xed18('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xed18('0x10'));var authService=require(_0xed18('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xed18('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xed18('0x13'))(_0xed18('0x14'));var utils=require(_0xed18('0x15'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xed18('0x16'))['db'];function respondWithStatusCode(_0x40a4f4,_0x1035a0){_0x1035a0=_0x1035a0||0xcc;return function(_0x4bd0c3){if(_0x4bd0c3){return _0x40a4f4['sendStatus'](_0x1035a0);}return _0x40a4f4[_0xed18('0x17')](_0x1035a0)[_0xed18('0x18')]();};}function respondWithResult(_0x37bde7,_0x4bc1cd){_0x4bc1cd=_0x4bc1cd||0xc8;return function(_0xecdf49){if(_0xecdf49){return _0x37bde7[_0xed18('0x17')](_0x4bc1cd)[_0xed18('0x19')](_0xecdf49);}};}function respondWithFilteredResult(_0xf01fb7,_0x56780b){return function(_0x3aa260){if(_0x3aa260){var _0x44dcd3=_0x3aa260[_0xed18('0x1a')],_0x78ef12=_0x56780b[_0xed18('0x1b')],_0x2f3e31=_0x56780b[_0xed18('0x1b')]+_0x56780b[_0xed18('0x1c')],_0xebcabe;if(_0x2f3e31>=_0x44dcd3){_0x2f3e31=_0x44dcd3;_0xebcabe=0xc8;}else{_0xebcabe=0xce;}_0xf01fb7[_0xed18('0x17')](_0xebcabe);return _0xf01fb7[_0xed18('0x1d')](_0xed18('0x1e'),_0x78ef12+'-'+_0x2f3e31+'/'+_0x44dcd3)['json'](_0x3aa260);}return null;};}function patchUpdates(_0x53621f){return function(_0x2fbdef){try{jsonpatch[_0xed18('0x1f')](_0x2fbdef,_0x53621f,!![]);}catch(_0x1f9cd0){return BPromise['reject'](_0x1f9cd0);}return _0x2fbdef[_0xed18('0x20')]();};}function saveUpdates(_0x4ccb3b,_0x1523a5){return function(_0x5736b7){if(_0x5736b7){return _0x5736b7['update'](_0x4ccb3b)[_0xed18('0x21')](function(_0x350dd7){return _0x350dd7;});}return null;};}function removeEntity(_0xa9b35b,_0x4ebb34){return function(_0xeb6e20){if(_0xeb6e20){return _0xeb6e20['destroy']()[_0xed18('0x21')](function(){_0xa9b35b[_0xed18('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5ce455,_0x134ba7){return function(_0x2d708b){if(!_0x2d708b){_0x5ce455['sendStatus'](0x194);}return _0x2d708b;};}function handleError(_0x1abf41,_0x406512){_0x406512=_0x406512||0x1f4;return function(_0x6063ff){logger[_0xed18('0x22')](_0x6063ff[_0xed18('0x23')]);if(_0x6063ff[_0xed18('0x24')]){delete _0x6063ff['name'];}_0x1abf41[_0xed18('0x17')](_0x406512)[_0xed18('0x25')](_0x6063ff);};}exports[_0xed18('0x26')]=function(_0xf6750c,_0xbd72dd){var _0x493405={},_0x299493={},_0x40dc76={'count':0x0,'rows':[]};var _0x7ab4b0=_[_0xed18('0x27')](db[_0xed18('0x28')][_0xed18('0x29')],function(_0x2a116d){return{'name':_0x2a116d[_0xed18('0x2a')],'type':_0x2a116d[_0xed18('0x2b')][_0xed18('0x2c')]};});_0x299493[_0xed18('0x2d')]=_[_0xed18('0x27')](_0x7ab4b0,_0xed18('0x24'));_0x299493[_0xed18('0x2e')]=_['keys'](_0xf6750c[_0xed18('0x2e')]);_0x299493[_0xed18('0x2f')]=_[_0xed18('0x30')](_0x299493[_0xed18('0x2d')],_0x299493[_0xed18('0x2e')]);_0x493405[_0xed18('0x31')]=_[_0xed18('0x30')](_0x299493[_0xed18('0x2d')],qs[_0xed18('0x32')](_0xf6750c[_0xed18('0x2e')][_0xed18('0x32')]));_0x493405[_0xed18('0x31')]=_0x493405[_0xed18('0x31')][_0xed18('0x33')]?_0x493405['attributes']:_0x299493['model'];if(!_0xf6750c[_0xed18('0x2e')][_0xed18('0x34')](_0xed18('0x35'))){_0x493405[_0xed18('0x1c')]=qs['limit'](_0xf6750c[_0xed18('0x2e')][_0xed18('0x1c')]);_0x493405[_0xed18('0x1b')]=qs[_0xed18('0x1b')](_0xf6750c['query'][_0xed18('0x1b')]);}_0x493405['order']=qs[_0xed18('0x36')](_0xf6750c[_0xed18('0x2e')][_0xed18('0x36')]);_0x493405[_0xed18('0x37')]=qs[_0xed18('0x2f')](_[_0xed18('0x38')](_0xf6750c[_0xed18('0x2e')],_0x299493[_0xed18('0x2f')]),_0x7ab4b0);if(_0xf6750c[_0xed18('0x2e')][_0xed18('0x39')]){_0x493405['where']=_[_0xed18('0x3a')](_0x493405['where'],{'$or':_[_0xed18('0x27')](_0x7ab4b0,function(_0x12944f){if(_0x12944f['type']!==_0xed18('0x3b')){var _0x93ce3b={};_0x93ce3b[_0x12944f[_0xed18('0x24')]]={'$like':'%'+_0xf6750c['query']['filter']+'%'};return _0x93ce3b;}})});}_0x493405=_[_0xed18('0x3a')]({},_0x493405,_0xf6750c[_0xed18('0x3c')]);var _0x2340ba={'where':_0x493405['where']};return db[_0xed18('0x28')][_0xed18('0x1a')](_0x2340ba)[_0xed18('0x21')](function(_0xe28509){_0x40dc76[_0xed18('0x1a')]=_0xe28509;if(_0xf6750c['query']['includeAll']){_0x493405[_0xed18('0x3d')]=[{'all':!![]}];}return db[_0xed18('0x28')]['findAll'](_0x493405);})[_0xed18('0x21')](function(_0x1415fc){_0x40dc76[_0xed18('0x3e')]=_0x1415fc;return _0x40dc76;})[_0xed18('0x21')](respondWithFilteredResult(_0xbd72dd,_0x493405))['catch'](handleError(_0xbd72dd,null));};exports[_0xed18('0x3f')]=function(_0x8fb2fe,_0x1c7eb4){var _0x53bf54={'raw':!![],'where':{'id':_0x8fb2fe[_0xed18('0x40')]['id']}},_0x38ece1={};_0x38ece1[_0xed18('0x2d')]=_[_0xed18('0x41')](db[_0xed18('0x28')][_0xed18('0x29')]);_0x38ece1[_0xed18('0x2e')]=_['keys'](_0x8fb2fe[_0xed18('0x2e')]);_0x38ece1[_0xed18('0x2f')]=_[_0xed18('0x30')](_0x38ece1[_0xed18('0x2d')],_0x38ece1['query']);_0x53bf54[_0xed18('0x31')]=_['intersection'](_0x38ece1[_0xed18('0x2d')],qs[_0xed18('0x32')](_0x8fb2fe[_0xed18('0x2e')][_0xed18('0x32')]));_0x53bf54[_0xed18('0x31')]=_0x53bf54[_0xed18('0x31')][_0xed18('0x33')]?_0x53bf54[_0xed18('0x31')]:_0x38ece1['model'];if(_0x8fb2fe['query'][_0xed18('0x42')]){_0x53bf54[_0xed18('0x3d')]=[{'all':!![]}];}_0x53bf54=_[_0xed18('0x3a')]({},_0x53bf54,_0x8fb2fe[_0xed18('0x3c')]);return db[_0xed18('0x28')][_0xed18('0x43')](_0x53bf54)['then'](handleEntityNotFound(_0x1c7eb4,null))[_0xed18('0x21')](respondWithResult(_0x1c7eb4,null))[_0xed18('0x44')](handleError(_0x1c7eb4,null));};exports[_0xed18('0x45')]=function(_0x3935a5,_0x268b05){return db[_0xed18('0x28')][_0xed18('0x45')](_0x3935a5[_0xed18('0x46')],{})['then'](respondWithResult(_0x268b05,0xc9))['catch'](handleError(_0x268b05,null));};exports[_0xed18('0x47')]=function(_0xe3b1e5,_0x5d99df){if(_0xe3b1e5['body']['id']){delete _0xe3b1e5[_0xed18('0x46')]['id'];}return db[_0xed18('0x28')][_0xed18('0x43')]({'where':{'id':_0xe3b1e5['params']['id']}})['then'](handleEntityNotFound(_0x5d99df,null))[_0xed18('0x21')](saveUpdates(_0xe3b1e5[_0xed18('0x46')],null))[_0xed18('0x21')](respondWithResult(_0x5d99df,null))['catch'](handleError(_0x5d99df,null));};exports['destroy']=function(_0x2fcddf,_0x2eb331){return db[_0xed18('0x28')][_0xed18('0x43')]({'where':{'id':_0x2fcddf[_0xed18('0x40')]['id']}})[_0xed18('0x21')](handleEntityNotFound(_0x2eb331,null))[_0xed18('0x21')](removeEntity(_0x2eb331,null))['catch'](handleError(_0x2eb331,null));};exports[_0xed18('0x48')]=function(_0x238361,_0x319788){return db[_0xed18('0x28')]['describe']()['then'](respondWithResult(_0x319788,null))[_0xed18('0x44')](handleError(_0x319788,null));};
\ No newline at end of file
+var _0x1fe1=['status','set','Content-Range','apply','reject','save','update','then','end','error','stack','name','index','map','WhatsappTransferReport','rawAttributes','type','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','findAll','rows','catch','show','includeAll','create','body','find','params','destroy','describe','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','to-csv','ejs','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','json','offset','undefined','count','limit'];(function(_0x1d10ae,_0x23555b){var _0x4541fc=function(_0x9e1a36){while(--_0x9e1a36){_0x1d10ae['push'](_0x1d10ae['shift']());}};_0x4541fc(++_0x23555b);}(_0x1fe1,0xbd));var _0x11fe=function(_0x25ad0d,_0x1c13e6){_0x25ad0d=_0x25ad0d-0x0;var _0x12f2b7=_0x1fe1[_0x25ad0d];return _0x12f2b7;};'use strict';var emlformat=require(_0x11fe('0x0'));var rimraf=require(_0x11fe('0x1'));var zipdir=require(_0x11fe('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x11fe('0x3'));var moment=require(_0x11fe('0x4'));var BPromise=require(_0x11fe('0x5'));var Mustache=require(_0x11fe('0x6'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x11fe('0x7'));var ejs=require(_0x11fe('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x11fe('0x9'));var crypto=require(_0x11fe('0xa'));var jsforce=require(_0x11fe('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x11fe('0x7'));var querystring=require(_0x11fe('0xc'));var Papa=require(_0x11fe('0xd'));var Redis=require(_0x11fe('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x11fe('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x11fe('0x10'));var utils=require(_0x11fe('0x11'));var config=require(_0x11fe('0x12'));var licenseUtil=require(_0x11fe('0x13'));var db=require(_0x11fe('0x14'))['db'];function respondWithStatusCode(_0x2b7fc7,_0x430d76){_0x430d76=_0x430d76||0xcc;return function(_0x389ab7){if(_0x389ab7){return _0x2b7fc7[_0x11fe('0x15')](_0x430d76);}return _0x2b7fc7['status'](_0x430d76)['end']();};}function respondWithResult(_0x514f10,_0x159fb7){_0x159fb7=_0x159fb7||0xc8;return function(_0x1318b3){if(_0x1318b3){return _0x514f10['status'](_0x159fb7)[_0x11fe('0x16')](_0x1318b3);}};}function respondWithFilteredResult(_0xcaccd5,_0x376748){return function(_0x39c8f3){if(_0x39c8f3){var _0x3bc5d8=typeof _0x376748[_0x11fe('0x17')]===_0x11fe('0x18')&&typeof _0x376748['limit']===_0x11fe('0x18');var _0x2ef394=_0x39c8f3['count'];var _0x5d4e0b=_0x3bc5d8?0x0:_0x376748[_0x11fe('0x17')];var _0x47f70b=_0x3bc5d8?_0x39c8f3[_0x11fe('0x19')]:_0x376748['offset']+_0x376748[_0x11fe('0x1a')];var _0x3dd272;if(_0x47f70b>=_0x2ef394){_0x47f70b=_0x2ef394;_0x3dd272=0xc8;}else{_0x3dd272=0xce;}_0xcaccd5[_0x11fe('0x1b')](_0x3dd272);return _0xcaccd5[_0x11fe('0x1c')](_0x11fe('0x1d'),_0x5d4e0b+'-'+_0x47f70b+'/'+_0x2ef394)['json'](_0x39c8f3);}return null;};}function patchUpdates(_0x37c309){return function(_0x112c2c){try{jsonpatch[_0x11fe('0x1e')](_0x112c2c,_0x37c309,!![]);}catch(_0xd37dae){return BPromise[_0x11fe('0x1f')](_0xd37dae);}return _0x112c2c[_0x11fe('0x20')]();};}function saveUpdates(_0x2c6795,_0x74fad4){return function(_0x1a1040){if(_0x1a1040){return _0x1a1040[_0x11fe('0x21')](_0x2c6795)[_0x11fe('0x22')](function(_0x197344){return _0x197344;});}return null;};}function removeEntity(_0xd5dd60,_0x1eda95){return function(_0x422969){if(_0x422969){return _0x422969['destroy']()[_0x11fe('0x22')](function(){_0xd5dd60[_0x11fe('0x1b')](0xcc)[_0x11fe('0x23')]();});}};}function handleEntityNotFound(_0x440ada,_0x51a4d3){return function(_0x322a4c){if(!_0x322a4c){_0x440ada[_0x11fe('0x15')](0x194);}return _0x322a4c;};}function handleError(_0x509036,_0x3731b2){_0x3731b2=_0x3731b2||0x1f4;return function(_0x315cd6){logger[_0x11fe('0x24')](_0x315cd6[_0x11fe('0x25')]);if(_0x315cd6['name']){delete _0x315cd6[_0x11fe('0x26')];}_0x509036[_0x11fe('0x1b')](_0x3731b2)['send'](_0x315cd6);};}exports[_0x11fe('0x27')]=function(_0x4e9016,_0x1f1953){var _0x3057e1={},_0x2436ad={},_0xeb4150={'count':0x0,'rows':[]};var _0x3ec437=_[_0x11fe('0x28')](db[_0x11fe('0x29')][_0x11fe('0x2a')],function(_0x5cda21){return{'name':_0x5cda21['fieldName'],'type':_0x5cda21[_0x11fe('0x2b')]['key']};});_0x2436ad[_0x11fe('0x2c')]=_['map'](_0x3ec437,_0x11fe('0x26'));_0x2436ad['query']=_[_0x11fe('0x2d')](_0x4e9016[_0x11fe('0x2e')]);_0x2436ad[_0x11fe('0x2f')]=_['intersection'](_0x2436ad['model'],_0x2436ad[_0x11fe('0x2e')]);_0x3057e1[_0x11fe('0x30')]=_[_0x11fe('0x31')](_0x2436ad[_0x11fe('0x2c')],qs[_0x11fe('0x32')](_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x32')]));_0x3057e1['attributes']=_0x3057e1['attributes'][_0x11fe('0x33')]?_0x3057e1['attributes']:_0x2436ad[_0x11fe('0x2c')];if(!_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x34')](_0x11fe('0x35'))){_0x3057e1[_0x11fe('0x1a')]=qs[_0x11fe('0x1a')](_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x1a')]);_0x3057e1[_0x11fe('0x17')]=qs['offset'](_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x17')]);}_0x3057e1[_0x11fe('0x36')]=qs['sort'](_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x37')]);_0x3057e1[_0x11fe('0x38')]=qs[_0x11fe('0x2f')](_['pick'](_0x4e9016[_0x11fe('0x2e')],_0x2436ad[_0x11fe('0x2f')]),_0x3ec437);if(_0x4e9016[_0x11fe('0x2e')][_0x11fe('0x39')]){_0x3057e1[_0x11fe('0x38')]=_[_0x11fe('0x3a')](_0x3057e1[_0x11fe('0x38')],{'$or':_['map'](_0x3ec437,function(_0x415151){if(_0x415151[_0x11fe('0x2b')]!==_0x11fe('0x3b')){var _0x1758d0={};_0x1758d0[_0x415151[_0x11fe('0x26')]]={'$like':'%'+_0x4e9016[_0x11fe('0x2e')]['filter']+'%'};return _0x1758d0;}})});}_0x3057e1=_[_0x11fe('0x3a')]({},_0x3057e1,_0x4e9016[_0x11fe('0x3c')]);var _0x161c8d={'where':_0x3057e1['where']};return db['WhatsappTransferReport'][_0x11fe('0x19')](_0x161c8d)[_0x11fe('0x22')](function(_0x51607c){_0xeb4150[_0x11fe('0x19')]=_0x51607c;if(_0x4e9016['query']['includeAll']){_0x3057e1['include']=[{'all':!![]}];}return db[_0x11fe('0x29')][_0x11fe('0x3d')](_0x3057e1);})[_0x11fe('0x22')](function(_0x37ed92){_0xeb4150[_0x11fe('0x3e')]=_0x37ed92;return _0xeb4150;})[_0x11fe('0x22')](respondWithFilteredResult(_0x1f1953,_0x3057e1))[_0x11fe('0x3f')](handleError(_0x1f1953,null));};exports[_0x11fe('0x40')]=function(_0xa1c698,_0x2fe790){var _0x114a7d={'raw':!![],'where':{'id':_0xa1c698['params']['id']}},_0x1a6bcc={};_0x1a6bcc['model']=_['keys'](db[_0x11fe('0x29')][_0x11fe('0x2a')]);_0x1a6bcc[_0x11fe('0x2e')]=_[_0x11fe('0x2d')](_0xa1c698[_0x11fe('0x2e')]);_0x1a6bcc['filters']=_[_0x11fe('0x31')](_0x1a6bcc['model'],_0x1a6bcc[_0x11fe('0x2e')]);_0x114a7d[_0x11fe('0x30')]=_[_0x11fe('0x31')](_0x1a6bcc['model'],qs[_0x11fe('0x32')](_0xa1c698['query']['fields']));_0x114a7d['attributes']=_0x114a7d[_0x11fe('0x30')][_0x11fe('0x33')]?_0x114a7d[_0x11fe('0x30')]:_0x1a6bcc[_0x11fe('0x2c')];if(_0xa1c698[_0x11fe('0x2e')][_0x11fe('0x41')]){_0x114a7d['include']=[{'all':!![]}];}_0x114a7d=_[_0x11fe('0x3a')]({},_0x114a7d,_0xa1c698[_0x11fe('0x3c')]);return db[_0x11fe('0x29')]['find'](_0x114a7d)[_0x11fe('0x22')](handleEntityNotFound(_0x2fe790,null))[_0x11fe('0x22')](respondWithResult(_0x2fe790,null))['catch'](handleError(_0x2fe790,null));};exports[_0x11fe('0x42')]=function(_0x5567d4,_0x128066){return db[_0x11fe('0x29')][_0x11fe('0x42')](_0x5567d4[_0x11fe('0x43')],{})[_0x11fe('0x22')](respondWithResult(_0x128066,0xc9))[_0x11fe('0x3f')](handleError(_0x128066,null));};exports[_0x11fe('0x21')]=function(_0x36e31b,_0x215f38){if(_0x36e31b['body']['id']){delete _0x36e31b[_0x11fe('0x43')]['id'];}return db[_0x11fe('0x29')][_0x11fe('0x44')]({'where':{'id':_0x36e31b[_0x11fe('0x45')]['id']}})[_0x11fe('0x22')](handleEntityNotFound(_0x215f38,null))[_0x11fe('0x22')](saveUpdates(_0x36e31b['body'],null))[_0x11fe('0x22')](respondWithResult(_0x215f38,null))['catch'](handleError(_0x215f38,null));};exports[_0x11fe('0x46')]=function(_0x4ebd9c,_0x37acf2){return db[_0x11fe('0x29')][_0x11fe('0x44')]({'where':{'id':_0x4ebd9c[_0x11fe('0x45')]['id']}})[_0x11fe('0x22')](handleEntityNotFound(_0x37acf2,null))[_0x11fe('0x22')](removeEntity(_0x37acf2,null))[_0x11fe('0x3f')](handleError(_0x37acf2,null));};exports['describe']=function(_0x10a54f,_0xd7690c){return db['WhatsappTransferReport'][_0x11fe('0x47')]()['then'](respondWithResult(_0xd7690c,null))['catch'](handleError(_0xd7690c,null));};
\ No newline at end of file