Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / whatsappApplication / whatsappApplication.controller.js
index 22224d0..0e82b12 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 _0x471a=['Content-Range','apply','reject','save','then','error','stack','name','send','index','map','WhatsappApplication','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','sort','where','pick','filter','merge','options','includeAll','findAll','rows','catch','params','rawAttributes','length','find','create','body','destroy','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','to-csv','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','set'];(function(_0x4fc702,_0x590060){var _0x1357d3=function(_0x45a119){while(--_0x45a119){_0x4fc702['push'](_0x4fc702['shift']());}};_0x1357d3(++_0x590060);}(_0x471a,0x18d));var _0xa471=function(_0x524a85,_0x5e1060){_0x524a85=_0x524a85-0x0;var _0x596ef4=_0x471a[_0x524a85];return _0x596ef4;};'use strict';var emlformat=require(_0xa471('0x0'));var rimraf=require(_0xa471('0x1'));var zipdir=require(_0xa471('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa471('0x3'));var moment=require(_0xa471('0x4'));var BPromise=require(_0xa471('0x5'));var Mustache=require(_0xa471('0x6'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xa471('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xa471('0x8'));var crypto=require(_0xa471('0x9'));var jsforce=require(_0xa471('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xa471('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xa471('0xb'));var authService=require(_0xa471('0xc'));var qs=require(_0xa471('0xd'));var as=require(_0xa471('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xa471('0xf'))(_0xa471('0x10'));var utils=require(_0xa471('0x11'));var config=require(_0xa471('0x12'));var licenseUtil=require(_0xa471('0x13'));var db=require(_0xa471('0x14'))['db'];function respondWithStatusCode(_0x5703c9,_0x2ae2a2){_0x2ae2a2=_0x2ae2a2||0xcc;return function(_0x4f1a44){if(_0x4f1a44){return _0x5703c9[_0xa471('0x15')](_0x2ae2a2);}return _0x5703c9['status'](_0x2ae2a2)[_0xa471('0x16')]();};}function respondWithResult(_0x115541,_0x501375){_0x501375=_0x501375||0xc8;return function(_0x39c025){if(_0x39c025){return _0x115541[_0xa471('0x17')](_0x501375)[_0xa471('0x18')](_0x39c025);}};}function respondWithFilteredResult(_0x531451,_0x31bcb7){return function(_0x1ed20c){if(_0x1ed20c){var _0x16e5bf=typeof _0x31bcb7[_0xa471('0x19')]===_0xa471('0x1a')&&typeof _0x31bcb7['limit']===_0xa471('0x1a');var _0x35f2f3=_0x1ed20c[_0xa471('0x1b')];var _0x5e5225=_0x16e5bf?0x0:_0x31bcb7['offset'];var _0x23fb08=_0x16e5bf?_0x1ed20c['count']:_0x31bcb7[_0xa471('0x19')]+_0x31bcb7['limit'];var _0x5e56dc;if(_0x23fb08>=_0x35f2f3){_0x23fb08=_0x35f2f3;_0x5e56dc=0xc8;}else{_0x5e56dc=0xce;}_0x531451[_0xa471('0x17')](_0x5e56dc);return _0x531451[_0xa471('0x1c')](_0xa471('0x1d'),_0x5e5225+'-'+_0x23fb08+'/'+_0x35f2f3)[_0xa471('0x18')](_0x1ed20c);}return null;};}function patchUpdates(_0x45ff30){return function(_0x6b230){try{jsonpatch[_0xa471('0x1e')](_0x6b230,_0x45ff30,!![]);}catch(_0x554610){return BPromise[_0xa471('0x1f')](_0x554610);}return _0x6b230[_0xa471('0x20')]();};}function saveUpdates(_0x398f23,_0x49ea0b){return function(_0x3e0972){if(_0x3e0972){return _0x3e0972['update'](_0x398f23)[_0xa471('0x21')](function(_0x2b7755){return _0x2b7755;});}return null;};}function removeEntity(_0x56a34e,_0x21b9e5){return function(_0x41a855){if(_0x41a855){return _0x41a855['destroy']()[_0xa471('0x21')](function(){_0x56a34e['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x188d6a,_0x2b1d3c){return function(_0x56682a){if(!_0x56682a){_0x188d6a['sendStatus'](0x194);}return _0x56682a;};}function handleError(_0x165504,_0x2d2a91){_0x2d2a91=_0x2d2a91||0x1f4;return function(_0x5009cf){logger[_0xa471('0x22')](_0x5009cf[_0xa471('0x23')]);if(_0x5009cf[_0xa471('0x24')]){delete _0x5009cf[_0xa471('0x24')];}_0x165504['status'](_0x2d2a91)[_0xa471('0x25')](_0x5009cf);};}exports[_0xa471('0x26')]=function(_0x5a3f99,_0x3851d9){var _0x3bb318={},_0x469b08={},_0x3961b5={'count':0x0,'rows':[]};var _0x5d4441=_[_0xa471('0x27')](db[_0xa471('0x28')]['rawAttributes'],function(_0x4eb527){return{'name':_0x4eb527[_0xa471('0x29')],'type':_0x4eb527[_0xa471('0x2a')][_0xa471('0x2b')]};});_0x469b08[_0xa471('0x2c')]=_[_0xa471('0x27')](_0x5d4441,'name');_0x469b08[_0xa471('0x2d')]=_[_0xa471('0x2e')](_0x5a3f99[_0xa471('0x2d')]);_0x469b08[_0xa471('0x2f')]=_[_0xa471('0x30')](_0x469b08[_0xa471('0x2c')],_0x469b08[_0xa471('0x2d')]);_0x3bb318[_0xa471('0x31')]=_[_0xa471('0x30')](_0x469b08['model'],qs[_0xa471('0x32')](_0x5a3f99[_0xa471('0x2d')][_0xa471('0x32')]));_0x3bb318[_0xa471('0x31')]=_0x3bb318[_0xa471('0x31')]['length']?_0x3bb318[_0xa471('0x31')]:_0x469b08[_0xa471('0x2c')];if(!_0x5a3f99[_0xa471('0x2d')][_0xa471('0x33')](_0xa471('0x34'))){_0x3bb318[_0xa471('0x35')]=qs['limit'](_0x5a3f99[_0xa471('0x2d')][_0xa471('0x35')]);_0x3bb318[_0xa471('0x19')]=qs[_0xa471('0x19')](_0x5a3f99[_0xa471('0x2d')][_0xa471('0x19')]);}_0x3bb318['order']=qs[_0xa471('0x36')](_0x5a3f99['query']['sort']);_0x3bb318[_0xa471('0x37')]=qs[_0xa471('0x2f')](_[_0xa471('0x38')](_0x5a3f99[_0xa471('0x2d')],_0x469b08[_0xa471('0x2f')]),_0x5d4441);if(_0x5a3f99['query'][_0xa471('0x39')]){_0x3bb318[_0xa471('0x37')]=_[_0xa471('0x3a')](_0x3bb318[_0xa471('0x37')],{'$or':_[_0xa471('0x27')](_0x5d4441,function(_0xcf1361){if(_0xcf1361[_0xa471('0x2a')]!=='VIRTUAL'){var _0x2aefbf={};_0x2aefbf[_0xcf1361[_0xa471('0x24')]]={'$like':'%'+_0x5a3f99['query']['filter']+'%'};return _0x2aefbf;}})});}_0x3bb318=_[_0xa471('0x3a')]({},_0x3bb318,_0x5a3f99[_0xa471('0x3b')]);var _0x2d98f0={'where':_0x3bb318[_0xa471('0x37')]};return db[_0xa471('0x28')][_0xa471('0x1b')](_0x2d98f0)[_0xa471('0x21')](function(_0xcc3f85){_0x3961b5[_0xa471('0x1b')]=_0xcc3f85;if(_0x5a3f99['query'][_0xa471('0x3c')]){_0x3bb318['include']=[{'all':!![]}];}return db[_0xa471('0x28')][_0xa471('0x3d')](_0x3bb318);})[_0xa471('0x21')](function(_0x19eb6e){_0x3961b5[_0xa471('0x3e')]=_0x19eb6e;return _0x3961b5;})[_0xa471('0x21')](respondWithFilteredResult(_0x3851d9,_0x3bb318))[_0xa471('0x3f')](handleError(_0x3851d9,null));};exports['show']=function(_0xc932ae,_0x2d848a){var _0x50668b={'raw':!![],'where':{'id':_0xc932ae[_0xa471('0x40')]['id']}},_0x38ec90={};_0x38ec90['model']=_['keys'](db[_0xa471('0x28')][_0xa471('0x41')]);_0x38ec90[_0xa471('0x2d')]=_[_0xa471('0x2e')](_0xc932ae[_0xa471('0x2d')]);_0x38ec90[_0xa471('0x2f')]=_[_0xa471('0x30')](_0x38ec90[_0xa471('0x2c')],_0x38ec90[_0xa471('0x2d')]);_0x50668b[_0xa471('0x31')]=_[_0xa471('0x30')](_0x38ec90[_0xa471('0x2c')],qs['fields'](_0xc932ae[_0xa471('0x2d')][_0xa471('0x32')]));_0x50668b[_0xa471('0x31')]=_0x50668b[_0xa471('0x31')][_0xa471('0x42')]?_0x50668b['attributes']:_0x38ec90[_0xa471('0x2c')];if(_0xc932ae['query'][_0xa471('0x3c')]){_0x50668b['include']=[{'all':!![]}];}_0x50668b=_[_0xa471('0x3a')]({},_0x50668b,_0xc932ae[_0xa471('0x3b')]);return db[_0xa471('0x28')][_0xa471('0x43')](_0x50668b)[_0xa471('0x21')](handleEntityNotFound(_0x2d848a,null))['then'](respondWithResult(_0x2d848a,null))[_0xa471('0x3f')](handleError(_0x2d848a,null));};exports['create']=function(_0x2fb716,_0x39e2d8){return db[_0xa471('0x28')][_0xa471('0x44')](_0x2fb716[_0xa471('0x45')],{})['then'](respondWithResult(_0x39e2d8,0xc9))[_0xa471('0x3f')](handleError(_0x39e2d8,null));};exports['update']=function(_0x5c0efe,_0x2cf4a9){if(_0x5c0efe['body']['id']){delete _0x5c0efe['body']['id'];}return db[_0xa471('0x28')]['find']({'where':{'id':_0x5c0efe[_0xa471('0x40')]['id']}})[_0xa471('0x21')](handleEntityNotFound(_0x2cf4a9,null))['then'](saveUpdates(_0x5c0efe[_0xa471('0x45')],null))[_0xa471('0x21')](respondWithResult(_0x2cf4a9,null))[_0xa471('0x3f')](handleError(_0x2cf4a9,null));};exports[_0xa471('0x46')]=function(_0x3e486f,_0x21323b){return db[_0xa471('0x28')]['find']({'where':{'id':_0x3e486f[_0xa471('0x40')]['id']}})[_0xa471('0x21')](handleEntityNotFound(_0x21323b,null))[_0xa471('0x21')](removeEntity(_0x21323b,null))['catch'](handleError(_0x21323b,null));};
\ No newline at end of file