Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / openchannelApplication / openchannelApplication.controller.js
index 885463c..6b9d601 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb68a=['merge','VIRTUAL','options','includeAll','findAll','rows','show','params','rawAttributes','include','catch','create','body','find','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../mysqldb','status','json','count','offset','limit','set','save','update','then','destroy','end','stack','name','index','map','OpenchannelApplication','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xb68a,0x19a));var _0xab68=function(_0x6c6d75,_0xef7deb){_0x6c6d75=_0x6c6d75-0x0;var _0x48a161=_0xb68a[_0x6c6d75];return _0x48a161;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xab68('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0xab68('0x1'));var moment=require(_0xab68('0x2'));var BPromise=require('bluebird');var Mustache=require(_0xab68('0x3'));var util=require(_0xab68('0x4'));var path=require(_0xab68('0x5'));var sox=require(_0xab68('0x6'));var csv=require(_0xab68('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xab68('0x8'));var squel=require('squel');var crypto=require(_0xab68('0x9'));var jsforce=require(_0xab68('0xa'));var deskjs=require(_0xab68('0xb'));var toCsv=require(_0xab68('0x7'));var querystring=require(_0xab68('0xc'));var Papa=require(_0xab68('0xd'));var Redis=require(_0xab68('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xab68('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xab68('0x10'));var logger=require(_0xab68('0x11'))(_0xab68('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xab68('0x13'))['db'];function respondWithStatusCode(_0x28544a,_0x5a0ded){_0x5a0ded=_0x5a0ded||0xcc;return function(_0x29e570){if(_0x29e570){return _0x28544a['sendStatus'](_0x5a0ded);}return _0x28544a['status'](_0x5a0ded)['end']();};}function respondWithResult(_0x58129f,_0x2d5b2f){_0x2d5b2f=_0x2d5b2f||0xc8;return function(_0x4df28e){if(_0x4df28e){return _0x58129f[_0xab68('0x14')](_0x2d5b2f)[_0xab68('0x15')](_0x4df28e);}};}function respondWithFilteredResult(_0x28f0df,_0x209000){return function(_0x372742){if(_0x372742){var _0x206d39=_0x372742[_0xab68('0x16')],_0x1d1c4f=_0x209000[_0xab68('0x17')],_0x2849fb=_0x209000[_0xab68('0x17')]+_0x209000[_0xab68('0x18')],_0x337a20;if(_0x2849fb>=_0x206d39){_0x2849fb=_0x206d39;_0x337a20=0xc8;}else{_0x337a20=0xce;}_0x28f0df[_0xab68('0x14')](_0x337a20);return _0x28f0df[_0xab68('0x19')]('Content-Range',_0x1d1c4f+'-'+_0x2849fb+'/'+_0x206d39)['json'](_0x372742);}return null;};}function patchUpdates(_0x3118c9){return function(_0x462316){try{jsonpatch['apply'](_0x462316,_0x3118c9,!![]);}catch(_0x94593){return BPromise['reject'](_0x94593);}return _0x462316[_0xab68('0x1a')]();};}function saveUpdates(_0x1822a4,_0x3d70cf){return function(_0x2b807a){if(_0x2b807a){return _0x2b807a[_0xab68('0x1b')](_0x1822a4)[_0xab68('0x1c')](function(_0x193b34){return _0x193b34;});}return null;};}function removeEntity(_0x2b79b5,_0xa55dd2){return function(_0x22318c){if(_0x22318c){return _0x22318c[_0xab68('0x1d')]()[_0xab68('0x1c')](function(){_0x2b79b5[_0xab68('0x14')](0xcc)[_0xab68('0x1e')]();});}};}function handleEntityNotFound(_0x54db07,_0x38f284){return function(_0x44a011){if(!_0x44a011){_0x54db07['sendStatus'](0x194);}return _0x44a011;};}function handleError(_0x107a71,_0x54ff15){_0x54ff15=_0x54ff15||0x1f4;return function(_0x2363ed){logger['error'](_0x2363ed[_0xab68('0x1f')]);if(_0x2363ed['name']){delete _0x2363ed[_0xab68('0x20')];}_0x107a71[_0xab68('0x14')](_0x54ff15)['send'](_0x2363ed);};}exports[_0xab68('0x21')]=function(_0x405592,_0x389ba4){var _0x8943a7={},_0x5df321={},_0x345893={'count':0x0,'rows':[]};var _0x6c8269=_[_0xab68('0x22')](db[_0xab68('0x23')]['rawAttributes'],function(_0x806c73){return{'name':_0x806c73['fieldName'],'type':_0x806c73['type'][_0xab68('0x24')]};});_0x5df321[_0xab68('0x25')]=_[_0xab68('0x22')](_0x6c8269,_0xab68('0x20'));_0x5df321[_0xab68('0x26')]=_[_0xab68('0x27')](_0x405592[_0xab68('0x26')]);_0x5df321[_0xab68('0x28')]=_[_0xab68('0x29')](_0x5df321['model'],_0x5df321[_0xab68('0x26')]);_0x8943a7[_0xab68('0x2a')]=_[_0xab68('0x29')](_0x5df321['model'],qs[_0xab68('0x2b')](_0x405592['query']['fields']));_0x8943a7[_0xab68('0x2a')]=_0x8943a7[_0xab68('0x2a')][_0xab68('0x2c')]?_0x8943a7[_0xab68('0x2a')]:_0x5df321[_0xab68('0x25')];if(!_0x405592[_0xab68('0x26')][_0xab68('0x2d')](_0xab68('0x2e'))){_0x8943a7[_0xab68('0x18')]=qs[_0xab68('0x18')](_0x405592[_0xab68('0x26')][_0xab68('0x18')]);_0x8943a7['offset']=qs['offset'](_0x405592[_0xab68('0x26')][_0xab68('0x17')]);}_0x8943a7[_0xab68('0x2f')]=qs[_0xab68('0x30')](_0x405592['query'][_0xab68('0x30')]);_0x8943a7[_0xab68('0x31')]=qs[_0xab68('0x28')](_[_0xab68('0x32')](_0x405592['query'],_0x5df321[_0xab68('0x28')]),_0x6c8269);if(_0x405592[_0xab68('0x26')][_0xab68('0x33')]){_0x8943a7[_0xab68('0x31')]=_[_0xab68('0x34')](_0x8943a7[_0xab68('0x31')],{'$or':_['map'](_0x6c8269,function(_0x46f81d){if(_0x46f81d['type']!==_0xab68('0x35')){var _0x41f54f={};_0x41f54f[_0x46f81d['name']]={'$like':'%'+_0x405592[_0xab68('0x26')][_0xab68('0x33')]+'%'};return _0x41f54f;}})});}_0x8943a7=_[_0xab68('0x34')]({},_0x8943a7,_0x405592[_0xab68('0x36')]);var _0x51d51d={'where':_0x8943a7[_0xab68('0x31')]};return db[_0xab68('0x23')]['count'](_0x51d51d)[_0xab68('0x1c')](function(_0xbdf88){_0x345893['count']=_0xbdf88;if(_0x405592[_0xab68('0x26')][_0xab68('0x37')]){_0x8943a7['include']=[{'all':!![]}];}return db[_0xab68('0x23')][_0xab68('0x38')](_0x8943a7);})[_0xab68('0x1c')](function(_0x8b893b){_0x345893[_0xab68('0x39')]=_0x8b893b;return _0x345893;})[_0xab68('0x1c')](respondWithFilteredResult(_0x389ba4,_0x8943a7))['catch'](handleError(_0x389ba4,null));};exports[_0xab68('0x3a')]=function(_0x243352,_0xbe2804){var _0x66ffb6={'raw':!![],'where':{'id':_0x243352[_0xab68('0x3b')]['id']}},_0x5d27a6={};_0x5d27a6[_0xab68('0x25')]=_[_0xab68('0x27')](db[_0xab68('0x23')][_0xab68('0x3c')]);_0x5d27a6[_0xab68('0x26')]=_[_0xab68('0x27')](_0x243352[_0xab68('0x26')]);_0x5d27a6[_0xab68('0x28')]=_[_0xab68('0x29')](_0x5d27a6[_0xab68('0x25')],_0x5d27a6[_0xab68('0x26')]);_0x66ffb6[_0xab68('0x2a')]=_[_0xab68('0x29')](_0x5d27a6[_0xab68('0x25')],qs['fields'](_0x243352['query'][_0xab68('0x2b')]));_0x66ffb6[_0xab68('0x2a')]=_0x66ffb6['attributes'][_0xab68('0x2c')]?_0x66ffb6[_0xab68('0x2a')]:_0x5d27a6[_0xab68('0x25')];if(_0x243352[_0xab68('0x26')][_0xab68('0x37')]){_0x66ffb6[_0xab68('0x3d')]=[{'all':!![]}];}_0x66ffb6=_[_0xab68('0x34')]({},_0x66ffb6,_0x243352[_0xab68('0x36')]);return db['OpenchannelApplication']['find'](_0x66ffb6)['then'](handleEntityNotFound(_0xbe2804,null))[_0xab68('0x1c')](respondWithResult(_0xbe2804,null))[_0xab68('0x3e')](handleError(_0xbe2804,null));};exports['create']=function(_0xa1b73,_0x548f48){return db[_0xab68('0x23')][_0xab68('0x3f')](_0xa1b73[_0xab68('0x40')],{})[_0xab68('0x1c')](respondWithResult(_0x548f48,0xc9))['catch'](handleError(_0x548f48,null));};exports[_0xab68('0x1b')]=function(_0x50c066,_0x2ac185){if(_0x50c066['body']['id']){delete _0x50c066[_0xab68('0x40')]['id'];}return db[_0xab68('0x23')][_0xab68('0x41')]({'where':{'id':_0x50c066[_0xab68('0x3b')]['id']}})[_0xab68('0x1c')](handleEntityNotFound(_0x2ac185,null))['then'](saveUpdates(_0x50c066[_0xab68('0x40')],null))[_0xab68('0x1c')](respondWithResult(_0x2ac185,null))['catch'](handleError(_0x2ac185,null));};exports[_0xab68('0x1d')]=function(_0x328d92,_0x243d0c){return db[_0xab68('0x23')][_0xab68('0x41')]({'where':{'id':_0x328d92[_0xab68('0x3b')]['id']}})['then'](handleEntityNotFound(_0x243d0c,null))[_0xab68('0x1c')](removeEntity(_0x243d0c,null))[_0xab68('0x3e')](handleError(_0x243d0c,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