Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / openchannelApplication / openchannelApplication.controller.js
index d03cb84..6b9d601 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0d11=['request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','squel','jsforce','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','then','destroy','stack','name','send','index','map','OpenchannelApplication','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','include','rows','catch','params','rawAttributes','includeAll','find','create','body','update','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x465a0c,_0x19d4d5){var _0x1e202e=function(_0x27bd8a){while(--_0x27bd8a){_0x465a0c['push'](_0x465a0c['shift']());}};_0x1e202e(++_0x19d4d5);}(_0x0d11,0x1a5));var _0x10d1=function(_0x2594dc,_0x33b3d0){_0x2594dc=_0x2594dc-0x0;var _0x4c4506=_0x0d11[_0x2594dc];return _0x4c4506;};'use strict';var pdf=require(_0x10d1('0x0'));var emlformat=require(_0x10d1('0x1'));var rimraf=require(_0x10d1('0x2'));var zipdir=require(_0x10d1('0x3'));var jsonpatch=require(_0x10d1('0x4'));var rp=require(_0x10d1('0x5'));var moment=require(_0x10d1('0x6'));var BPromise=require(_0x10d1('0x7'));var Mustache=require(_0x10d1('0x8'));var util=require('util');var path=require(_0x10d1('0x9'));var sox=require('sox');var csv=require(_0x10d1('0xa'));var ejs=require(_0x10d1('0xb'));var fs=require('fs');var _=require(_0x10d1('0xc'));var squel=require(_0x10d1('0xd'));var crypto=require('crypto');var jsforce=require(_0x10d1('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x10d1('0xa'));var querystring=require(_0x10d1('0xf'));var Papa=require(_0x10d1('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x10d1('0x11'));var as=require(_0x10d1('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x10d1('0x13'))(_0x10d1('0x14'));var utils=require(_0x10d1('0x15'));var config=require(_0x10d1('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xffb15c,_0x1b0d52){_0x1b0d52=_0x1b0d52||0xcc;return function(_0x192545){if(_0x192545){return _0xffb15c[_0x10d1('0x17')](_0x1b0d52);}return _0xffb15c[_0x10d1('0x18')](_0x1b0d52)[_0x10d1('0x19')]();};}function respondWithResult(_0x2a2326,_0x32f789){_0x32f789=_0x32f789||0xc8;return function(_0x46175e){if(_0x46175e){return _0x2a2326['status'](_0x32f789)[_0x10d1('0x1a')](_0x46175e);}};}function respondWithFilteredResult(_0xb7ebc8,_0x4df0e3){return function(_0x2dd2b3){if(_0x2dd2b3){var _0x36451e=_0x2dd2b3[_0x10d1('0x1b')],_0x512e9a=_0x4df0e3[_0x10d1('0x1c')],_0x52ae3b=_0x4df0e3[_0x10d1('0x1c')]+_0x4df0e3[_0x10d1('0x1d')],_0x5a60e2;if(_0x52ae3b>=_0x36451e){_0x52ae3b=_0x36451e;_0x5a60e2=0xc8;}else{_0x5a60e2=0xce;}_0xb7ebc8[_0x10d1('0x18')](_0x5a60e2);return _0xb7ebc8['set'](_0x10d1('0x1e'),_0x512e9a+'-'+_0x52ae3b+'/'+_0x36451e)['json'](_0x2dd2b3);}return null;};}function patchUpdates(_0x5ec4fe){return function(_0x2307a2){try{jsonpatch[_0x10d1('0x1f')](_0x2307a2,_0x5ec4fe,!![]);}catch(_0x9ad305){return BPromise['reject'](_0x9ad305);}return _0x2307a2['save']();};}function saveUpdates(_0x4b8284,_0x3376ef){return function(_0xf4c940){if(_0xf4c940){return _0xf4c940['update'](_0x4b8284)[_0x10d1('0x20')](function(_0x42a488){return _0x42a488;});}return null;};}function removeEntity(_0x499b1c,_0x259bdc){return function(_0x36c705){if(_0x36c705){return _0x36c705[_0x10d1('0x21')]()['then'](function(){_0x499b1c[_0x10d1('0x18')](0xcc)[_0x10d1('0x19')]();});}};}function handleEntityNotFound(_0xd93eb9,_0x285782){return function(_0x12d11a){if(!_0x12d11a){_0xd93eb9[_0x10d1('0x17')](0x194);}return _0x12d11a;};}function handleError(_0x211ec9,_0x111cb4){_0x111cb4=_0x111cb4||0x1f4;return function(_0x443f9b){logger['error'](_0x443f9b[_0x10d1('0x22')]);if(_0x443f9b[_0x10d1('0x23')]){delete _0x443f9b[_0x10d1('0x23')];}_0x211ec9[_0x10d1('0x18')](_0x111cb4)[_0x10d1('0x24')](_0x443f9b);};}exports[_0x10d1('0x25')]=function(_0x36e08e,_0x33fa7d){var _0x3df909={},_0x3e7b9b={},_0x485942={'count':0x0,'rows':[]};var _0x37060c=_[_0x10d1('0x26')](db[_0x10d1('0x27')]['rawAttributes'],function(_0x2871f4){return{'name':_0x2871f4[_0x10d1('0x28')],'type':_0x2871f4[_0x10d1('0x29')][_0x10d1('0x2a')]};});_0x3e7b9b[_0x10d1('0x2b')]=_['map'](_0x37060c,_0x10d1('0x23'));_0x3e7b9b[_0x10d1('0x2c')]=_[_0x10d1('0x2d')](_0x36e08e['query']);_0x3e7b9b[_0x10d1('0x2e')]=_[_0x10d1('0x2f')](_0x3e7b9b[_0x10d1('0x2b')],_0x3e7b9b[_0x10d1('0x2c')]);_0x3df909[_0x10d1('0x30')]=_[_0x10d1('0x2f')](_0x3e7b9b[_0x10d1('0x2b')],qs[_0x10d1('0x31')](_0x36e08e[_0x10d1('0x2c')][_0x10d1('0x31')]));_0x3df909['attributes']=_0x3df909['attributes'][_0x10d1('0x32')]?_0x3df909['attributes']:_0x3e7b9b[_0x10d1('0x2b')];if(!_0x36e08e['query'][_0x10d1('0x33')](_0x10d1('0x34'))){_0x3df909['limit']=qs[_0x10d1('0x1d')](_0x36e08e[_0x10d1('0x2c')]['limit']);_0x3df909[_0x10d1('0x1c')]=qs['offset'](_0x36e08e[_0x10d1('0x2c')]['offset']);}_0x3df909[_0x10d1('0x35')]=qs[_0x10d1('0x36')](_0x36e08e[_0x10d1('0x2c')][_0x10d1('0x36')]);_0x3df909['where']=qs[_0x10d1('0x2e')](_[_0x10d1('0x37')](_0x36e08e[_0x10d1('0x2c')],_0x3e7b9b[_0x10d1('0x2e')]),_0x37060c);if(_0x36e08e[_0x10d1('0x2c')][_0x10d1('0x38')]){_0x3df909[_0x10d1('0x39')]=_[_0x10d1('0x3a')](_0x3df909[_0x10d1('0x39')],{'$or':_[_0x10d1('0x26')](_0x37060c,function(_0x31061a){if(_0x31061a['type']!==_0x10d1('0x3b')){var _0x220cb8={};_0x220cb8[_0x31061a[_0x10d1('0x23')]]={'$like':'%'+_0x36e08e['query'][_0x10d1('0x38')]+'%'};return _0x220cb8;}})});}_0x3df909=_[_0x10d1('0x3a')]({},_0x3df909,_0x36e08e[_0x10d1('0x3c')]);var _0x454d43={'where':_0x3df909[_0x10d1('0x39')]};return db[_0x10d1('0x27')]['count'](_0x454d43)[_0x10d1('0x20')](function(_0x5b7280){_0x485942['count']=_0x5b7280;if(_0x36e08e['query']['includeAll']){_0x3df909[_0x10d1('0x3d')]=[{'all':!![]}];}return db[_0x10d1('0x27')]['findAll'](_0x3df909);})[_0x10d1('0x20')](function(_0x1b23a9){_0x485942[_0x10d1('0x3e')]=_0x1b23a9;return _0x485942;})[_0x10d1('0x20')](respondWithFilteredResult(_0x33fa7d,_0x3df909))[_0x10d1('0x3f')](handleError(_0x33fa7d,null));};exports['show']=function(_0xdff2e4,_0x2d6301){var _0x4c7db1={'raw':!![],'where':{'id':_0xdff2e4[_0x10d1('0x40')]['id']}},_0x513b14={};_0x513b14[_0x10d1('0x2b')]=_[_0x10d1('0x2d')](db[_0x10d1('0x27')][_0x10d1('0x41')]);_0x513b14['query']=_[_0x10d1('0x2d')](_0xdff2e4[_0x10d1('0x2c')]);_0x513b14[_0x10d1('0x2e')]=_['intersection'](_0x513b14[_0x10d1('0x2b')],_0x513b14[_0x10d1('0x2c')]);_0x4c7db1[_0x10d1('0x30')]=_[_0x10d1('0x2f')](_0x513b14[_0x10d1('0x2b')],qs[_0x10d1('0x31')](_0xdff2e4[_0x10d1('0x2c')]['fields']));_0x4c7db1[_0x10d1('0x30')]=_0x4c7db1[_0x10d1('0x30')][_0x10d1('0x32')]?_0x4c7db1['attributes']:_0x513b14[_0x10d1('0x2b')];if(_0xdff2e4[_0x10d1('0x2c')][_0x10d1('0x42')]){_0x4c7db1['include']=[{'all':!![]}];}_0x4c7db1=_[_0x10d1('0x3a')]({},_0x4c7db1,_0xdff2e4[_0x10d1('0x3c')]);return db[_0x10d1('0x27')][_0x10d1('0x43')](_0x4c7db1)['then'](handleEntityNotFound(_0x2d6301,null))[_0x10d1('0x20')](respondWithResult(_0x2d6301,null))[_0x10d1('0x3f')](handleError(_0x2d6301,null));};exports[_0x10d1('0x44')]=function(_0x11c41b,_0x4af690){return db[_0x10d1('0x27')]['create'](_0x11c41b[_0x10d1('0x45')],{})[_0x10d1('0x20')](respondWithResult(_0x4af690,0xc9))[_0x10d1('0x3f')](handleError(_0x4af690,null));};exports[_0x10d1('0x46')]=function(_0x9c428,_0x11b2aa){if(_0x9c428[_0x10d1('0x45')]['id']){delete _0x9c428[_0x10d1('0x45')]['id'];}return db[_0x10d1('0x27')][_0x10d1('0x43')]({'where':{'id':_0x9c428[_0x10d1('0x40')]['id']}})[_0x10d1('0x20')](handleEntityNotFound(_0x11b2aa,null))[_0x10d1('0x20')](saveUpdates(_0x9c428[_0x10d1('0x45')],null))[_0x10d1('0x20')](respondWithResult(_0x11b2aa,null))[_0x10d1('0x3f')](handleError(_0x11b2aa,null));};exports[_0x10d1('0x21')]=function(_0x5b0049,_0x53a499){return db['OpenchannelApplication']['find']({'where':{'id':_0x5b0049[_0x10d1('0x40')]['id']}})['then'](handleEntityNotFound(_0x53a499,null))[_0x10d1('0x20')](removeEntity(_0x53a499,null))[_0x10d1('0x3f')](handleError(_0x53a499,null));};
\ No newline at end of file
+var _0xf17b=['model','fields','attributes','sort','where','filters','pick','filter','merge','type','options','OpenchannelApplication','includeAll','catch','params','rawAttributes','length','include','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','offset','limit','count','set','Content-Range','reject','update','then','destroy','sendStatus','error','stack','name','send','index','map','key','query','keys','intersection'];(function(_0x38697a,_0x2af2f2){var _0x2995e3=function(_0x1a7de0){while(--_0x1a7de0){_0x38697a['push'](_0x38697a['shift']());}};_0x2995e3(++_0x2af2f2);}(_0xf17b,0x12d));var _0xbf17=function(_0x334619,_0x4d049e){_0x334619=_0x334619-0x0;var _0x174dea=_0xf17b[_0x334619];return _0x174dea;};'use strict';var emlformat=require(_0xbf17('0x0'));var rimraf=require(_0xbf17('0x1'));var zipdir=require(_0xbf17('0x2'));var jsonpatch=require(_0xbf17('0x3'));var rp=require(_0xbf17('0x4'));var moment=require(_0xbf17('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xbf17('0x6'));var path=require(_0xbf17('0x7'));var sox=require('sox');var csv=require(_0xbf17('0x8'));var ejs=require(_0xbf17('0x9'));var fs=require('fs');var fs_extra=require(_0xbf17('0xa'));var _=require(_0xbf17('0xb'));var squel=require(_0xbf17('0xc'));var crypto=require(_0xbf17('0xd'));var jsforce=require(_0xbf17('0xe'));var deskjs=require(_0xbf17('0xf'));var toCsv=require('to-csv');var querystring=require(_0xbf17('0x10'));var Papa=require(_0xbf17('0x11'));var Redis=require(_0xbf17('0x12'));var authService=require(_0xbf17('0x13'));var qs=require(_0xbf17('0x14'));var as=require(_0xbf17('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbf17('0x16'))('api');var utils=require(_0xbf17('0x17'));var config=require(_0xbf17('0x18'));var licenseUtil=require(_0xbf17('0x19'));var db=require(_0xbf17('0x1a'))['db'];function respondWithStatusCode(_0x4a06a9,_0x3e2b29){_0x3e2b29=_0x3e2b29||0xcc;return function(_0x540b37){if(_0x540b37){return _0x4a06a9['sendStatus'](_0x3e2b29);}return _0x4a06a9[_0xbf17('0x1b')](_0x3e2b29)['end']();};}function respondWithResult(_0x388cf2,_0x13bdb5){_0x13bdb5=_0x13bdb5||0xc8;return function(_0x561b65){if(_0x561b65){return _0x388cf2[_0xbf17('0x1b')](_0x13bdb5)[_0xbf17('0x1c')](_0x561b65);}};}function respondWithFilteredResult(_0x222835,_0x5ce313){return function(_0x3a3090){if(_0x3a3090){var _0x2edc60=typeof _0x5ce313[_0xbf17('0x1d')]==='undefined'&&typeof _0x5ce313[_0xbf17('0x1e')]==='undefined';var _0x1a3a1b=_0x3a3090[_0xbf17('0x1f')];var _0x55ba24=_0x2edc60?0x0:_0x5ce313['offset'];var _0x5b7591=_0x2edc60?_0x3a3090['count']:_0x5ce313['offset']+_0x5ce313[_0xbf17('0x1e')];var _0x478904;if(_0x5b7591>=_0x1a3a1b){_0x5b7591=_0x1a3a1b;_0x478904=0xc8;}else{_0x478904=0xce;}_0x222835['status'](_0x478904);return _0x222835[_0xbf17('0x20')](_0xbf17('0x21'),_0x55ba24+'-'+_0x5b7591+'/'+_0x1a3a1b)[_0xbf17('0x1c')](_0x3a3090);}return null;};}function patchUpdates(_0x3a4cb1){return function(_0x3d7dda){try{jsonpatch['apply'](_0x3d7dda,_0x3a4cb1,!![]);}catch(_0x44fa09){return BPromise[_0xbf17('0x22')](_0x44fa09);}return _0x3d7dda['save']();};}function saveUpdates(_0x26794c,_0x41196c){return function(_0x188d0c){if(_0x188d0c){return _0x188d0c[_0xbf17('0x23')](_0x26794c)[_0xbf17('0x24')](function(_0x2bb9cf){return _0x2bb9cf;});}return null;};}function removeEntity(_0x5e1b7b,_0x1691d7){return function(_0x22c097){if(_0x22c097){return _0x22c097[_0xbf17('0x25')]()['then'](function(){_0x5e1b7b[_0xbf17('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4cf845,_0x15e43f){return function(_0x135d29){if(!_0x135d29){_0x4cf845[_0xbf17('0x26')](0x194);}return _0x135d29;};}function handleError(_0x3bbd29,_0x5add7a){_0x5add7a=_0x5add7a||0x1f4;return function(_0x57614f){logger[_0xbf17('0x27')](_0x57614f[_0xbf17('0x28')]);if(_0x57614f[_0xbf17('0x29')]){delete _0x57614f[_0xbf17('0x29')];}_0x3bbd29[_0xbf17('0x1b')](_0x5add7a)[_0xbf17('0x2a')](_0x57614f);};}exports[_0xbf17('0x2b')]=function(_0x4d3146,_0x260196){var _0x16470c={},_0x514f12={},_0x5b315f={'count':0x0,'rows':[]};var _0x4f28d5=_[_0xbf17('0x2c')](db['OpenchannelApplication']['rawAttributes'],function(_0x28e219){return{'name':_0x28e219['fieldName'],'type':_0x28e219['type'][_0xbf17('0x2d')]};});_0x514f12['model']=_['map'](_0x4f28d5,_0xbf17('0x29'));_0x514f12[_0xbf17('0x2e')]=_[_0xbf17('0x2f')](_0x4d3146[_0xbf17('0x2e')]);_0x514f12['filters']=_[_0xbf17('0x30')](_0x514f12[_0xbf17('0x31')],_0x514f12[_0xbf17('0x2e')]);_0x16470c['attributes']=_['intersection'](_0x514f12[_0xbf17('0x31')],qs[_0xbf17('0x32')](_0x4d3146[_0xbf17('0x2e')]['fields']));_0x16470c[_0xbf17('0x33')]=_0x16470c['attributes']['length']?_0x16470c['attributes']:_0x514f12[_0xbf17('0x31')];if(!_0x4d3146['query']['hasOwnProperty']('nolimit')){_0x16470c[_0xbf17('0x1e')]=qs[_0xbf17('0x1e')](_0x4d3146[_0xbf17('0x2e')][_0xbf17('0x1e')]);_0x16470c[_0xbf17('0x1d')]=qs[_0xbf17('0x1d')](_0x4d3146[_0xbf17('0x2e')]['offset']);}_0x16470c['order']=qs[_0xbf17('0x34')](_0x4d3146[_0xbf17('0x2e')][_0xbf17('0x34')]);_0x16470c[_0xbf17('0x35')]=qs[_0xbf17('0x36')](_[_0xbf17('0x37')](_0x4d3146['query'],_0x514f12['filters']),_0x4f28d5);if(_0x4d3146[_0xbf17('0x2e')][_0xbf17('0x38')]){_0x16470c[_0xbf17('0x35')]=_[_0xbf17('0x39')](_0x16470c['where'],{'$or':_[_0xbf17('0x2c')](_0x4f28d5,function(_0xeb804f){if(_0xeb804f[_0xbf17('0x3a')]!=='VIRTUAL'){var _0x50c2b5={};_0x50c2b5[_0xeb804f[_0xbf17('0x29')]]={'$like':'%'+_0x4d3146['query'][_0xbf17('0x38')]+'%'};return _0x50c2b5;}})});}_0x16470c=_[_0xbf17('0x39')]({},_0x16470c,_0x4d3146[_0xbf17('0x3b')]);var _0x371e3d={'where':_0x16470c[_0xbf17('0x35')]};return db[_0xbf17('0x3c')]['count'](_0x371e3d)['then'](function(_0x2c35a8){_0x5b315f[_0xbf17('0x1f')]=_0x2c35a8;if(_0x4d3146[_0xbf17('0x2e')][_0xbf17('0x3d')]){_0x16470c['include']=[{'all':!![]}];}return db[_0xbf17('0x3c')]['findAll'](_0x16470c);})['then'](function(_0xe8f720){_0x5b315f['rows']=_0xe8f720;return _0x5b315f;})['then'](respondWithFilteredResult(_0x260196,_0x16470c))[_0xbf17('0x3e')](handleError(_0x260196,null));};exports['show']=function(_0x5b7382,_0x1cb177){var _0xba438c={'raw':!![],'where':{'id':_0x5b7382[_0xbf17('0x3f')]['id']}},_0x4520bf={};_0x4520bf[_0xbf17('0x31')]=_[_0xbf17('0x2f')](db[_0xbf17('0x3c')][_0xbf17('0x40')]);_0x4520bf['query']=_[_0xbf17('0x2f')](_0x5b7382[_0xbf17('0x2e')]);_0x4520bf[_0xbf17('0x36')]=_['intersection'](_0x4520bf[_0xbf17('0x31')],_0x4520bf[_0xbf17('0x2e')]);_0xba438c[_0xbf17('0x33')]=_[_0xbf17('0x30')](_0x4520bf['model'],qs[_0xbf17('0x32')](_0x5b7382['query'][_0xbf17('0x32')]));_0xba438c[_0xbf17('0x33')]=_0xba438c[_0xbf17('0x33')][_0xbf17('0x41')]?_0xba438c[_0xbf17('0x33')]:_0x4520bf[_0xbf17('0x31')];if(_0x5b7382[_0xbf17('0x2e')]['includeAll']){_0xba438c[_0xbf17('0x42')]=[{'all':!![]}];}_0xba438c=_[_0xbf17('0x39')]({},_0xba438c,_0x5b7382[_0xbf17('0x3b')]);return db[_0xbf17('0x3c')][_0xbf17('0x43')](_0xba438c)[_0xbf17('0x24')](handleEntityNotFound(_0x1cb177,null))[_0xbf17('0x24')](respondWithResult(_0x1cb177,null))[_0xbf17('0x3e')](handleError(_0x1cb177,null));};exports[_0xbf17('0x44')]=function(_0x42e8f0,_0x1c0fe7){return db[_0xbf17('0x3c')][_0xbf17('0x44')](_0x42e8f0[_0xbf17('0x45')],{})[_0xbf17('0x24')](respondWithResult(_0x1c0fe7,0xc9))[_0xbf17('0x3e')](handleError(_0x1c0fe7,null));};exports[_0xbf17('0x23')]=function(_0x3a6af1,_0x9c632d){if(_0x3a6af1[_0xbf17('0x45')]['id']){delete _0x3a6af1['body']['id'];}return db[_0xbf17('0x3c')][_0xbf17('0x43')]({'where':{'id':_0x3a6af1['params']['id']}})[_0xbf17('0x24')](handleEntityNotFound(_0x9c632d,null))['then'](saveUpdates(_0x3a6af1[_0xbf17('0x45')],null))[_0xbf17('0x24')](respondWithResult(_0x9c632d,null))['catch'](handleError(_0x9c632d,null));};exports[_0xbf17('0x25')]=function(_0x15b57a,_0x3b1535){return db[_0xbf17('0x3c')][_0xbf17('0x43')]({'where':{'id':_0x15b57a[_0xbf17('0x3f')]['id']}})['then'](handleEntityNotFound(_0x3b1535,null))[_0xbf17('0x24')](removeEntity(_0x3b1535,null))[_0xbf17('0x3e')](handleError(_0x3b1535,null));};
\ No newline at end of file