Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / whatsappApplication / whatsappApplication.controller.js
index 360914e..0e82b12 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x323f=['send','index','map','WhatsappApplication','rawAttributes','fieldName','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','filter','merge','type','options','includeAll','include','rows','catch','show','params','keys','create','body','find','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','Content-Range','json','reject','save','update','then','destroy','error','stack','name'];(function(_0x2a3a73,_0x964fbe){var _0x2cdc58=function(_0xd15e69){while(--_0xd15e69){_0x2a3a73['push'](_0x2a3a73['shift']());}};_0x2cdc58(++_0x964fbe);}(_0x323f,0x1ee));var _0xf323=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0x323f[_0x46aff0];return _0x9d78cf;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf323('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf323('0x1'));var rp=require(_0xf323('0x2'));var moment=require(_0xf323('0x3'));var BPromise=require(_0xf323('0x4'));var Mustache=require(_0xf323('0x5'));var util=require(_0xf323('0x6'));var path=require(_0xf323('0x7'));var sox=require(_0xf323('0x8'));var csv=require(_0xf323('0x9'));var ejs=require(_0xf323('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf323('0xb'));var squel=require(_0xf323('0xc'));var crypto=require(_0xf323('0xd'));var jsforce=require(_0xf323('0xe'));var deskjs=require(_0xf323('0xf'));var toCsv=require(_0xf323('0x9'));var querystring=require(_0xf323('0x10'));var Papa=require(_0xf323('0x11'));var Redis=require(_0xf323('0x12'));var authService=require(_0xf323('0x13'));var qs=require(_0xf323('0x14'));var as=require(_0xf323('0x15'));var hardwareService=require(_0xf323('0x16'));var logger=require(_0xf323('0x17'))(_0xf323('0x18'));var utils=require(_0xf323('0x19'));var config=require(_0xf323('0x1a'));var licenseUtil=require('../../config/license/util');var db=require(_0xf323('0x1b'))['db'];function respondWithStatusCode(_0x7dbd26,_0x26eddb){_0x26eddb=_0x26eddb||0xcc;return function(_0x56b916){if(_0x56b916){return _0x7dbd26[_0xf323('0x1c')](_0x26eddb);}return _0x7dbd26[_0xf323('0x1d')](_0x26eddb)[_0xf323('0x1e')]();};}function respondWithResult(_0x3a829f,_0x22672e){_0x22672e=_0x22672e||0xc8;return function(_0x144db9){if(_0x144db9){return _0x3a829f['status'](_0x22672e)['json'](_0x144db9);}};}function respondWithFilteredResult(_0x874219,_0x447517){return function(_0x38fd4c){if(_0x38fd4c){var _0x3858ee=typeof _0x447517[_0xf323('0x1f')]==='undefined'&&typeof _0x447517[_0xf323('0x20')]===_0xf323('0x21');var _0xb9859f=_0x38fd4c[_0xf323('0x22')];var _0x49b115=_0x3858ee?0x0:_0x447517[_0xf323('0x1f')];var _0x272aec=_0x3858ee?_0x38fd4c[_0xf323('0x22')]:_0x447517[_0xf323('0x1f')]+_0x447517['limit'];var _0x409b16;if(_0x272aec>=_0xb9859f){_0x272aec=_0xb9859f;_0x409b16=0xc8;}else{_0x409b16=0xce;}_0x874219[_0xf323('0x1d')](_0x409b16);return _0x874219['set'](_0xf323('0x23'),_0x49b115+'-'+_0x272aec+'/'+_0xb9859f)[_0xf323('0x24')](_0x38fd4c);}return null;};}function patchUpdates(_0x32a942){return function(_0x183ce0){try{jsonpatch['apply'](_0x183ce0,_0x32a942,!![]);}catch(_0xdc7891){return BPromise[_0xf323('0x25')](_0xdc7891);}return _0x183ce0[_0xf323('0x26')]();};}function saveUpdates(_0x52305d,_0x43e467){return function(_0x375473){if(_0x375473){return _0x375473[_0xf323('0x27')](_0x52305d)[_0xf323('0x28')](function(_0x13ec1f){return _0x13ec1f;});}return null;};}function removeEntity(_0xa3362c,_0x189b23){return function(_0x43bc05){if(_0x43bc05){return _0x43bc05[_0xf323('0x29')]()['then'](function(){_0xa3362c[_0xf323('0x1d')](0xcc)[_0xf323('0x1e')]();});}};}function handleEntityNotFound(_0x33dc52,_0x292ce0){return function(_0x87ec45){if(!_0x87ec45){_0x33dc52[_0xf323('0x1c')](0x194);}return _0x87ec45;};}function handleError(_0x4d737d,_0x30ed93){_0x30ed93=_0x30ed93||0x1f4;return function(_0x56ce33){logger[_0xf323('0x2a')](_0x56ce33[_0xf323('0x2b')]);if(_0x56ce33['name']){delete _0x56ce33[_0xf323('0x2c')];}_0x4d737d[_0xf323('0x1d')](_0x30ed93)[_0xf323('0x2d')](_0x56ce33);};}exports[_0xf323('0x2e')]=function(_0x46e3b1,_0x5b8b60){var _0x44c944={},_0x34b536={},_0x12c7d5={'count':0x0,'rows':[]};var _0x30a5d7=_[_0xf323('0x2f')](db[_0xf323('0x30')][_0xf323('0x31')],function(_0x1723b7){return{'name':_0x1723b7[_0xf323('0x32')],'type':_0x1723b7['type'][_0xf323('0x33')]};});_0x34b536[_0xf323('0x34')]=_[_0xf323('0x2f')](_0x30a5d7,_0xf323('0x2c'));_0x34b536[_0xf323('0x35')]=_['keys'](_0x46e3b1[_0xf323('0x35')]);_0x34b536[_0xf323('0x36')]=_[_0xf323('0x37')](_0x34b536[_0xf323('0x34')],_0x34b536[_0xf323('0x35')]);_0x44c944['attributes']=_[_0xf323('0x37')](_0x34b536[_0xf323('0x34')],qs[_0xf323('0x38')](_0x46e3b1[_0xf323('0x35')]['fields']));_0x44c944[_0xf323('0x39')]=_0x44c944['attributes'][_0xf323('0x3a')]?_0x44c944[_0xf323('0x39')]:_0x34b536['model'];if(!_0x46e3b1[_0xf323('0x35')]['hasOwnProperty'](_0xf323('0x3b'))){_0x44c944['limit']=qs[_0xf323('0x20')](_0x46e3b1['query'][_0xf323('0x20')]);_0x44c944[_0xf323('0x1f')]=qs['offset'](_0x46e3b1['query']['offset']);}_0x44c944[_0xf323('0x3c')]=qs[_0xf323('0x3d')](_0x46e3b1[_0xf323('0x35')][_0xf323('0x3d')]);_0x44c944[_0xf323('0x3e')]=qs['filters'](_['pick'](_0x46e3b1['query'],_0x34b536[_0xf323('0x36')]),_0x30a5d7);if(_0x46e3b1['query'][_0xf323('0x3f')]){_0x44c944['where']=_[_0xf323('0x40')](_0x44c944[_0xf323('0x3e')],{'$or':_[_0xf323('0x2f')](_0x30a5d7,function(_0x325fa9){if(_0x325fa9[_0xf323('0x41')]!=='VIRTUAL'){var _0x3d8ddb={};_0x3d8ddb[_0x325fa9[_0xf323('0x2c')]]={'$like':'%'+_0x46e3b1[_0xf323('0x35')][_0xf323('0x3f')]+'%'};return _0x3d8ddb;}})});}_0x44c944=_[_0xf323('0x40')]({},_0x44c944,_0x46e3b1[_0xf323('0x42')]);var _0x288428={'where':_0x44c944[_0xf323('0x3e')]};return db[_0xf323('0x30')][_0xf323('0x22')](_0x288428)[_0xf323('0x28')](function(_0x45287b){_0x12c7d5[_0xf323('0x22')]=_0x45287b;if(_0x46e3b1[_0xf323('0x35')][_0xf323('0x43')]){_0x44c944[_0xf323('0x44')]=[{'all':!![]}];}return db['WhatsappApplication']['findAll'](_0x44c944);})[_0xf323('0x28')](function(_0x16ac6d){_0x12c7d5[_0xf323('0x45')]=_0x16ac6d;return _0x12c7d5;})[_0xf323('0x28')](respondWithFilteredResult(_0x5b8b60,_0x44c944))[_0xf323('0x46')](handleError(_0x5b8b60,null));};exports[_0xf323('0x47')]=function(_0x2746e3,_0x125047){var _0x1c0136={'raw':!![],'where':{'id':_0x2746e3[_0xf323('0x48')]['id']}},_0x320592={};_0x320592[_0xf323('0x34')]=_[_0xf323('0x49')](db['WhatsappApplication'][_0xf323('0x31')]);_0x320592['query']=_['keys'](_0x2746e3[_0xf323('0x35')]);_0x320592['filters']=_['intersection'](_0x320592[_0xf323('0x34')],_0x320592[_0xf323('0x35')]);_0x1c0136[_0xf323('0x39')]=_[_0xf323('0x37')](_0x320592[_0xf323('0x34')],qs[_0xf323('0x38')](_0x2746e3[_0xf323('0x35')][_0xf323('0x38')]));_0x1c0136[_0xf323('0x39')]=_0x1c0136[_0xf323('0x39')][_0xf323('0x3a')]?_0x1c0136['attributes']:_0x320592[_0xf323('0x34')];if(_0x2746e3['query'][_0xf323('0x43')]){_0x1c0136[_0xf323('0x44')]=[{'all':!![]}];}_0x1c0136=_[_0xf323('0x40')]({},_0x1c0136,_0x2746e3[_0xf323('0x42')]);return db['WhatsappApplication']['find'](_0x1c0136)[_0xf323('0x28')](handleEntityNotFound(_0x125047,null))['then'](respondWithResult(_0x125047,null))[_0xf323('0x46')](handleError(_0x125047,null));};exports['create']=function(_0x2204f5,_0x8980f){return db['WhatsappApplication'][_0xf323('0x4a')](_0x2204f5[_0xf323('0x4b')],{})[_0xf323('0x28')](respondWithResult(_0x8980f,0xc9))[_0xf323('0x46')](handleError(_0x8980f,null));};exports[_0xf323('0x27')]=function(_0x950009,_0x34268e){if(_0x950009[_0xf323('0x4b')]['id']){delete _0x950009[_0xf323('0x4b')]['id'];}return db[_0xf323('0x30')][_0xf323('0x4c')]({'where':{'id':_0x950009[_0xf323('0x48')]['id']}})[_0xf323('0x28')](handleEntityNotFound(_0x34268e,null))['then'](saveUpdates(_0x950009[_0xf323('0x4b')],null))[_0xf323('0x28')](respondWithResult(_0x34268e,null))[_0xf323('0x46')](handleError(_0x34268e,null));};exports[_0xf323('0x29')]=function(_0x190e85,_0x1288b3){return db['WhatsappApplication'][_0xf323('0x4c')]({'where':{'id':_0x190e85[_0xf323('0x48')]['id']}})['then'](handleEntityNotFound(_0x1288b3,null))[_0xf323('0x28')](removeEntity(_0x1288b3,null))[_0xf323('0x46')](handleError(_0x1288b3,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