Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / whatsappApplication / whatsappApplication.controller.js
index 1b31caf..e26f196 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x570b=['Content-Range','apply','reject','then','destroy','stack','name','send','index','map','WhatsappApplication','fieldName','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','options','includeAll','include','rows','catch','show','params','merge','find','create','body','update','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','count','offset','limit','set'];(function(_0x4caca1,_0x2388d1){var _0x75d75c=function(_0x8fa3d1){while(--_0x8fa3d1){_0x4caca1['push'](_0x4caca1['shift']());}};_0x75d75c(++_0x2388d1);}(_0x570b,0x73));var _0xb570=function(_0x475b20,_0x8cead4){_0x475b20=_0x475b20-0x0;var _0x5c69cd=_0x570b[_0x475b20];return _0x5c69cd;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xb570('0x0'));var zipdir=require(_0xb570('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb570('0x2'));var moment=require(_0xb570('0x3'));var BPromise=require(_0xb570('0x4'));var Mustache=require(_0xb570('0x5'));var util=require(_0xb570('0x6'));var path=require(_0xb570('0x7'));var sox=require(_0xb570('0x8'));var csv=require(_0xb570('0x9'));var ejs=require(_0xb570('0xa'));var fs=require('fs');var _=require(_0xb570('0xb'));var squel=require(_0xb570('0xc'));var crypto=require(_0xb570('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xb570('0xe'));var toCsv=require('to-csv');var querystring=require(_0xb570('0xf'));var Papa=require(_0xb570('0x10'));var Redis=require(_0xb570('0x11'));var authService=require(_0xb570('0x12'));var qs=require(_0xb570('0x13'));var as=require(_0xb570('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xb570('0x15'));var utils=require(_0xb570('0x16'));var config=require(_0xb570('0x17'));var licenseUtil=require(_0xb570('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x28e44e,_0x5134d8){_0x5134d8=_0x5134d8||0xcc;return function(_0x584e03){if(_0x584e03){return _0x28e44e[_0xb570('0x19')](_0x5134d8);}return _0x28e44e['status'](_0x5134d8)[_0xb570('0x1a')]();};}function respondWithResult(_0xa9fa24,_0x1bb73d){_0x1bb73d=_0x1bb73d||0xc8;return function(_0x37918f){if(_0x37918f){return _0xa9fa24[_0xb570('0x1b')](_0x1bb73d)[_0xb570('0x1c')](_0x37918f);}};}function respondWithFilteredResult(_0x53c4b4,_0x459407){return function(_0x3e314a){if(_0x3e314a){var _0x2f19c2=_0x3e314a[_0xb570('0x1d')],_0x253334=_0x459407[_0xb570('0x1e')],_0x376def=_0x459407[_0xb570('0x1e')]+_0x459407[_0xb570('0x1f')],_0x7777e;if(_0x376def>=_0x2f19c2){_0x376def=_0x2f19c2;_0x7777e=0xc8;}else{_0x7777e=0xce;}_0x53c4b4[_0xb570('0x1b')](_0x7777e);return _0x53c4b4[_0xb570('0x20')](_0xb570('0x21'),_0x253334+'-'+_0x376def+'/'+_0x2f19c2)[_0xb570('0x1c')](_0x3e314a);}return null;};}function patchUpdates(_0x137c4f){return function(_0x200af8){try{jsonpatch[_0xb570('0x22')](_0x200af8,_0x137c4f,!![]);}catch(_0x53d72c){return BPromise[_0xb570('0x23')](_0x53d72c);}return _0x200af8['save']();};}function saveUpdates(_0x348a42,_0x41c94d){return function(_0x52e6a2){if(_0x52e6a2){return _0x52e6a2['update'](_0x348a42)[_0xb570('0x24')](function(_0x10321a){return _0x10321a;});}return null;};}function removeEntity(_0x5e15ef,_0xb0829c){return function(_0x5cc133){if(_0x5cc133){return _0x5cc133[_0xb570('0x25')]()['then'](function(){_0x5e15ef[_0xb570('0x1b')](0xcc)[_0xb570('0x1a')]();});}};}function handleEntityNotFound(_0xe7cbf7,_0x3ddb03){return function(_0x2d454a){if(!_0x2d454a){_0xe7cbf7[_0xb570('0x19')](0x194);}return _0x2d454a;};}function handleError(_0x1cab66,_0x39794b){_0x39794b=_0x39794b||0x1f4;return function(_0x5dd488){logger['error'](_0x5dd488[_0xb570('0x26')]);if(_0x5dd488[_0xb570('0x27')]){delete _0x5dd488[_0xb570('0x27')];}_0x1cab66[_0xb570('0x1b')](_0x39794b)[_0xb570('0x28')](_0x5dd488);};}exports[_0xb570('0x29')]=function(_0xd84515,_0x220df7){var _0x24fc58={},_0x39bf96={},_0x25c8fb={'count':0x0,'rows':[]};var _0x49a501=_[_0xb570('0x2a')](db[_0xb570('0x2b')]['rawAttributes'],function(_0x303993){return{'name':_0x303993[_0xb570('0x2c')],'type':_0x303993['type'][_0xb570('0x2d')]};});_0x39bf96[_0xb570('0x2e')]=_[_0xb570('0x2a')](_0x49a501,_0xb570('0x27'));_0x39bf96['query']=_[_0xb570('0x2f')](_0xd84515[_0xb570('0x30')]);_0x39bf96[_0xb570('0x31')]=_[_0xb570('0x32')](_0x39bf96[_0xb570('0x2e')],_0x39bf96[_0xb570('0x30')]);_0x24fc58[_0xb570('0x33')]=_['intersection'](_0x39bf96[_0xb570('0x2e')],qs[_0xb570('0x34')](_0xd84515[_0xb570('0x30')][_0xb570('0x34')]));_0x24fc58[_0xb570('0x33')]=_0x24fc58[_0xb570('0x33')][_0xb570('0x35')]?_0x24fc58[_0xb570('0x33')]:_0x39bf96['model'];if(!_0xd84515['query'][_0xb570('0x36')](_0xb570('0x37'))){_0x24fc58[_0xb570('0x1f')]=qs[_0xb570('0x1f')](_0xd84515[_0xb570('0x30')][_0xb570('0x1f')]);_0x24fc58[_0xb570('0x1e')]=qs[_0xb570('0x1e')](_0xd84515[_0xb570('0x30')][_0xb570('0x1e')]);}_0x24fc58[_0xb570('0x38')]=qs[_0xb570('0x39')](_0xd84515['query'][_0xb570('0x39')]);_0x24fc58[_0xb570('0x3a')]=qs['filters'](_[_0xb570('0x3b')](_0xd84515[_0xb570('0x30')],_0x39bf96[_0xb570('0x31')]),_0x49a501);if(_0xd84515[_0xb570('0x30')][_0xb570('0x3c')]){_0x24fc58['where']=_['merge'](_0x24fc58[_0xb570('0x3a')],{'$or':_['map'](_0x49a501,function(_0x146e15){if(_0x146e15[_0xb570('0x3d')]!=='VIRTUAL'){var _0x26b809={};_0x26b809[_0x146e15[_0xb570('0x27')]]={'$like':'%'+_0xd84515[_0xb570('0x30')][_0xb570('0x3c')]+'%'};return _0x26b809;}})});}_0x24fc58=_['merge']({},_0x24fc58,_0xd84515[_0xb570('0x3e')]);var _0x1224f4={'where':_0x24fc58[_0xb570('0x3a')]};return db[_0xb570('0x2b')][_0xb570('0x1d')](_0x1224f4)[_0xb570('0x24')](function(_0x1305ce){_0x25c8fb['count']=_0x1305ce;if(_0xd84515[_0xb570('0x30')][_0xb570('0x3f')]){_0x24fc58[_0xb570('0x40')]=[{'all':!![]}];}return db['WhatsappApplication']['findAll'](_0x24fc58);})['then'](function(_0x180838){_0x25c8fb[_0xb570('0x41')]=_0x180838;return _0x25c8fb;})[_0xb570('0x24')](respondWithFilteredResult(_0x220df7,_0x24fc58))[_0xb570('0x42')](handleError(_0x220df7,null));};exports[_0xb570('0x43')]=function(_0xdfd55e,_0x5b19fd){var _0xdb4145={'raw':!![],'where':{'id':_0xdfd55e[_0xb570('0x44')]['id']}},_0x308d4d={};_0x308d4d[_0xb570('0x2e')]=_[_0xb570('0x2f')](db[_0xb570('0x2b')]['rawAttributes']);_0x308d4d[_0xb570('0x30')]=_[_0xb570('0x2f')](_0xdfd55e['query']);_0x308d4d[_0xb570('0x31')]=_[_0xb570('0x32')](_0x308d4d[_0xb570('0x2e')],_0x308d4d['query']);_0xdb4145[_0xb570('0x33')]=_[_0xb570('0x32')](_0x308d4d[_0xb570('0x2e')],qs[_0xb570('0x34')](_0xdfd55e[_0xb570('0x30')][_0xb570('0x34')]));_0xdb4145[_0xb570('0x33')]=_0xdb4145[_0xb570('0x33')][_0xb570('0x35')]?_0xdb4145[_0xb570('0x33')]:_0x308d4d[_0xb570('0x2e')];if(_0xdfd55e['query'][_0xb570('0x3f')]){_0xdb4145[_0xb570('0x40')]=[{'all':!![]}];}_0xdb4145=_[_0xb570('0x45')]({},_0xdb4145,_0xdfd55e[_0xb570('0x3e')]);return db[_0xb570('0x2b')][_0xb570('0x46')](_0xdb4145)[_0xb570('0x24')](handleEntityNotFound(_0x5b19fd,null))[_0xb570('0x24')](respondWithResult(_0x5b19fd,null))['catch'](handleError(_0x5b19fd,null));};exports[_0xb570('0x47')]=function(_0x120ad9,_0x3e84ae){return db[_0xb570('0x2b')][_0xb570('0x47')](_0x120ad9[_0xb570('0x48')],{})[_0xb570('0x24')](respondWithResult(_0x3e84ae,0xc9))[_0xb570('0x42')](handleError(_0x3e84ae,null));};exports[_0xb570('0x49')]=function(_0x34a4dc,_0x55701b){if(_0x34a4dc[_0xb570('0x48')]['id']){delete _0x34a4dc[_0xb570('0x48')]['id'];}return db['WhatsappApplication'][_0xb570('0x46')]({'where':{'id':_0x34a4dc[_0xb570('0x44')]['id']}})[_0xb570('0x24')](handleEntityNotFound(_0x55701b,null))[_0xb570('0x24')](saveUpdates(_0x34a4dc[_0xb570('0x48')],null))['then'](respondWithResult(_0x55701b,null))[_0xb570('0x42')](handleError(_0x55701b,null));};exports[_0xb570('0x25')]=function(_0x572756,_0x36acd8){return db[_0xb570('0x2b')][_0xb570('0x46')]({'where':{'id':_0x572756[_0xb570('0x44')]['id']}})[_0xb570('0x24')](handleEntityNotFound(_0x36acd8,null))[_0xb570('0x24')](removeEntity(_0x36acd8,null))[_0xb570('0x42')](handleError(_0x36acd8,null));};
\ No newline at end of file
+var _0xb44a=['sort','where','pick','filter','map','type','VIRTUAL','options','rows','catch','show','params','includeAll','merge','create','body','find','destroy','zip-dir','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','error','stack','name','send','WhatsappApplication','rawAttributes','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order'];(function(_0x25b439,_0xb20872){var _0xbf2210=function(_0x518b01){while(--_0x518b01){_0x25b439['push'](_0x25b439['shift']());}};_0xbf2210(++_0xb20872);}(_0xb44a,0x1c2));var _0xab44=function(_0x39782f,_0x4aa931){_0x39782f=_0x39782f-0x0;var _0x47768c=_0xb44a[_0x39782f];return _0x47768c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xab44('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0xab44('0x1'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xab44('0x2'));var util=require('util');var path=require(_0xab44('0x3'));var sox=require(_0xab44('0x4'));var csv=require(_0xab44('0x5'));var ejs=require(_0xab44('0x6'));var fs=require('fs');var fs_extra=require(_0xab44('0x7'));var _=require(_0xab44('0x8'));var squel=require(_0xab44('0x9'));var crypto=require(_0xab44('0xa'));var jsforce=require(_0xab44('0xb'));var deskjs=require(_0xab44('0xc'));var toCsv=require(_0xab44('0x5'));var querystring=require(_0xab44('0xd'));var Papa=require(_0xab44('0xe'));var Redis=require('ioredis');var authService=require(_0xab44('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xab44('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xab44('0x11'));var utils=require(_0xab44('0x12'));var config=require(_0xab44('0x13'));var licenseUtil=require(_0xab44('0x14'));var db=require(_0xab44('0x15'))['db'];function respondWithStatusCode(_0x237c26,_0x52d282){_0x52d282=_0x52d282||0xcc;return function(_0x57fcff){if(_0x57fcff){return _0x237c26[_0xab44('0x16')](_0x52d282);}return _0x237c26['status'](_0x52d282)[_0xab44('0x17')]();};}function respondWithResult(_0x5ae369,_0x25f611){_0x25f611=_0x25f611||0xc8;return function(_0x15b98a){if(_0x15b98a){return _0x5ae369[_0xab44('0x18')](_0x25f611)[_0xab44('0x19')](_0x15b98a);}};}function respondWithFilteredResult(_0x31404d,_0x41701b){return function(_0x4875df){if(_0x4875df){var _0x51251b=typeof _0x41701b[_0xab44('0x1a')]===_0xab44('0x1b')&&typeof _0x41701b[_0xab44('0x1c')]===_0xab44('0x1b');var _0xffdfbc=_0x4875df[_0xab44('0x1d')];var _0x354b09=_0x51251b?0x0:_0x41701b[_0xab44('0x1a')];var _0x310b15=_0x51251b?_0x4875df[_0xab44('0x1d')]:_0x41701b[_0xab44('0x1a')]+_0x41701b['limit'];var _0xb779bb;if(_0x310b15>=_0xffdfbc){_0x310b15=_0xffdfbc;_0xb779bb=0xc8;}else{_0xb779bb=0xce;}_0x31404d[_0xab44('0x18')](_0xb779bb);return _0x31404d[_0xab44('0x1e')](_0xab44('0x1f'),_0x354b09+'-'+_0x310b15+'/'+_0xffdfbc)[_0xab44('0x19')](_0x4875df);}return null;};}function patchUpdates(_0x5123b1){return function(_0xcd426){try{jsonpatch['apply'](_0xcd426,_0x5123b1,!![]);}catch(_0x1f7311){return BPromise[_0xab44('0x20')](_0x1f7311);}return _0xcd426[_0xab44('0x21')]();};}function saveUpdates(_0x355083,_0x486317){return function(_0x3a2b1d){if(_0x3a2b1d){return _0x3a2b1d[_0xab44('0x22')](_0x355083)[_0xab44('0x23')](function(_0x3b17d5){return _0x3b17d5;});}return null;};}function removeEntity(_0x11f0b,_0x402950){return function(_0x43f1c6){if(_0x43f1c6){return _0x43f1c6['destroy']()['then'](function(){_0x11f0b[_0xab44('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2439f3,_0x5a7269){return function(_0x2a1bbc){if(!_0x2a1bbc){_0x2439f3['sendStatus'](0x194);}return _0x2a1bbc;};}function handleError(_0x531583,_0x8e60fa){_0x8e60fa=_0x8e60fa||0x1f4;return function(_0x25287b){logger[_0xab44('0x24')](_0x25287b[_0xab44('0x25')]);if(_0x25287b[_0xab44('0x26')]){delete _0x25287b['name'];}_0x531583[_0xab44('0x18')](_0x8e60fa)[_0xab44('0x27')](_0x25287b);};}exports['index']=function(_0x887b0d,_0xebb7d1){var _0x21131e={},_0x1cd486={},_0x4550c8={'count':0x0,'rows':[]};var _0xdc50a1=_['map'](db[_0xab44('0x28')][_0xab44('0x29')],function(_0x36f9b6){return{'name':_0x36f9b6['fieldName'],'type':_0x36f9b6['type'][_0xab44('0x2a')]};});_0x1cd486['model']=_['map'](_0xdc50a1,_0xab44('0x26'));_0x1cd486[_0xab44('0x2b')]=_[_0xab44('0x2c')](_0x887b0d[_0xab44('0x2b')]);_0x1cd486[_0xab44('0x2d')]=_[_0xab44('0x2e')](_0x1cd486[_0xab44('0x2f')],_0x1cd486[_0xab44('0x2b')]);_0x21131e[_0xab44('0x30')]=_[_0xab44('0x2e')](_0x1cd486[_0xab44('0x2f')],qs[_0xab44('0x31')](_0x887b0d[_0xab44('0x2b')][_0xab44('0x31')]));_0x21131e['attributes']=_0x21131e['attributes'][_0xab44('0x32')]?_0x21131e[_0xab44('0x30')]:_0x1cd486['model'];if(!_0x887b0d[_0xab44('0x2b')][_0xab44('0x33')](_0xab44('0x34'))){_0x21131e[_0xab44('0x1c')]=qs[_0xab44('0x1c')](_0x887b0d[_0xab44('0x2b')][_0xab44('0x1c')]);_0x21131e[_0xab44('0x1a')]=qs[_0xab44('0x1a')](_0x887b0d[_0xab44('0x2b')][_0xab44('0x1a')]);}_0x21131e[_0xab44('0x35')]=qs[_0xab44('0x36')](_0x887b0d[_0xab44('0x2b')][_0xab44('0x36')]);_0x21131e[_0xab44('0x37')]=qs[_0xab44('0x2d')](_[_0xab44('0x38')](_0x887b0d['query'],_0x1cd486[_0xab44('0x2d')]),_0xdc50a1);if(_0x887b0d[_0xab44('0x2b')][_0xab44('0x39')]){_0x21131e[_0xab44('0x37')]=_['merge'](_0x21131e[_0xab44('0x37')],{'$or':_[_0xab44('0x3a')](_0xdc50a1,function(_0xcd077a){if(_0xcd077a[_0xab44('0x3b')]!==_0xab44('0x3c')){var _0x4f5cf3={};_0x4f5cf3[_0xcd077a[_0xab44('0x26')]]={'$like':'%'+_0x887b0d[_0xab44('0x2b')][_0xab44('0x39')]+'%'};return _0x4f5cf3;}})});}_0x21131e=_['merge']({},_0x21131e,_0x887b0d[_0xab44('0x3d')]);var _0x1e26de={'where':_0x21131e[_0xab44('0x37')]};return db[_0xab44('0x28')][_0xab44('0x1d')](_0x1e26de)['then'](function(_0x1de52d){_0x4550c8['count']=_0x1de52d;if(_0x887b0d[_0xab44('0x2b')]['includeAll']){_0x21131e['include']=[{'all':!![]}];}return db['WhatsappApplication']['findAll'](_0x21131e);})['then'](function(_0x120585){_0x4550c8[_0xab44('0x3e')]=_0x120585;return _0x4550c8;})[_0xab44('0x23')](respondWithFilteredResult(_0xebb7d1,_0x21131e))[_0xab44('0x3f')](handleError(_0xebb7d1,null));};exports[_0xab44('0x40')]=function(_0xf3f37a,_0x19d20d){var _0x33641e={'raw':!![],'where':{'id':_0xf3f37a[_0xab44('0x41')]['id']}},_0x4429e6={};_0x4429e6['model']=_[_0xab44('0x2c')](db[_0xab44('0x28')][_0xab44('0x29')]);_0x4429e6[_0xab44('0x2b')]=_['keys'](_0xf3f37a[_0xab44('0x2b')]);_0x4429e6[_0xab44('0x2d')]=_[_0xab44('0x2e')](_0x4429e6[_0xab44('0x2f')],_0x4429e6[_0xab44('0x2b')]);_0x33641e[_0xab44('0x30')]=_['intersection'](_0x4429e6['model'],qs[_0xab44('0x31')](_0xf3f37a[_0xab44('0x2b')][_0xab44('0x31')]));_0x33641e[_0xab44('0x30')]=_0x33641e[_0xab44('0x30')]['length']?_0x33641e[_0xab44('0x30')]:_0x4429e6[_0xab44('0x2f')];if(_0xf3f37a[_0xab44('0x2b')][_0xab44('0x42')]){_0x33641e['include']=[{'all':!![]}];}_0x33641e=_[_0xab44('0x43')]({},_0x33641e,_0xf3f37a[_0xab44('0x3d')]);return db[_0xab44('0x28')]['find'](_0x33641e)[_0xab44('0x23')](handleEntityNotFound(_0x19d20d,null))[_0xab44('0x23')](respondWithResult(_0x19d20d,null))[_0xab44('0x3f')](handleError(_0x19d20d,null));};exports[_0xab44('0x44')]=function(_0x4eeb65,_0x13892d){return db['WhatsappApplication'][_0xab44('0x44')](_0x4eeb65[_0xab44('0x45')],{})[_0xab44('0x23')](respondWithResult(_0x13892d,0xc9))[_0xab44('0x3f')](handleError(_0x13892d,null));};exports['update']=function(_0x328891,_0x5497a3){if(_0x328891[_0xab44('0x45')]['id']){delete _0x328891[_0xab44('0x45')]['id'];}return db[_0xab44('0x28')][_0xab44('0x46')]({'where':{'id':_0x328891[_0xab44('0x41')]['id']}})['then'](handleEntityNotFound(_0x5497a3,null))[_0xab44('0x23')](saveUpdates(_0x328891['body'],null))[_0xab44('0x23')](respondWithResult(_0x5497a3,null))[_0xab44('0x3f')](handleError(_0x5497a3,null));};exports[_0xab44('0x47')]=function(_0x50b705,_0x4463f1){return db[_0xab44('0x28')][_0xab44('0x46')]({'where':{'id':_0x50b705[_0xab44('0x41')]['id']}})[_0xab44('0x23')](handleEntityNotFound(_0x4463f1,null))['then'](removeEntity(_0x4463f1,null))['catch'](handleError(_0x4463f1,null));};
\ No newline at end of file