Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / openchannelApplication / openchannelApplication.controller.js
index 3b28538..6b9d601 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe8b0=['OpenchannelApplication','fieldName','model','query','keys','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','includeAll','include','rows','catch','show','params','rawAttributes','length','find','create','body','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','name','index','map'];(function(_0x4939c2,_0x5383b1){var _0x5508c7=function(_0x45a511){while(--_0x45a511){_0x4939c2['push'](_0x4939c2['shift']());}};_0x5508c7(++_0x5383b1);}(_0xe8b0,0x1b6));var _0x0e8b=function(_0x58b9f9,_0x3046b6){_0x58b9f9=_0x58b9f9-0x0;var _0x146adc=_0xe8b0[_0x58b9f9];return _0x146adc;};'use strict';var pdf=require(_0x0e8b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x0e8b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0e8b('0x2'));var rp=require(_0x0e8b('0x3'));var moment=require(_0x0e8b('0x4'));var BPromise=require(_0x0e8b('0x5'));var Mustache=require(_0x0e8b('0x6'));var util=require('util');var path=require(_0x0e8b('0x7'));var sox=require('sox');var csv=require(_0x0e8b('0x8'));var ejs=require(_0x0e8b('0x9'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0e8b('0xa'));var toCsv=require(_0x0e8b('0x8'));var querystring=require('querystring');var Papa=require(_0x0e8b('0xb'));var Redis=require('ioredis');var authService=require(_0x0e8b('0xc'));var qs=require(_0x0e8b('0xd'));var as=require(_0x0e8b('0xe'));var hardwareService=require(_0x0e8b('0xf'));var logger=require(_0x0e8b('0x10'))(_0x0e8b('0x11'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0e8b('0x12'));var db=require(_0x0e8b('0x13'))['db'];function respondWithStatusCode(_0x4e589a,_0x2605f4){_0x2605f4=_0x2605f4||0xcc;return function(_0x12188){if(_0x12188){return _0x4e589a[_0x0e8b('0x14')](_0x2605f4);}return _0x4e589a[_0x0e8b('0x15')](_0x2605f4)['end']();};}function respondWithResult(_0x1ffd64,_0x11c4e1){_0x11c4e1=_0x11c4e1||0xc8;return function(_0x5e591a){if(_0x5e591a){return _0x1ffd64[_0x0e8b('0x15')](_0x11c4e1)[_0x0e8b('0x16')](_0x5e591a);}};}function respondWithFilteredResult(_0x1cc879,_0x324e79){return function(_0x2f0744){if(_0x2f0744){var _0x1c5d97=_0x2f0744[_0x0e8b('0x17')],_0x37397e=_0x324e79[_0x0e8b('0x18')],_0x295e24=_0x324e79[_0x0e8b('0x18')]+_0x324e79[_0x0e8b('0x19')],_0x46fde1;if(_0x295e24>=_0x1c5d97){_0x295e24=_0x1c5d97;_0x46fde1=0xc8;}else{_0x46fde1=0xce;}_0x1cc879[_0x0e8b('0x15')](_0x46fde1);return _0x1cc879[_0x0e8b('0x1a')](_0x0e8b('0x1b'),_0x37397e+'-'+_0x295e24+'/'+_0x1c5d97)['json'](_0x2f0744);}return null;};}function patchUpdates(_0x69a5ea){return function(_0xb90946){try{jsonpatch[_0x0e8b('0x1c')](_0xb90946,_0x69a5ea,!![]);}catch(_0x3a0342){return BPromise[_0x0e8b('0x1d')](_0x3a0342);}return _0xb90946[_0x0e8b('0x1e')]();};}function saveUpdates(_0x5c6842,_0x4cc105){return function(_0x12c70e){if(_0x12c70e){return _0x12c70e[_0x0e8b('0x1f')](_0x5c6842)[_0x0e8b('0x20')](function(_0x2f7f72){return _0x2f7f72;});}return null;};}function removeEntity(_0x58c4ea,_0x4faa8b){return function(_0x4d6e2a){if(_0x4d6e2a){return _0x4d6e2a[_0x0e8b('0x21')]()['then'](function(){_0x58c4ea['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x865801,_0x53f2cd){return function(_0x3375e5){if(!_0x3375e5){_0x865801[_0x0e8b('0x14')](0x194);}return _0x3375e5;};}function handleError(_0x5dda09,_0x3a3f18){_0x3a3f18=_0x3a3f18||0x1f4;return function(_0x314ff0){logger[_0x0e8b('0x22')](_0x314ff0['stack']);if(_0x314ff0[_0x0e8b('0x23')]){delete _0x314ff0['name'];}_0x5dda09[_0x0e8b('0x15')](_0x3a3f18)['send'](_0x314ff0);};}exports[_0x0e8b('0x24')]=function(_0x450aff,_0x291c06){var _0x276192={},_0x1b4579={},_0x1dd1b6={'count':0x0,'rows':[]};var _0x392788=_[_0x0e8b('0x25')](db[_0x0e8b('0x26')]['rawAttributes'],function(_0x33f8d6){return{'name':_0x33f8d6[_0x0e8b('0x27')],'type':_0x33f8d6['type']['key']};});_0x1b4579[_0x0e8b('0x28')]=_[_0x0e8b('0x25')](_0x392788,'name');_0x1b4579[_0x0e8b('0x29')]=_[_0x0e8b('0x2a')](_0x450aff[_0x0e8b('0x29')]);_0x1b4579['filters']=_['intersection'](_0x1b4579[_0x0e8b('0x28')],_0x1b4579['query']);_0x276192[_0x0e8b('0x2b')]=_[_0x0e8b('0x2c')](_0x1b4579[_0x0e8b('0x28')],qs[_0x0e8b('0x2d')](_0x450aff[_0x0e8b('0x29')][_0x0e8b('0x2d')]));_0x276192['attributes']=_0x276192['attributes']['length']?_0x276192[_0x0e8b('0x2b')]:_0x1b4579[_0x0e8b('0x28')];if(!_0x450aff['query'][_0x0e8b('0x2e')](_0x0e8b('0x2f'))){_0x276192[_0x0e8b('0x19')]=qs[_0x0e8b('0x19')](_0x450aff[_0x0e8b('0x29')][_0x0e8b('0x19')]);_0x276192['offset']=qs[_0x0e8b('0x18')](_0x450aff[_0x0e8b('0x29')]['offset']);}_0x276192[_0x0e8b('0x30')]=qs[_0x0e8b('0x31')](_0x450aff[_0x0e8b('0x29')][_0x0e8b('0x31')]);_0x276192[_0x0e8b('0x32')]=qs[_0x0e8b('0x33')](_[_0x0e8b('0x34')](_0x450aff['query'],_0x1b4579[_0x0e8b('0x33')]),_0x392788);if(_0x450aff[_0x0e8b('0x29')]['filter']){_0x276192[_0x0e8b('0x32')]=_[_0x0e8b('0x35')](_0x276192[_0x0e8b('0x32')],{'$or':_['map'](_0x392788,function(_0x57c158){if(_0x57c158['type']!==_0x0e8b('0x36')){var _0x429e88={};_0x429e88[_0x57c158[_0x0e8b('0x23')]]={'$like':'%'+_0x450aff[_0x0e8b('0x29')][_0x0e8b('0x37')]+'%'};return _0x429e88;}})});}_0x276192=_['merge']({},_0x276192,_0x450aff[_0x0e8b('0x38')]);var _0x5f3eb8={'where':_0x276192['where']};return db[_0x0e8b('0x26')][_0x0e8b('0x17')](_0x5f3eb8)['then'](function(_0x140fe7){_0x1dd1b6['count']=_0x140fe7;if(_0x450aff[_0x0e8b('0x29')][_0x0e8b('0x39')]){_0x276192[_0x0e8b('0x3a')]=[{'all':!![]}];}return db[_0x0e8b('0x26')]['findAll'](_0x276192);})[_0x0e8b('0x20')](function(_0x5b89ba){_0x1dd1b6[_0x0e8b('0x3b')]=_0x5b89ba;return _0x1dd1b6;})[_0x0e8b('0x20')](respondWithFilteredResult(_0x291c06,_0x276192))[_0x0e8b('0x3c')](handleError(_0x291c06,null));};exports[_0x0e8b('0x3d')]=function(_0x3b8d7a,_0x4f5505){var _0x44388a={'raw':!![],'where':{'id':_0x3b8d7a[_0x0e8b('0x3e')]['id']}},_0x3c4155={};_0x3c4155[_0x0e8b('0x28')]=_[_0x0e8b('0x2a')](db[_0x0e8b('0x26')][_0x0e8b('0x3f')]);_0x3c4155[_0x0e8b('0x29')]=_[_0x0e8b('0x2a')](_0x3b8d7a[_0x0e8b('0x29')]);_0x3c4155['filters']=_['intersection'](_0x3c4155['model'],_0x3c4155[_0x0e8b('0x29')]);_0x44388a[_0x0e8b('0x2b')]=_[_0x0e8b('0x2c')](_0x3c4155['model'],qs[_0x0e8b('0x2d')](_0x3b8d7a['query'][_0x0e8b('0x2d')]));_0x44388a[_0x0e8b('0x2b')]=_0x44388a[_0x0e8b('0x2b')][_0x0e8b('0x40')]?_0x44388a[_0x0e8b('0x2b')]:_0x3c4155[_0x0e8b('0x28')];if(_0x3b8d7a[_0x0e8b('0x29')][_0x0e8b('0x39')]){_0x44388a[_0x0e8b('0x3a')]=[{'all':!![]}];}_0x44388a=_[_0x0e8b('0x35')]({},_0x44388a,_0x3b8d7a[_0x0e8b('0x38')]);return db[_0x0e8b('0x26')][_0x0e8b('0x41')](_0x44388a)['then'](handleEntityNotFound(_0x4f5505,null))[_0x0e8b('0x20')](respondWithResult(_0x4f5505,null))[_0x0e8b('0x3c')](handleError(_0x4f5505,null));};exports[_0x0e8b('0x42')]=function(_0x3af372,_0x60ed14){return db['OpenchannelApplication'][_0x0e8b('0x42')](_0x3af372[_0x0e8b('0x43')],{})[_0x0e8b('0x20')](respondWithResult(_0x60ed14,0xc9))[_0x0e8b('0x3c')](handleError(_0x60ed14,null));};exports[_0x0e8b('0x1f')]=function(_0x545600,_0x460848){if(_0x545600['body']['id']){delete _0x545600[_0x0e8b('0x43')]['id'];}return db[_0x0e8b('0x26')][_0x0e8b('0x41')]({'where':{'id':_0x545600[_0x0e8b('0x3e')]['id']}})[_0x0e8b('0x20')](handleEntityNotFound(_0x460848,null))[_0x0e8b('0x20')](saveUpdates(_0x545600['body'],null))[_0x0e8b('0x20')](respondWithResult(_0x460848,null))[_0x0e8b('0x3c')](handleError(_0x460848,null));};exports[_0x0e8b('0x21')]=function(_0x2df63b,_0xb9d22a){return db['OpenchannelApplication'][_0x0e8b('0x41')]({'where':{'id':_0x2df63b[_0x0e8b('0x3e')]['id']}})[_0x0e8b('0x20')](handleEntityNotFound(_0xb9d22a,null))[_0x0e8b('0x20')](removeEntity(_0xb9d22a,null))['catch'](handleError(_0xb9d22a,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