Built motion from commit 9d7072cc.|2.5.39
[motion2.git] / server / api / whatsappApplication / whatsappApplication.controller.js
index 22224d0..d2aee35 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfd6e=['includeAll','include','catch','show','intersection','create','body','find','html-pdf','eml-format','zip-dir','moment','mustache','util','path','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','set','Content-Range','apply','save','update','then','destroy','error','stack','name','index','rawAttributes','fieldName','type','key','model','map','query','keys','filters','attributes','fields','length','hasOwnProperty','limit','order','sort','pick','filter','where','merge','options','WhatsappApplication'];(function(_0x31b889,_0x448803){var _0xaabac4=function(_0x1d1a37){while(--_0x1d1a37){_0x31b889['push'](_0x31b889['shift']());}};_0xaabac4(++_0x448803);}(_0xfd6e,0xdd));var _0xefd6=function(_0x397e5f,_0x454c8f){_0x397e5f=_0x397e5f-0x0;var _0x5302b8=_0xfd6e[_0x397e5f];return _0x5302b8;};'use strict';var pdf=require(_0xefd6('0x0'));var emlformat=require(_0xefd6('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xefd6('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xefd6('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xefd6('0x4'));var util=require(_0xefd6('0x5'));var path=require(_0xefd6('0x6'));var sox=require('sox');var csv=require(_0xefd6('0x7'));var ejs=require(_0xefd6('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xefd6('0x9'));var crypto=require(_0xefd6('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xefd6('0xb'));var toCsv=require('to-csv');var querystring=require(_0xefd6('0xc'));var Papa=require(_0xefd6('0xd'));var Redis=require(_0xefd6('0xe'));var authService=require(_0xefd6('0xf'));var qs=require(_0xefd6('0x10'));var as=require(_0xefd6('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xefd6('0x12'))(_0xefd6('0x13'));var utils=require(_0xefd6('0x14'));var config=require(_0xefd6('0x15'));var licenseUtil=require(_0xefd6('0x16'));var db=require(_0xefd6('0x17'))['db'];function respondWithStatusCode(_0x42971e,_0x300c79){_0x300c79=_0x300c79||0xcc;return function(_0x339a71){if(_0x339a71){return _0x42971e[_0xefd6('0x18')](_0x300c79);}return _0x42971e[_0xefd6('0x19')](_0x300c79)[_0xefd6('0x1a')]();};}function respondWithResult(_0x5c8ce8,_0x5dbeca){_0x5dbeca=_0x5dbeca||0xc8;return function(_0x8a97b9){if(_0x8a97b9){return _0x5c8ce8[_0xefd6('0x19')](_0x5dbeca)[_0xefd6('0x1b')](_0x8a97b9);}};}function respondWithFilteredResult(_0x1caa6a,_0x4dfd66){return function(_0x539bcb){if(_0x539bcb){var _0x451ce7=_0x539bcb[_0xefd6('0x1c')],_0x15b280=_0x4dfd66[_0xefd6('0x1d')],_0x5476c0=_0x4dfd66[_0xefd6('0x1d')]+_0x4dfd66['limit'],_0x5b358c;if(_0x5476c0>=_0x451ce7){_0x5476c0=_0x451ce7;_0x5b358c=0xc8;}else{_0x5b358c=0xce;}_0x1caa6a[_0xefd6('0x19')](_0x5b358c);return _0x1caa6a[_0xefd6('0x1e')](_0xefd6('0x1f'),_0x15b280+'-'+_0x5476c0+'/'+_0x451ce7)[_0xefd6('0x1b')](_0x539bcb);}return null;};}function patchUpdates(_0xb88430){return function(_0x5319f4){try{jsonpatch[_0xefd6('0x20')](_0x5319f4,_0xb88430,!![]);}catch(_0x4b8f25){return BPromise['reject'](_0x4b8f25);}return _0x5319f4[_0xefd6('0x21')]();};}function saveUpdates(_0xd34ab2,_0x2b1867){return function(_0x18bf37){if(_0x18bf37){return _0x18bf37[_0xefd6('0x22')](_0xd34ab2)[_0xefd6('0x23')](function(_0x48d289){return _0x48d289;});}return null;};}function removeEntity(_0x216670,_0xa24970){return function(_0x3aca7a){if(_0x3aca7a){return _0x3aca7a[_0xefd6('0x24')]()[_0xefd6('0x23')](function(){_0x216670[_0xefd6('0x19')](0xcc)[_0xefd6('0x1a')]();});}};}function handleEntityNotFound(_0x3d14d8,_0xe51151){return function(_0x5c7622){if(!_0x5c7622){_0x3d14d8[_0xefd6('0x18')](0x194);}return _0x5c7622;};}function handleError(_0x5c66f0,_0x5dbc1b){_0x5dbc1b=_0x5dbc1b||0x1f4;return function(_0x352b24){logger[_0xefd6('0x25')](_0x352b24[_0xefd6('0x26')]);if(_0x352b24['name']){delete _0x352b24[_0xefd6('0x27')];}_0x5c66f0[_0xefd6('0x19')](_0x5dbc1b)['send'](_0x352b24);};}exports[_0xefd6('0x28')]=function(_0x2d2410,_0x2024d2){var _0x296d44={},_0x16474b={},_0x20700d={'count':0x0,'rows':[]};var _0x506e0a=_['map'](db['WhatsappApplication'][_0xefd6('0x29')],function(_0x3ead75){return{'name':_0x3ead75[_0xefd6('0x2a')],'type':_0x3ead75[_0xefd6('0x2b')][_0xefd6('0x2c')]};});_0x16474b[_0xefd6('0x2d')]=_[_0xefd6('0x2e')](_0x506e0a,_0xefd6('0x27'));_0x16474b[_0xefd6('0x2f')]=_[_0xefd6('0x30')](_0x2d2410[_0xefd6('0x2f')]);_0x16474b[_0xefd6('0x31')]=_['intersection'](_0x16474b[_0xefd6('0x2d')],_0x16474b[_0xefd6('0x2f')]);_0x296d44[_0xefd6('0x32')]=_['intersection'](_0x16474b[_0xefd6('0x2d')],qs[_0xefd6('0x33')](_0x2d2410[_0xefd6('0x2f')][_0xefd6('0x33')]));_0x296d44['attributes']=_0x296d44[_0xefd6('0x32')][_0xefd6('0x34')]?_0x296d44[_0xefd6('0x32')]:_0x16474b[_0xefd6('0x2d')];if(!_0x2d2410[_0xefd6('0x2f')][_0xefd6('0x35')]('nolimit')){_0x296d44[_0xefd6('0x36')]=qs['limit'](_0x2d2410['query'][_0xefd6('0x36')]);_0x296d44[_0xefd6('0x1d')]=qs['offset'](_0x2d2410[_0xefd6('0x2f')]['offset']);}_0x296d44[_0xefd6('0x37')]=qs[_0xefd6('0x38')](_0x2d2410[_0xefd6('0x2f')][_0xefd6('0x38')]);_0x296d44['where']=qs[_0xefd6('0x31')](_[_0xefd6('0x39')](_0x2d2410[_0xefd6('0x2f')],_0x16474b[_0xefd6('0x31')]),_0x506e0a);if(_0x2d2410['query'][_0xefd6('0x3a')]){_0x296d44[_0xefd6('0x3b')]=_[_0xefd6('0x3c')](_0x296d44[_0xefd6('0x3b')],{'$or':_[_0xefd6('0x2e')](_0x506e0a,function(_0x18e931){if(_0x18e931[_0xefd6('0x2b')]!=='VIRTUAL'){var _0x1779a0={};_0x1779a0[_0x18e931[_0xefd6('0x27')]]={'$like':'%'+_0x2d2410[_0xefd6('0x2f')][_0xefd6('0x3a')]+'%'};return _0x1779a0;}})});}_0x296d44=_['merge']({},_0x296d44,_0x2d2410[_0xefd6('0x3d')]);var _0x412a46={'where':_0x296d44['where']};return db[_0xefd6('0x3e')][_0xefd6('0x1c')](_0x412a46)[_0xefd6('0x23')](function(_0x1449d5){_0x20700d[_0xefd6('0x1c')]=_0x1449d5;if(_0x2d2410[_0xefd6('0x2f')][_0xefd6('0x3f')]){_0x296d44[_0xefd6('0x40')]=[{'all':!![]}];}return db['WhatsappApplication']['findAll'](_0x296d44);})[_0xefd6('0x23')](function(_0x186989){_0x20700d['rows']=_0x186989;return _0x20700d;})['then'](respondWithFilteredResult(_0x2024d2,_0x296d44))[_0xefd6('0x41')](handleError(_0x2024d2,null));};exports[_0xefd6('0x42')]=function(_0x5620af,_0x15f2e0){var _0x93a317={'raw':!![],'where':{'id':_0x5620af['params']['id']}},_0x1ef535={};_0x1ef535[_0xefd6('0x2d')]=_[_0xefd6('0x30')](db[_0xefd6('0x3e')]['rawAttributes']);_0x1ef535['query']=_['keys'](_0x5620af['query']);_0x1ef535[_0xefd6('0x31')]=_[_0xefd6('0x43')](_0x1ef535['model'],_0x1ef535[_0xefd6('0x2f')]);_0x93a317[_0xefd6('0x32')]=_['intersection'](_0x1ef535[_0xefd6('0x2d')],qs['fields'](_0x5620af[_0xefd6('0x2f')][_0xefd6('0x33')]));_0x93a317['attributes']=_0x93a317[_0xefd6('0x32')][_0xefd6('0x34')]?_0x93a317['attributes']:_0x1ef535[_0xefd6('0x2d')];if(_0x5620af['query']['includeAll']){_0x93a317[_0xefd6('0x40')]=[{'all':!![]}];}_0x93a317=_[_0xefd6('0x3c')]({},_0x93a317,_0x5620af[_0xefd6('0x3d')]);return db[_0xefd6('0x3e')]['find'](_0x93a317)[_0xefd6('0x23')](handleEntityNotFound(_0x15f2e0,null))[_0xefd6('0x23')](respondWithResult(_0x15f2e0,null))[_0xefd6('0x41')](handleError(_0x15f2e0,null));};exports['create']=function(_0x3b15dc,_0x90ee44){return db[_0xefd6('0x3e')][_0xefd6('0x44')](_0x3b15dc['body'],{})[_0xefd6('0x23')](respondWithResult(_0x90ee44,0xc9))[_0xefd6('0x41')](handleError(_0x90ee44,null));};exports['update']=function(_0x574f85,_0x462d85){if(_0x574f85[_0xefd6('0x45')]['id']){delete _0x574f85[_0xefd6('0x45')]['id'];}return db[_0xefd6('0x3e')][_0xefd6('0x46')]({'where':{'id':_0x574f85['params']['id']}})['then'](handleEntityNotFound(_0x462d85,null))[_0xefd6('0x23')](saveUpdates(_0x574f85['body'],null))['then'](respondWithResult(_0x462d85,null))[_0xefd6('0x41')](handleError(_0x462d85,null));};exports[_0xefd6('0x24')]=function(_0x338d5c,_0x4a1ccb){return db[_0xefd6('0x3e')][_0xefd6('0x46')]({'where':{'id':_0x338d5c['params']['id']}})['then'](handleEntityNotFound(_0x4a1ccb,null))[_0xefd6('0x23')](removeEntity(_0x4a1ccb,null))[_0xefd6('0x41')](handleError(_0x4a1ccb,null));};
\ No newline at end of file
+var _0x04fa=['intersection','fields','attributes','length','hasOwnProperty','sort','where','pick','merge','type','filter','options','includeAll','include','WhatsappApplication','rows','catch','params','find','create','body','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','sox','to-csv','fs-extra','lodash','squel','jsforce','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','end','status','json','offset','undefined','limit','count','Content-Range','apply','save','update','then','destroy','sendStatus','error','stack','name','send','map','rawAttributes','key','model','query','keys','filters'];(function(_0x5e32f3,_0x3386c1){var _0x4d4e03=function(_0xe86f5){while(--_0xe86f5){_0x5e32f3['push'](_0x5e32f3['shift']());}};_0x4d4e03(++_0x3386c1);}(_0x04fa,0x119));var _0xa04f=function(_0x393187,_0x39ef4e){_0x393187=_0x393187-0x0;var _0x364856=_0x04fa[_0x393187];return _0x364856;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa04f('0x0'));var zipdir=require(_0xa04f('0x1'));var jsonpatch=require(_0xa04f('0x2'));var rp=require(_0xa04f('0x3'));var moment=require(_0xa04f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xa04f('0x5'));var util=require('util');var path=require(_0xa04f('0x6'));var sox=require(_0xa04f('0x7'));var csv=require(_0xa04f('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa04f('0x9'));var _=require(_0xa04f('0xa'));var squel=require(_0xa04f('0xb'));var crypto=require('crypto');var jsforce=require(_0xa04f('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xa04f('0xd'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xa04f('0xe'));var hardwareService=require(_0xa04f('0xf'));var logger=require('../../config/logger')(_0xa04f('0x10'));var utils=require('../../config/utils');var config=require(_0xa04f('0x11'));var licenseUtil=require(_0xa04f('0x12'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x155b4f,_0x46687a){_0x46687a=_0x46687a||0xcc;return function(_0x5671c2){if(_0x5671c2){return _0x155b4f['sendStatus'](_0x46687a);}return _0x155b4f['status'](_0x46687a)[_0xa04f('0x13')]();};}function respondWithResult(_0x3254ea,_0x3d57cb){_0x3d57cb=_0x3d57cb||0xc8;return function(_0xb396b){if(_0xb396b){return _0x3254ea[_0xa04f('0x14')](_0x3d57cb)[_0xa04f('0x15')](_0xb396b);}};}function respondWithFilteredResult(_0x5b4afd,_0xf25bd){return function(_0x2737f2){if(_0x2737f2){var _0x509830=typeof _0xf25bd[_0xa04f('0x16')]===_0xa04f('0x17')&&typeof _0xf25bd[_0xa04f('0x18')]===_0xa04f('0x17');var _0x4e5908=_0x2737f2[_0xa04f('0x19')];var _0x5d59d5=_0x509830?0x0:_0xf25bd[_0xa04f('0x16')];var _0x25bb59=_0x509830?_0x2737f2['count']:_0xf25bd[_0xa04f('0x16')]+_0xf25bd[_0xa04f('0x18')];var _0x31e707;if(_0x25bb59>=_0x4e5908){_0x25bb59=_0x4e5908;_0x31e707=0xc8;}else{_0x31e707=0xce;}_0x5b4afd['status'](_0x31e707);return _0x5b4afd['set'](_0xa04f('0x1a'),_0x5d59d5+'-'+_0x25bb59+'/'+_0x4e5908)['json'](_0x2737f2);}return null;};}function patchUpdates(_0x5d68f4){return function(_0x141fc8){try{jsonpatch[_0xa04f('0x1b')](_0x141fc8,_0x5d68f4,!![]);}catch(_0x48f760){return BPromise['reject'](_0x48f760);}return _0x141fc8[_0xa04f('0x1c')]();};}function saveUpdates(_0x13fdb1,_0x17d471){return function(_0x3f7268){if(_0x3f7268){return _0x3f7268[_0xa04f('0x1d')](_0x13fdb1)[_0xa04f('0x1e')](function(_0x600bfa){return _0x600bfa;});}return null;};}function removeEntity(_0x40bc69,_0x28dc9b){return function(_0x3ee16d){if(_0x3ee16d){return _0x3ee16d[_0xa04f('0x1f')]()[_0xa04f('0x1e')](function(){_0x40bc69[_0xa04f('0x14')](0xcc)[_0xa04f('0x13')]();});}};}function handleEntityNotFound(_0x5123db,_0x18c13e){return function(_0xee0a84){if(!_0xee0a84){_0x5123db[_0xa04f('0x20')](0x194);}return _0xee0a84;};}function handleError(_0x48f242,_0x54ed09){_0x54ed09=_0x54ed09||0x1f4;return function(_0x3faa79){logger[_0xa04f('0x21')](_0x3faa79[_0xa04f('0x22')]);if(_0x3faa79['name']){delete _0x3faa79[_0xa04f('0x23')];}_0x48f242[_0xa04f('0x14')](_0x54ed09)[_0xa04f('0x24')](_0x3faa79);};}exports['index']=function(_0x3c6ccd,_0x1c0cc5){var _0x25a96f={},_0x7e0865={},_0x1e441c={'count':0x0,'rows':[]};var _0x24cf00=_[_0xa04f('0x25')](db['WhatsappApplication'][_0xa04f('0x26')],function(_0x3e3395){return{'name':_0x3e3395['fieldName'],'type':_0x3e3395['type'][_0xa04f('0x27')]};});_0x7e0865[_0xa04f('0x28')]=_[_0xa04f('0x25')](_0x24cf00,_0xa04f('0x23'));_0x7e0865[_0xa04f('0x29')]=_[_0xa04f('0x2a')](_0x3c6ccd['query']);_0x7e0865[_0xa04f('0x2b')]=_[_0xa04f('0x2c')](_0x7e0865[_0xa04f('0x28')],_0x7e0865['query']);_0x25a96f['attributes']=_['intersection'](_0x7e0865[_0xa04f('0x28')],qs[_0xa04f('0x2d')](_0x3c6ccd[_0xa04f('0x29')]['fields']));_0x25a96f['attributes']=_0x25a96f[_0xa04f('0x2e')][_0xa04f('0x2f')]?_0x25a96f[_0xa04f('0x2e')]:_0x7e0865[_0xa04f('0x28')];if(!_0x3c6ccd[_0xa04f('0x29')][_0xa04f('0x30')]('nolimit')){_0x25a96f[_0xa04f('0x18')]=qs[_0xa04f('0x18')](_0x3c6ccd[_0xa04f('0x29')]['limit']);_0x25a96f[_0xa04f('0x16')]=qs[_0xa04f('0x16')](_0x3c6ccd[_0xa04f('0x29')][_0xa04f('0x16')]);}_0x25a96f['order']=qs['sort'](_0x3c6ccd['query'][_0xa04f('0x31')]);_0x25a96f[_0xa04f('0x32')]=qs[_0xa04f('0x2b')](_[_0xa04f('0x33')](_0x3c6ccd[_0xa04f('0x29')],_0x7e0865[_0xa04f('0x2b')]),_0x24cf00);if(_0x3c6ccd['query']['filter']){_0x25a96f['where']=_[_0xa04f('0x34')](_0x25a96f[_0xa04f('0x32')],{'$or':_['map'](_0x24cf00,function(_0x3c9639){if(_0x3c9639[_0xa04f('0x35')]!=='VIRTUAL'){var _0x59e7ce={};_0x59e7ce[_0x3c9639[_0xa04f('0x23')]]={'$like':'%'+_0x3c6ccd[_0xa04f('0x29')][_0xa04f('0x36')]+'%'};return _0x59e7ce;}})});}_0x25a96f=_[_0xa04f('0x34')]({},_0x25a96f,_0x3c6ccd[_0xa04f('0x37')]);var _0x30b6e7={'where':_0x25a96f[_0xa04f('0x32')]};return db['WhatsappApplication'][_0xa04f('0x19')](_0x30b6e7)['then'](function(_0x18b1ae){_0x1e441c['count']=_0x18b1ae;if(_0x3c6ccd[_0xa04f('0x29')][_0xa04f('0x38')]){_0x25a96f[_0xa04f('0x39')]=[{'all':!![]}];}return db[_0xa04f('0x3a')]['findAll'](_0x25a96f);})[_0xa04f('0x1e')](function(_0x5aecf2){_0x1e441c[_0xa04f('0x3b')]=_0x5aecf2;return _0x1e441c;})[_0xa04f('0x1e')](respondWithFilteredResult(_0x1c0cc5,_0x25a96f))[_0xa04f('0x3c')](handleError(_0x1c0cc5,null));};exports['show']=function(_0x54ea98,_0x5abd61){var _0x731d6b={'raw':!![],'where':{'id':_0x54ea98[_0xa04f('0x3d')]['id']}},_0x34a56b={};_0x34a56b['model']=_[_0xa04f('0x2a')](db[_0xa04f('0x3a')][_0xa04f('0x26')]);_0x34a56b['query']=_[_0xa04f('0x2a')](_0x54ea98[_0xa04f('0x29')]);_0x34a56b[_0xa04f('0x2b')]=_[_0xa04f('0x2c')](_0x34a56b[_0xa04f('0x28')],_0x34a56b[_0xa04f('0x29')]);_0x731d6b[_0xa04f('0x2e')]=_[_0xa04f('0x2c')](_0x34a56b[_0xa04f('0x28')],qs[_0xa04f('0x2d')](_0x54ea98[_0xa04f('0x29')]['fields']));_0x731d6b['attributes']=_0x731d6b[_0xa04f('0x2e')][_0xa04f('0x2f')]?_0x731d6b[_0xa04f('0x2e')]:_0x34a56b['model'];if(_0x54ea98[_0xa04f('0x29')][_0xa04f('0x38')]){_0x731d6b[_0xa04f('0x39')]=[{'all':!![]}];}_0x731d6b=_[_0xa04f('0x34')]({},_0x731d6b,_0x54ea98['options']);return db[_0xa04f('0x3a')][_0xa04f('0x3e')](_0x731d6b)[_0xa04f('0x1e')](handleEntityNotFound(_0x5abd61,null))[_0xa04f('0x1e')](respondWithResult(_0x5abd61,null))[_0xa04f('0x3c')](handleError(_0x5abd61,null));};exports[_0xa04f('0x3f')]=function(_0x1d4f25,_0x1a7ea5){return db[_0xa04f('0x3a')]['create'](_0x1d4f25[_0xa04f('0x40')],{})['then'](respondWithResult(_0x1a7ea5,0xc9))[_0xa04f('0x3c')](handleError(_0x1a7ea5,null));};exports[_0xa04f('0x1d')]=function(_0x246d5e,_0x18c591){if(_0x246d5e[_0xa04f('0x40')]['id']){delete _0x246d5e['body']['id'];}return db['WhatsappApplication'][_0xa04f('0x3e')]({'where':{'id':_0x246d5e[_0xa04f('0x3d')]['id']}})[_0xa04f('0x1e')](handleEntityNotFound(_0x18c591,null))['then'](saveUpdates(_0x246d5e[_0xa04f('0x40')],null))[_0xa04f('0x1e')](respondWithResult(_0x18c591,null))['catch'](handleError(_0x18c591,null));};exports[_0xa04f('0x1f')]=function(_0x518bf4,_0x12ccd2){return db['WhatsappApplication'][_0xa04f('0x3e')]({'where':{'id':_0x518bf4[_0xa04f('0x3d')]['id']}})['then'](handleEntityNotFound(_0x12ccd2,null))[_0xa04f('0x1e')](removeEntity(_0x12ccd2,null))['catch'](handleError(_0x12ccd2,null));};
\ No newline at end of file