Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / plugin / plugin.controller.js
index cfad10a..84a3063 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0c4c=['Plugin','fieldName','type','key','model','map','keys','query','filters','attributes','fields','length','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','intersection','find','path','join','root','server/files/plugins','format','%s.zip','createWriteStream','zip','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','glob','**/*','dirname','basename','node_modules/**/*','attachments/**/*','finalize','close','existsSync','download','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','Download\x20completed','info','Temporary\x20file\x20removed','upload','filename','extname','file','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','Invalid\x20plugin\x20structure','readdirSync','some','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','Invalid\x20manifest:\x20version\x20not\x20specified','parameters','Invalid\x20manifest:\x20parameters\x20missing','html','views','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','Invalid\x20manifest:\x20invalid\x20type','sidebar','always','icon','icon-apps','admin','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','scriptName','scriptPath','create','body','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','UserProfileResource','send','Zip\x20archive\x20removed','delete','destroy','webhookGet','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','method','headers','content-length','content-type','statusCode','sendStatus','webhookPost','%s%s','eml-format','zip-dir','request-promise','moment','bluebird','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','papaparse','extract-zip','rimraf','archiver','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./plugin.socket','register','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','get','Plugins','error','stack','name','index'];(function(_0x28690e,_0x20a6ae){var _0xc6d99=function(_0x46cbb0){while(--_0x46cbb0){_0x28690e['push'](_0x28690e['shift']());}};_0xc6d99(++_0x20a6ae);}(_0x0c4c,0x12e));var _0xc0c4=function(_0x75a182,_0xf96dfc){_0x75a182=_0x75a182-0x0;var _0x419689=_0x0c4c[_0x75a182];return _0x419689;};'use strict';var emlformat=require(_0xc0c4('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc0c4('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc0c4('0x2'));var moment=require(_0xc0c4('0x3'));var BPromise=require(_0xc0c4('0x4'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xc0c4('0x5'));var csv=require(_0xc0c4('0x6'));var ejs=require(_0xc0c4('0x7'));var fs=require('fs');var fs_extra=require(_0xc0c4('0x8'));var _=require('lodash');var squel=require(_0xc0c4('0x9'));var crypto=require(_0xc0c4('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xc0c4('0xb'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xc0c4('0xc'));var extract=require(_0xc0c4('0xd'));var rimraf=require(_0xc0c4('0xe'));var archiver=require(_0xc0c4('0xf'));var Redis=require(_0xc0c4('0x10'));var authService=require(_0xc0c4('0x11'));var qs=require(_0xc0c4('0x12'));var as=require(_0xc0c4('0x13'));var hardwareService=require(_0xc0c4('0x14'));var logger=require('../../config/logger')(_0xc0c4('0x15'));var utils=require('../../config/utils');var config=require(_0xc0c4('0x16'));var licenseUtil=require(_0xc0c4('0x17'));var db=require(_0xc0c4('0x18'))['db'];config[_0xc0c4('0x19')]=_['defaults'](config['redis'],{'host':_0xc0c4('0x1a'),'port':0x18eb});var socket=require(_0xc0c4('0x1b'))(new Redis(config['redis']));require(_0xc0c4('0x1c'))[_0xc0c4('0x1d')](socket);function respondWithStatusCode(_0x203cd7,_0x27ca90){_0x27ca90=_0x27ca90||0xcc;return function(_0x32edc8){if(_0x32edc8){return _0x203cd7['sendStatus'](_0x27ca90);}return _0x203cd7[_0xc0c4('0x1e')](_0x27ca90)[_0xc0c4('0x1f')]();};}function respondWithResult(_0x5eb665,_0x11dde1){_0x11dde1=_0x11dde1||0xc8;return function(_0x452f2d){if(_0x452f2d){return _0x5eb665[_0xc0c4('0x1e')](_0x11dde1)[_0xc0c4('0x20')](_0x452f2d);}};}function respondWithFilteredResult(_0x354414,_0x54e959){return function(_0x1b6fd8){if(_0x1b6fd8){var _0x349fff=typeof _0x54e959[_0xc0c4('0x21')]==='undefined'&&typeof _0x54e959['limit']===_0xc0c4('0x22');var _0x474e9a=_0x1b6fd8['count'];var _0x1e6e75=_0x349fff?0x0:_0x54e959[_0xc0c4('0x21')];var _0x7437c9=_0x349fff?_0x1b6fd8[_0xc0c4('0x23')]:_0x54e959[_0xc0c4('0x21')]+_0x54e959[_0xc0c4('0x24')];var _0x4966ad;if(_0x7437c9>=_0x474e9a){_0x7437c9=_0x474e9a;_0x4966ad=0xc8;}else{_0x4966ad=0xce;}_0x354414[_0xc0c4('0x1e')](_0x4966ad);return _0x354414[_0xc0c4('0x25')](_0xc0c4('0x26'),_0x1e6e75+'-'+_0x7437c9+'/'+_0x474e9a)[_0xc0c4('0x20')](_0x1b6fd8);}return null;};}function patchUpdates(_0x4129e8){return function(_0x288049){try{jsonpatch[_0xc0c4('0x27')](_0x288049,_0x4129e8,!![]);}catch(_0x824a06){return BPromise[_0xc0c4('0x28')](_0x824a06);}return _0x288049[_0xc0c4('0x29')]();};}function saveUpdates(_0x530c07,_0x21d603){return function(_0x1e4681){if(_0x1e4681){return _0x1e4681[_0xc0c4('0x2a')](_0x530c07)[_0xc0c4('0x2b')](function(_0x1c9e6b){return _0x1c9e6b;});}return null;};}function removeEntity(_0x99f8f8,_0x37d72e){return function(_0xfa0010){if(_0xfa0010){return _0xfa0010['destroy']()[_0xc0c4('0x2b')](function(){var _0x473190=_0xfa0010[_0xc0c4('0x2c')]({'plain':!![]});var _0x4501e7=_0xc0c4('0x2d');return db['UserProfileResource']['destroy']({'where':{'type':_0x4501e7,'resourceId':_0x473190['id']}})[_0xc0c4('0x2b')](function(){return _0xfa0010;});})[_0xc0c4('0x2b')](function(){_0x99f8f8['status'](0xcc)[_0xc0c4('0x1f')]();});}};}function handleEntityNotFound(_0x305d6f,_0x4b3fe6){return function(_0x351b5d){if(!_0x351b5d){_0x305d6f['sendStatus'](0x194);}return _0x351b5d;};}function handleError(_0x45066c,_0x1a70f9){_0x1a70f9=_0x1a70f9||0x1f4;return function(_0x5b708f){logger[_0xc0c4('0x2e')](_0x5b708f[_0xc0c4('0x2f')]);if(_0x5b708f[_0xc0c4('0x30')]){delete _0x5b708f['name'];}_0x45066c[_0xc0c4('0x1e')](_0x1a70f9)['send'](_0x5b708f);};}exports[_0xc0c4('0x31')]=function(_0x24cbc8,_0x21d67e){var _0x51eea0={},_0x4c8861={},_0x4aa8d9={'count':0x0,'rows':[]};var _0x2a3357=_['map'](db[_0xc0c4('0x32')]['rawAttributes'],function(_0x251999){return{'name':_0x251999[_0xc0c4('0x33')],'type':_0x251999[_0xc0c4('0x34')][_0xc0c4('0x35')]};});_0x4c8861[_0xc0c4('0x36')]=_[_0xc0c4('0x37')](_0x2a3357,'name');_0x4c8861['query']=_[_0xc0c4('0x38')](_0x24cbc8[_0xc0c4('0x39')]);_0x4c8861[_0xc0c4('0x3a')]=_['intersection'](_0x4c8861[_0xc0c4('0x36')],_0x4c8861[_0xc0c4('0x39')]);_0x51eea0[_0xc0c4('0x3b')]=_['intersection'](_0x4c8861[_0xc0c4('0x36')],qs[_0xc0c4('0x3c')](_0x24cbc8['query']['fields']));_0x51eea0[_0xc0c4('0x3b')]=_0x51eea0[_0xc0c4('0x3b')][_0xc0c4('0x3d')]?_0x51eea0[_0xc0c4('0x3b')]:_0x4c8861[_0xc0c4('0x36')];if(!_0x24cbc8[_0xc0c4('0x39')]['hasOwnProperty'](_0xc0c4('0x3e'))){_0x51eea0[_0xc0c4('0x24')]=qs[_0xc0c4('0x24')](_0x24cbc8[_0xc0c4('0x39')][_0xc0c4('0x24')]);_0x51eea0['offset']=qs[_0xc0c4('0x21')](_0x24cbc8[_0xc0c4('0x39')]['offset']);}_0x51eea0[_0xc0c4('0x3f')]=qs['sort'](_0x24cbc8[_0xc0c4('0x39')][_0xc0c4('0x40')]);_0x51eea0['where']=qs[_0xc0c4('0x3a')](_[_0xc0c4('0x41')](_0x24cbc8[_0xc0c4('0x39')],_0x4c8861[_0xc0c4('0x3a')]),_0x2a3357);if(_0x24cbc8[_0xc0c4('0x39')][_0xc0c4('0x42')]){_0x51eea0[_0xc0c4('0x43')]=_[_0xc0c4('0x44')](_0x51eea0[_0xc0c4('0x43')],{'$or':_[_0xc0c4('0x37')](_0x2a3357,function(_0x3ec6a0){if(_0x3ec6a0[_0xc0c4('0x34')]!==_0xc0c4('0x45')){var _0x26982a={};_0x26982a[_0x3ec6a0[_0xc0c4('0x30')]]={'$like':'%'+_0x24cbc8[_0xc0c4('0x39')][_0xc0c4('0x42')]+'%'};return _0x26982a;}})});}_0x51eea0=_[_0xc0c4('0x44')]({},_0x51eea0,_0x24cbc8[_0xc0c4('0x46')]);var _0x2da69f={'where':_0x51eea0[_0xc0c4('0x43')]};return db[_0xc0c4('0x32')][_0xc0c4('0x23')](_0x2da69f)['then'](function(_0x4062a1){_0x4aa8d9[_0xc0c4('0x23')]=_0x4062a1;if(_0x24cbc8[_0xc0c4('0x39')][_0xc0c4('0x47')]){_0x51eea0[_0xc0c4('0x48')]=[{'all':!![]}];}return db[_0xc0c4('0x32')][_0xc0c4('0x49')](_0x51eea0);})[_0xc0c4('0x2b')](function(_0x2fbaf7){_0x4aa8d9[_0xc0c4('0x4a')]=_0x2fbaf7;return _0x4aa8d9;})[_0xc0c4('0x2b')](respondWithFilteredResult(_0x21d67e,_0x51eea0))[_0xc0c4('0x4b')](handleError(_0x21d67e,null));};exports[_0xc0c4('0x4c')]=function(_0x5c43e0,_0x47528f){var _0x732e8c={'raw':!![],'where':{'id':_0x5c43e0[_0xc0c4('0x4d')]['id']}},_0xa90ed9={};_0xa90ed9[_0xc0c4('0x36')]=_[_0xc0c4('0x38')](db[_0xc0c4('0x32')][_0xc0c4('0x4e')]);_0xa90ed9[_0xc0c4('0x39')]=_[_0xc0c4('0x38')](_0x5c43e0[_0xc0c4('0x39')]);_0xa90ed9['filters']=_['intersection'](_0xa90ed9[_0xc0c4('0x36')],_0xa90ed9[_0xc0c4('0x39')]);_0x732e8c[_0xc0c4('0x3b')]=_[_0xc0c4('0x4f')](_0xa90ed9[_0xc0c4('0x36')],qs['fields'](_0x5c43e0[_0xc0c4('0x39')][_0xc0c4('0x3c')]));_0x732e8c[_0xc0c4('0x3b')]=_0x732e8c[_0xc0c4('0x3b')][_0xc0c4('0x3d')]?_0x732e8c[_0xc0c4('0x3b')]:_0xa90ed9[_0xc0c4('0x36')];if(_0x5c43e0[_0xc0c4('0x39')][_0xc0c4('0x47')]){_0x732e8c[_0xc0c4('0x48')]=[{'all':!![]}];}_0x732e8c=_[_0xc0c4('0x44')]({},_0x732e8c,_0x5c43e0[_0xc0c4('0x46')]);return db['Plugin']['find'](_0x732e8c)[_0xc0c4('0x2b')](handleEntityNotFound(_0x47528f,null))[_0xc0c4('0x2b')](respondWithResult(_0x47528f,null))[_0xc0c4('0x4b')](handleError(_0x47528f,null));};exports['download']=function(_0x1748a4,_0x19b39f,_0x113e1a){return db['Plugin'][_0xc0c4('0x50')]({'where':{'id':_0x1748a4['params']['id']},'attributes':[_0xc0c4('0x30'),_0xc0c4('0x51')],'raw':!![]})['then'](handleEntityNotFound(_0x19b39f,null))['then'](function(_0x2ffbff){if(_0x2ffbff){var _0x23235d=path[_0xc0c4('0x52')](config[_0xc0c4('0x53')],_0xc0c4('0x54'),util[_0xc0c4('0x55')](_0xc0c4('0x56'),path['basename'](_0x2ffbff[_0xc0c4('0x51')])));var _0x332044=fs[_0xc0c4('0x57')](_0x23235d);var _0xaa5770=archiver(_0xc0c4('0x58'),{'zlib':{'level':0x9}});_0xaa5770['on'](_0xc0c4('0x59'),function(_0x305e72){if(_0x305e72[_0xc0c4('0x5a')]===_0xc0c4('0x5b')){logger[_0xc0c4('0x2e')](_0x305e72);}else{throw new db[(_0xc0c4('0x5c'))][(_0xc0c4('0x5d'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0xaa5770['on'](_0xc0c4('0x2e'),function(_0x114d9b){throw new db[(_0xc0c4('0x5c'))]['Error'](_0xc0c4('0x5e'));});_0xaa5770[_0xc0c4('0x5f')](_0x332044);_0xaa5770[_0xc0c4('0x60')](_0xc0c4('0x61'),{'cwd':path[_0xc0c4('0x52')](config[_0xc0c4('0x53')],_0xc0c4('0x54'),path[_0xc0c4('0x62')](_0x2ffbff[_0xc0c4('0x51')])),'ignore':[path[_0xc0c4('0x52')](path[_0xc0c4('0x63')](_0x2ffbff[_0xc0c4('0x51')]),_0xc0c4('0x64')),path[_0xc0c4('0x52')](path['basename'](_0x2ffbff[_0xc0c4('0x51')]),_0xc0c4('0x65'))],'nodir':!![]})[_0xc0c4('0x66')]();_0x332044['on'](_0xc0c4('0x67'),function(){if(!fs[_0xc0c4('0x68')](_0x23235d)){throw new db[(_0xc0c4('0x5c'))][(_0xc0c4('0x5d'))]('Plugin\x20not\x20found');}return _0x19b39f[_0xc0c4('0x69')](_0x23235d,util[_0xc0c4('0x55')]('%s.zip',path[_0xc0c4('0x63')](_0x2ffbff[_0xc0c4('0x51')])),function(_0x202704){if(_0x202704){throw new db[(_0xc0c4('0x5c'))][(_0xc0c4('0x5d'))](_0xc0c4('0x6a'));}fs[_0xc0c4('0x6b')](_0x23235d);logger['info'](_0xc0c4('0x6c'));logger[_0xc0c4('0x6d')](_0xc0c4('0x6e'));});});}return null;})[_0xc0c4('0x4b')](handleError(_0x19b39f,null));};exports[_0xc0c4('0x6f')]=function(_0x50c23a,_0x3781c1,_0x1e2f49){var _0x2e4405=path[_0xc0c4('0x63')](_0x50c23a['file'][_0xc0c4('0x70')],path[_0xc0c4('0x71')](_0x50c23a[_0xc0c4('0x72')][_0xc0c4('0x70')]));var _0x23ebbf=path[_0xc0c4('0x52')](config['root'],_0xc0c4('0x54'),_0x50c23a[_0xc0c4('0x72')][_0xc0c4('0x70')]);var _0x48d164=path['join'](config['root'],_0xc0c4('0x54'),_0x2e4405);logger['info'](_0xc0c4('0x73'),_0x23ebbf);logger['info'](_0xc0c4('0x74'),_0x48d164);try{fs[_0xc0c4('0x75')](_0x23ebbf,parseInt(_0xc0c4('0x76'),0x8));extract(_0x23ebbf,{'dir':_0x48d164},function(_0x421204){if(_0x421204){logger[_0xc0c4('0x2e')](_0x421204);handleError(_0x421204,!![]);};var _0xed54a5=fs['readdirSync'](_0x48d164);if(_0xed54a5[_0xc0c4('0x3d')]>0x1){removeReferences(_0x23ebbf,_0x48d164);logger[_0xc0c4('0x2e')]('Invalid\x20plugin\x20structure');return _0x1e2f49(new Error('Invalid\x20plugin\x20structure'));}var _0x46bb31=fs['lstatSync'](path[_0xc0c4('0x52')](_0x48d164,_0xed54a5[0x0]));if(_0x46bb31['isFile']()){removeReferences(_0x23ebbf,_0x48d164);logger[_0xc0c4('0x2e')](_0xc0c4('0x77'));return _0x1e2f49(new Error('Invalid\x20plugin\x20structure'));}if(_0x46bb31['isDirectory']()){var _0x2ce8b0=fs[_0xc0c4('0x78')](path['join'](_0x48d164,_0xed54a5[0x0]));if(_0x2ce8b0[_0xc0c4('0x3d')]===0x0){removeReferences(_0x23ebbf,_0x48d164);logger[_0xc0c4('0x2e')]('Invalid\x20plugin\x20structure');return _0x1e2f49(new Error(_0xc0c4('0x77')));}var _0x20a789=_0x2ce8b0[_0xc0c4('0x79')](function(_0x5ffd8c){return _0x5ffd8c===_0xc0c4('0x7a');});if(!_0x20a789){return _0x1e2f49(new Error(_0xc0c4('0x7b')));}var _0x4880fb=fs[_0xc0c4('0x7c')](path[_0xc0c4('0x52')](_0x48d164,_0xed54a5[0x0],_0xc0c4('0x7a')));var _0x111181=JSON[_0xc0c4('0x7d')](_0x4880fb);if(_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x30')]){return _0x1e2f49(new Error(_0xc0c4('0x7e')));}if(_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x34')]){return _0x1e2f49(new Error(_0xc0c4('0x7f')));}if(_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x80')]){return _0x1e2f49(new Error(_0xc0c4('0x81')));}if(_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x82')]){return _0x1e2f49(new Error(_0xc0c4('0x83')));}if(_0x111181[_0xc0c4('0x34')]===_0xc0c4('0x84')){if(_0xc0c4('0x22')==typeof _0x111181['parameters'][_0xc0c4('0x85')]){return _0x1e2f49(new Error('Invalid\x20manifest:\x20views\x20missing'));}if(_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')]['admin']&&_0xc0c4('0x22')==typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')][_0xc0c4('0x86')]){return _0x1e2f49(new Error(_0xc0c4('0x87')));}}else if(_0x111181['type']===_0xc0c4('0x88')){if('undefined'==typeof _0x111181[_0xc0c4('0x82')]['scriptName']){return _0x1e2f49(new Error('Invalid\x20manifest:\x20script\x20name\x20missing'));}if(_0xc0c4('0x22')==typeof _0x111181['parameters']['scriptPath']){return _0x1e2f49(new Error('Invalid\x20manifest:\x20script\x20path\x20missing'));}}else{return _0x1e2f49(new Error(_0xc0c4('0x89')));}var _0xee1130=_0x111181[_0xc0c4('0x30')];var _0x47ce86=_0x111181['description'];var _0x19314d=_0x111181[_0xc0c4('0x34')];var _0x5e69d2=_0x111181[_0xc0c4('0x8a')]?_0x111181[_0xc0c4('0x8a')]:_0xc0c4('0x8b');var _0x456127=_0x111181[_0xc0c4('0x8c')]?_0x111181[_0xc0c4('0x8c')]:_0xc0c4('0x8d');var _0x30049d='';var _0x4243d6='';var _0x46f19e='';var _0x14315e='';var _0x220197=_0x111181['version'];if(_0x19314d===_0xc0c4('0x84')){if(_0xc0c4('0x22')!=typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')][_0xc0c4('0x8e')]){var _0x16e8fc=_0x111181['parameters'][_0xc0c4('0x85')][_0xc0c4('0x8e')];if(!/^(f|ht)tps?:\/\//i[_0xc0c4('0x8f')](_0x16e8fc)){_0x30049d=path[_0xc0c4('0x52')](_0xc0c4('0x90'),_0x2e4405,_0xed54a5[0x0],_0x16e8fc);}else{_0x30049d=_0x16e8fc;}}else{logger['info'](_0xc0c4('0x91'));}if(_0xc0c4('0x22')!=typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')][_0xc0c4('0x86')]){var _0x339ea4=_0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')][_0xc0c4('0x86')];if(!/^(f|ht)tps?:\/\//i[_0xc0c4('0x8f')](_0x339ea4)){_0x4243d6=path[_0xc0c4('0x52')](_0xc0c4('0x90'),_0x2e4405,_0xed54a5[0x0],_0x339ea4);}else{_0x4243d6=_0x339ea4;}}else{logger[_0xc0c4('0x6d')](_0xc0c4('0x92'));}}else if(_0x19314d===_0xc0c4('0x88')){_0x46f19e=_0x111181[_0xc0c4('0x82')][_0xc0c4('0x93')];_0x14315e=_0x111181[_0xc0c4('0x82')][_0xc0c4('0x94')];if('undefined'!=typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')]){if(_0xc0c4('0x22')!=typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')][_0xc0c4('0x8e')]){var _0x16e8fc=_0x111181[_0xc0c4('0x82')]['views']['admin'];if(!/^(f|ht)tps?:\/\//i[_0xc0c4('0x8f')](_0x16e8fc)){_0x30049d=path['join']('plugins',_0x2e4405,_0xed54a5[0x0],_0x16e8fc);}else{_0x30049d=_0x16e8fc;}}if(_0xc0c4('0x22')!=typeof _0x111181[_0xc0c4('0x82')][_0xc0c4('0x85')]['agent']){var _0x339ea4=_0x111181['parameters']['views'][_0xc0c4('0x86')];if(!/^(f|ht)tps?:\/\//i[_0xc0c4('0x8f')](_0x339ea4)){_0x4243d6=path['join'](_0xc0c4('0x90'),_0x2e4405,_0xed54a5[0x0],_0x339ea4);}else{_0x4243d6=_0x339ea4;}}}}var _0x1abf11={'name':_0xee1130,'description':_0x47ce86,'path':path[_0xc0c4('0x52')](_0x2e4405,_0xed54a5[0x0]),'type':_0x19314d,'sidebar':_0x5e69d2,'icon':_0x456127,'adminUrl':_0x30049d,'agentUrl':_0x4243d6,'scriptName':_0x46f19e,'scriptPath':_0x14315e,'version':_0x220197};removeReferences(_0x23ebbf,null);return db[_0xc0c4('0x32')][_0xc0c4('0x95')](_0x1abf11)[_0xc0c4('0x2b')](function(_0x5a5f39){var _0x5d7ab7={'role':_0x50c23a[_0xc0c4('0x96')][_0xc0c4('0x97')],'userProfileId':_0x50c23a['body']['userProfileId']};if(!_0x5d7ab7)throw new Error(_0xc0c4('0x98'));if(_0x5d7ab7[_0xc0c4('0x97')]==='user'){var _0x23565e=_0x5a5f39[_0xc0c4('0x2c')]({'plain':!![]});return db['UserProfileSection'][_0xc0c4('0x50')]({'where':{'name':_0xc0c4('0x2d'),'userProfileId':_0x5d7ab7[_0xc0c4('0x99')]},'raw':!![]})[_0xc0c4('0x2b')](function(_0x3d7b76){if(_0x3d7b76&&_0x3d7b76[_0xc0c4('0x9a')]===0x0){return db[_0xc0c4('0x9b')][_0xc0c4('0x95')]({'name':_0x23565e['name'],'resourceId':_0x23565e['id'],'type':_0x3d7b76[_0xc0c4('0x30')],'sectionId':_0x3d7b76['id']},{})[_0xc0c4('0x2b')](function(){return _0x5a5f39;});}else{return _0x5a5f39;}})[_0xc0c4('0x4b')](function(_0x21e882){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x21e882);throw _0x21e882;});}return _0x5a5f39;})[_0xc0c4('0x2b')](respondWithResult(_0x3781c1,null))[_0xc0c4('0x4b')](handleError(_0x3781c1,null));}});}catch(_0x3c2ad5){_0x3781c1[_0xc0c4('0x1e')](0x1f4)[_0xc0c4('0x9c')](_0x3c2ad5);}};function removeReferences(_0x4b8566,_0x121600){try{if(_0x4b8566){fs[_0xc0c4('0x6b')](_0x4b8566);logger[_0xc0c4('0x6d')](_0xc0c4('0x9d'));}if(_0x121600){rimraf(_0x121600,function(){});logger['info']('Extracted\x20folder\x20removed');}}catch(_0x3c5639){logger['error'](_0x3c5639);}}exports[_0xc0c4('0x2a')]=function(_0xf7c369,_0x1aef69,_0x2567ee){return db[_0xc0c4('0x32')]['find']({'where':{'id':_0xf7c369[_0xc0c4('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1aef69,null))['then'](saveUpdates(_0xf7c369[_0xc0c4('0x96')],null))['then'](respondWithResult(_0x1aef69,null))[_0xc0c4('0x4b')](handleError(_0x1aef69,null));};exports[_0xc0c4('0x9e')]=function(_0x3ff7e4,_0x1bbaea,_0x32eb42){return db[_0xc0c4('0x32')][_0xc0c4('0x50')]({'where':{'id':_0x3ff7e4[_0xc0c4('0x4d')]['id']}})[_0xc0c4('0x2b')](function(_0x2648fa){if(_0x2648fa){return _0x2648fa[_0xc0c4('0x9f')]();}})[_0xc0c4('0x2b')](function(_0x8e3d19){rimraf(path['join'](config[_0xc0c4('0x53')],_0xc0c4('0x54'),path[_0xc0c4('0x62')](_0x8e3d19[_0xc0c4('0x51')])),function(){});return _0x8e3d19;})['then'](handleEntityNotFound(_0x1bbaea,null))[_0xc0c4('0x2b')](respondWithStatusCode(_0x1bbaea,null))[_0xc0c4('0x4b')](handleError(_0x1bbaea,null));};exports[_0xc0c4('0xa0')]=function(_0x122884,_0x12d412,_0x36e80d){return BPromise[_0xc0c4('0xa1')]()[_0xc0c4('0x2b')](function(){if(!_0x122884[_0xc0c4('0x39')]['path']){throw new Error(_0xc0c4('0xa2'));}if(!_0x122884['query'][_0xc0c4('0xa3')]){throw new Error(_0xc0c4('0xa4'));}var _0x25c9f4=_0x122884[_0xc0c4('0x39')][_0xc0c4('0xa5')]?_0x122884[_0xc0c4('0x39')]['hostname']+':'+_0x122884[_0xc0c4('0x39')]['port']:_0xc0c4('0xa6')+_0x122884[_0xc0c4('0x39')][_0xc0c4('0xa3')];var _0x37552b=_0x122884[_0xc0c4('0x39')][_0xc0c4('0x20')]?_0x122884[_0xc0c4('0x39')][_0xc0c4('0x20')]:!![];var _0x4f36e7=_0x122884['query'][_0xc0c4('0xa7')]?_0x122884['query'][_0xc0c4('0xa7')]:null;var _0x2196bf={'method':_0x122884[_0xc0c4('0xa8')],'uri':util[_0xc0c4('0x55')]('%s%s',_0x25c9f4,_0x122884[_0xc0c4('0x39')][_0xc0c4('0x51')]),'json':_0x37552b,'resolveWithFullResponse':!![],'encoding':_0x4f36e7,'qs':_0x122884[_0xc0c4('0x39')]};if(_0x122884[_0xc0c4('0xa9')]){_0x2196bf[_0xc0c4('0xa9')]=_0x122884[_0xc0c4('0xa9')];if(_0x2196bf['headers']['content-length']){delete _0x2196bf[_0xc0c4('0xa9')][_0xc0c4('0xaa')];}}if(_0x2196bf[_0xc0c4('0xa9')][_0xc0c4('0xab')]){delete _0x2196bf[_0xc0c4('0xa9')]['content-type'];}return rp(_0x2196bf);})[_0xc0c4('0x2b')](function(_0x362c5d){if(_0x362c5d){_0x12d412[_0xc0c4('0x25')](_0x362c5d[_0xc0c4('0xa9')]);logger[_0xc0c4('0x6d')](_0x362c5d[_0xc0c4('0x96')]);if(_['endsWith'](_0x122884[_0xc0c4('0x39')][_0xc0c4('0x51')],_0xc0c4('0x69'))&&_0x362c5d[_0xc0c4('0xac')]==0x1f4){return _0x12d412[_0xc0c4('0xad')](_0x362c5d[_0xc0c4('0xac')]);}else{return _0x12d412[_0xc0c4('0x1e')](_0x362c5d[_0xc0c4('0xac')])[_0xc0c4('0x9c')](_0x362c5d[_0xc0c4('0x96')]);}}else{return _0x12d412[_0xc0c4('0xad')](0xc8);}})['catch'](handleError(_0x12d412,null));};exports[_0xc0c4('0xae')]=function(_0x220124,_0x51f780,_0x5dbb45){return BPromise[_0xc0c4('0xa1')]()['then'](function(){if(!_0x220124[_0xc0c4('0x39')][_0xc0c4('0x51')]){throw new Error(_0xc0c4('0xa2'));}if(!_0x220124[_0xc0c4('0x39')]['port']){throw new Error(_0xc0c4('0xa4'));}var _0x35c163=_0x220124[_0xc0c4('0x39')][_0xc0c4('0xa5')]?_0x220124['query']['hostname']+':'+_0x220124['query'][_0xc0c4('0xa3')]:'http://localhost:'+_0x220124['query'][_0xc0c4('0xa3')];var _0x4d69cd=_0x220124['query'][_0xc0c4('0x20')]?_0x220124[_0xc0c4('0x39')][_0xc0c4('0x20')]:!![];var _0x8b23c6=_0x220124['query'][_0xc0c4('0xa7')]?_0x220124['query'][_0xc0c4('0xa7')]:null;var _0x573d36={'method':_0x220124[_0xc0c4('0xa8')],'uri':util[_0xc0c4('0x55')](_0xc0c4('0xaf'),_0x35c163,_0x220124[_0xc0c4('0x39')][_0xc0c4('0x51')]),'json':_0x4d69cd,'resolveWithFullResponse':!![],'encoding':_0x8b23c6,'body':_0x220124[_0xc0c4('0x96')]};if(_0x220124[_0xc0c4('0xa9')]){_0x573d36['headers']=_0x220124[_0xc0c4('0xa9')];if(_0x573d36[_0xc0c4('0xa9')]['content-length']){delete _0x573d36['headers']['content-length'];}}if(_0x573d36[_0xc0c4('0xa9')]['content-type']){delete _0x573d36[_0xc0c4('0xa9')][_0xc0c4('0xab')];}return rp(_0x573d36);})[_0xc0c4('0x2b')](function(_0x170aeb){if(_0x170aeb){_0x51f780[_0xc0c4('0x25')](_0x170aeb[_0xc0c4('0xa9')]);logger[_0xc0c4('0x6d')](_0x170aeb[_0xc0c4('0x96')]);return _0x51f780['status'](_0x170aeb['statusCode'])[_0xc0c4('0x9c')](_0x170aeb[_0xc0c4('0x96')]);}else{return _0x51f780[_0xc0c4('0xad')](0xc8);}})[_0xc0c4('0x4b')](handleError(_0x51f780,null));};
\ No newline at end of file
+var _0xc842=['undefined','limit','count','set','Content-Range','apply','save','update','then','get','UserProfileResource','destroy','error','name','send','index','map','Plugin','fieldName','type','key','model','keys','filters','intersection','query','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','root','server/files/plugins','format','%s.zip','basename','warning','code','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','**/*','dirname','node_modules/**/*','attachments/**/*','close','Plugin\x20not\x20found','download','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Temporary\x20file\x20removed','upload','filename','extname','join','file','Plugin\x20upload\x20destination:\x20%s','0777','readdirSync','Invalid\x20plugin\x20structure','isFile','some','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','Invalid\x20manifest:\x20version\x20not\x20specified','parameters','Invalid\x20manifest:\x20parameters\x20missing','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','html','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','Plugins','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','webhookGet','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','method','%s%s','headers','content-length','content-type','endsWith','statusCode','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','extract-zip','rimraf','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./plugin.socket','register','sendStatus','status','end','json','offset'];(function(_0x31574d,_0x173c0e){var _0x7b0b84=function(_0x3eb6ac){while(--_0x3eb6ac){_0x31574d['push'](_0x31574d['shift']());}};_0x7b0b84(++_0x173c0e);}(_0xc842,0x13a));var _0x2c84=function(_0x4565bf,_0x5ad9d6){_0x4565bf=_0x4565bf-0x0;var _0x5610ba=_0xc842[_0x4565bf];return _0x5610ba;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x2c84('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0x2c84('0x1'));var moment=require(_0x2c84('0x2'));var BPromise=require(_0x2c84('0x3'));var Mustache=require(_0x2c84('0x4'));var util=require(_0x2c84('0x5'));var path=require(_0x2c84('0x6'));var sox=require('sox');var csv=require(_0x2c84('0x7'));var ejs=require(_0x2c84('0x8'));var fs=require('fs');var fs_extra=require(_0x2c84('0x9'));var _=require(_0x2c84('0xa'));var squel=require(_0x2c84('0xb'));var crypto=require(_0x2c84('0xc'));var jsforce=require(_0x2c84('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x2c84('0x7'));var querystring=require(_0x2c84('0xe'));var Papa=require(_0x2c84('0xf'));var extract=require(_0x2c84('0x10'));var rimraf=require(_0x2c84('0x11'));var archiver=require('archiver');var Redis=require(_0x2c84('0x12'));var authService=require(_0x2c84('0x13'));var qs=require(_0x2c84('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x2c84('0x15'));var logger=require(_0x2c84('0x16'))(_0x2c84('0x17'));var utils=require(_0x2c84('0x18'));var config=require(_0x2c84('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x2c84('0x1a'))['db'];config['redis']=_[_0x2c84('0x1b')](config[_0x2c84('0x1c')],{'host':_0x2c84('0x1d'),'port':0x18eb});var socket=require(_0x2c84('0x1e'))(new Redis(config[_0x2c84('0x1c')]));require(_0x2c84('0x1f'))[_0x2c84('0x20')](socket);function respondWithStatusCode(_0x347be1,_0x3b5791){_0x3b5791=_0x3b5791||0xcc;return function(_0x143bd2){if(_0x143bd2){return _0x347be1[_0x2c84('0x21')](_0x3b5791);}return _0x347be1[_0x2c84('0x22')](_0x3b5791)[_0x2c84('0x23')]();};}function respondWithResult(_0x12df2e,_0x7336e4){_0x7336e4=_0x7336e4||0xc8;return function(_0xcf910b){if(_0xcf910b){return _0x12df2e[_0x2c84('0x22')](_0x7336e4)[_0x2c84('0x24')](_0xcf910b);}};}function respondWithFilteredResult(_0xcd8cde,_0x4fd5e5){return function(_0x107637){if(_0x107637){var _0x42e796=typeof _0x4fd5e5[_0x2c84('0x25')]===_0x2c84('0x26')&&typeof _0x4fd5e5[_0x2c84('0x27')]===_0x2c84('0x26');var _0x537bda=_0x107637[_0x2c84('0x28')];var _0x23cab3=_0x42e796?0x0:_0x4fd5e5[_0x2c84('0x25')];var _0xf6497e=_0x42e796?_0x107637['count']:_0x4fd5e5[_0x2c84('0x25')]+_0x4fd5e5['limit'];var _0x24bdcf;if(_0xf6497e>=_0x537bda){_0xf6497e=_0x537bda;_0x24bdcf=0xc8;}else{_0x24bdcf=0xce;}_0xcd8cde['status'](_0x24bdcf);return _0xcd8cde[_0x2c84('0x29')](_0x2c84('0x2a'),_0x23cab3+'-'+_0xf6497e+'/'+_0x537bda)['json'](_0x107637);}return null;};}function patchUpdates(_0x45cf65){return function(_0x20327b){try{jsonpatch[_0x2c84('0x2b')](_0x20327b,_0x45cf65,!![]);}catch(_0x18a022){return BPromise['reject'](_0x18a022);}return _0x20327b[_0x2c84('0x2c')]();};}function saveUpdates(_0x347ba3,_0x14258d){return function(_0x4e20fd){if(_0x4e20fd){return _0x4e20fd[_0x2c84('0x2d')](_0x347ba3)['then'](function(_0x4be292){return _0x4be292;});}return null;};}function removeEntity(_0x7f2afd,_0x4fa423){return function(_0x3b10f5){if(_0x3b10f5){return _0x3b10f5['destroy']()[_0x2c84('0x2e')](function(){var _0x284972=_0x3b10f5[_0x2c84('0x2f')]({'plain':!![]});var _0xaf1007='Plugins';return db[_0x2c84('0x30')][_0x2c84('0x31')]({'where':{'type':_0xaf1007,'resourceId':_0x284972['id']}})[_0x2c84('0x2e')](function(){return _0x3b10f5;});})[_0x2c84('0x2e')](function(){_0x7f2afd[_0x2c84('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x412708,_0x5eec51){return function(_0x564cd1){if(!_0x564cd1){_0x412708[_0x2c84('0x21')](0x194);}return _0x564cd1;};}function handleError(_0x1544d0,_0xa6f59f){_0xa6f59f=_0xa6f59f||0x1f4;return function(_0x56fa98){logger[_0x2c84('0x32')](_0x56fa98['stack']);if(_0x56fa98[_0x2c84('0x33')]){delete _0x56fa98[_0x2c84('0x33')];}_0x1544d0[_0x2c84('0x22')](_0xa6f59f)[_0x2c84('0x34')](_0x56fa98);};}exports[_0x2c84('0x35')]=function(_0x55548b,_0x104815){var _0x23b76a={},_0x2b67ac={},_0xf04312={'count':0x0,'rows':[]};var _0x11be52=_[_0x2c84('0x36')](db[_0x2c84('0x37')]['rawAttributes'],function(_0x23c1d9){return{'name':_0x23c1d9[_0x2c84('0x38')],'type':_0x23c1d9[_0x2c84('0x39')][_0x2c84('0x3a')]};});_0x2b67ac[_0x2c84('0x3b')]=_[_0x2c84('0x36')](_0x11be52,_0x2c84('0x33'));_0x2b67ac['query']=_[_0x2c84('0x3c')](_0x55548b['query']);_0x2b67ac[_0x2c84('0x3d')]=_[_0x2c84('0x3e')](_0x2b67ac[_0x2c84('0x3b')],_0x2b67ac[_0x2c84('0x3f')]);_0x23b76a['attributes']=_[_0x2c84('0x3e')](_0x2b67ac[_0x2c84('0x3b')],qs[_0x2c84('0x40')](_0x55548b[_0x2c84('0x3f')]['fields']));_0x23b76a[_0x2c84('0x41')]=_0x23b76a[_0x2c84('0x41')][_0x2c84('0x42')]?_0x23b76a[_0x2c84('0x41')]:_0x2b67ac[_0x2c84('0x3b')];if(!_0x55548b[_0x2c84('0x3f')][_0x2c84('0x43')](_0x2c84('0x44'))){_0x23b76a['limit']=qs[_0x2c84('0x27')](_0x55548b['query'][_0x2c84('0x27')]);_0x23b76a[_0x2c84('0x25')]=qs[_0x2c84('0x25')](_0x55548b['query'][_0x2c84('0x25')]);}_0x23b76a[_0x2c84('0x45')]=qs['sort'](_0x55548b[_0x2c84('0x3f')][_0x2c84('0x46')]);_0x23b76a[_0x2c84('0x47')]=qs[_0x2c84('0x3d')](_[_0x2c84('0x48')](_0x55548b[_0x2c84('0x3f')],_0x2b67ac['filters']),_0x11be52);if(_0x55548b['query'][_0x2c84('0x49')]){_0x23b76a[_0x2c84('0x47')]=_[_0x2c84('0x4a')](_0x23b76a[_0x2c84('0x47')],{'$or':_[_0x2c84('0x36')](_0x11be52,function(_0x489a15){if(_0x489a15[_0x2c84('0x39')]!==_0x2c84('0x4b')){var _0x573b5d={};_0x573b5d[_0x489a15[_0x2c84('0x33')]]={'$like':'%'+_0x55548b[_0x2c84('0x3f')]['filter']+'%'};return _0x573b5d;}})});}_0x23b76a=_[_0x2c84('0x4a')]({},_0x23b76a,_0x55548b[_0x2c84('0x4c')]);var _0x3a491b={'where':_0x23b76a[_0x2c84('0x47')]};return db[_0x2c84('0x37')]['count'](_0x3a491b)[_0x2c84('0x2e')](function(_0x2bfe4b){_0xf04312[_0x2c84('0x28')]=_0x2bfe4b;if(_0x55548b[_0x2c84('0x3f')][_0x2c84('0x4d')]){_0x23b76a[_0x2c84('0x4e')]=[{'all':!![]}];}return db['Plugin'][_0x2c84('0x4f')](_0x23b76a);})['then'](function(_0x4b0d30){_0xf04312[_0x2c84('0x50')]=_0x4b0d30;return _0xf04312;})['then'](respondWithFilteredResult(_0x104815,_0x23b76a))[_0x2c84('0x51')](handleError(_0x104815,null));};exports[_0x2c84('0x52')]=function(_0x1863d8,_0x181e1b){var _0x30e359={'raw':!![],'where':{'id':_0x1863d8[_0x2c84('0x53')]['id']}},_0x237dbd={};_0x237dbd[_0x2c84('0x3b')]=_[_0x2c84('0x3c')](db['Plugin'][_0x2c84('0x54')]);_0x237dbd['query']=_[_0x2c84('0x3c')](_0x1863d8[_0x2c84('0x3f')]);_0x237dbd[_0x2c84('0x3d')]=_['intersection'](_0x237dbd[_0x2c84('0x3b')],_0x237dbd[_0x2c84('0x3f')]);_0x30e359[_0x2c84('0x41')]=_[_0x2c84('0x3e')](_0x237dbd[_0x2c84('0x3b')],qs[_0x2c84('0x40')](_0x1863d8[_0x2c84('0x3f')][_0x2c84('0x40')]));_0x30e359[_0x2c84('0x41')]=_0x30e359[_0x2c84('0x41')]['length']?_0x30e359[_0x2c84('0x41')]:_0x237dbd[_0x2c84('0x3b')];if(_0x1863d8[_0x2c84('0x3f')][_0x2c84('0x4d')]){_0x30e359['include']=[{'all':!![]}];}_0x30e359=_[_0x2c84('0x4a')]({},_0x30e359,_0x1863d8[_0x2c84('0x4c')]);return db[_0x2c84('0x37')][_0x2c84('0x55')](_0x30e359)['then'](handleEntityNotFound(_0x181e1b,null))['then'](respondWithResult(_0x181e1b,null))['catch'](handleError(_0x181e1b,null));};exports['download']=function(_0x1fbd59,_0x141628,_0x4978de){return db[_0x2c84('0x37')][_0x2c84('0x55')]({'where':{'id':_0x1fbd59[_0x2c84('0x53')]['id']},'attributes':[_0x2c84('0x33'),'path'],'raw':!![]})[_0x2c84('0x2e')](handleEntityNotFound(_0x141628,null))[_0x2c84('0x2e')](function(_0x3c99e2){if(_0x3c99e2){var _0x3e38f3=path['join'](config[_0x2c84('0x56')],_0x2c84('0x57'),util[_0x2c84('0x58')](_0x2c84('0x59'),path[_0x2c84('0x5a')](_0x3c99e2[_0x2c84('0x6')])));var _0x566418=fs['createWriteStream'](_0x3e38f3);var _0x160f4f=archiver('zip',{'zlib':{'level':0x9}});_0x160f4f['on'](_0x2c84('0x5b'),function(_0x2400a4){if(_0x2400a4[_0x2c84('0x5c')]==='ENOENT'){logger[_0x2c84('0x32')](_0x2400a4);}else{throw new db[(_0x2c84('0x5d'))][(_0x2c84('0x5e'))](_0x2c84('0x5f'));}});_0x160f4f['on']('error',function(_0x571f98){throw new db[(_0x2c84('0x5d'))][(_0x2c84('0x5e'))](_0x2c84('0x5f'));});_0x160f4f['pipe'](_0x566418);_0x160f4f[_0x2c84('0x60')](_0x2c84('0x61'),{'cwd':path['join'](config[_0x2c84('0x56')],_0x2c84('0x57'),path[_0x2c84('0x62')](_0x3c99e2['path'])),'ignore':[path['join'](path[_0x2c84('0x5a')](_0x3c99e2[_0x2c84('0x6')]),_0x2c84('0x63')),path['join'](path[_0x2c84('0x5a')](_0x3c99e2[_0x2c84('0x6')]),_0x2c84('0x64'))],'nodir':!![]})['finalize']();_0x566418['on'](_0x2c84('0x65'),function(){if(!fs['existsSync'](_0x3e38f3)){throw new db[(_0x2c84('0x5d'))][(_0x2c84('0x5e'))](_0x2c84('0x66'));}return _0x141628[_0x2c84('0x67')](_0x3e38f3,util[_0x2c84('0x58')]('%s.zip',path[_0x2c84('0x5a')](_0x3c99e2[_0x2c84('0x6')])),function(_0x4624ea){if(_0x4624ea){throw new db[(_0x2c84('0x5d'))][(_0x2c84('0x5e'))](_0x2c84('0x68'));}fs[_0x2c84('0x69')](_0x3e38f3);logger['info']('Download\x20completed');logger[_0x2c84('0x6a')](_0x2c84('0x6b'));});});}return null;})[_0x2c84('0x51')](handleError(_0x141628,null));};exports[_0x2c84('0x6c')]=function(_0x11a5ef,_0xbdcf38,_0x20d314){var _0xe5de21=path[_0x2c84('0x5a')](_0x11a5ef['file'][_0x2c84('0x6d')],path[_0x2c84('0x6e')](_0x11a5ef['file'][_0x2c84('0x6d')]));var _0x5a8f7f=path[_0x2c84('0x6f')](config[_0x2c84('0x56')],'server/files/plugins',_0x11a5ef[_0x2c84('0x70')][_0x2c84('0x6d')]);var _0x483f2e=path[_0x2c84('0x6f')](config['root'],_0x2c84('0x57'),_0xe5de21);logger[_0x2c84('0x6a')]('Plugin\x20upload\x20filepath:\x20%s',_0x5a8f7f);logger[_0x2c84('0x6a')](_0x2c84('0x71'),_0x483f2e);try{fs['chmodSync'](_0x5a8f7f,parseInt(_0x2c84('0x72'),0x8));extract(_0x5a8f7f,{'dir':_0x483f2e},function(_0xc2ba69){if(_0xc2ba69){logger[_0x2c84('0x32')](_0xc2ba69);handleError(_0xc2ba69,!![]);};var _0x116bb=fs[_0x2c84('0x73')](_0x483f2e);if(_0x116bb[_0x2c84('0x42')]>0x1){removeReferences(_0x5a8f7f,_0x483f2e);logger[_0x2c84('0x32')]('Invalid\x20plugin\x20structure');return _0x20d314(new Error(_0x2c84('0x74')));}var _0x4f71f9=fs['lstatSync'](path[_0x2c84('0x6f')](_0x483f2e,_0x116bb[0x0]));if(_0x4f71f9[_0x2c84('0x75')]()){removeReferences(_0x5a8f7f,_0x483f2e);logger['error'](_0x2c84('0x74'));return _0x20d314(new Error('Invalid\x20plugin\x20structure'));}if(_0x4f71f9['isDirectory']()){var _0x4ab9a1=fs[_0x2c84('0x73')](path[_0x2c84('0x6f')](_0x483f2e,_0x116bb[0x0]));if(_0x4ab9a1[_0x2c84('0x42')]===0x0){removeReferences(_0x5a8f7f,_0x483f2e);logger[_0x2c84('0x32')](_0x2c84('0x74'));return _0x20d314(new Error('Invalid\x20plugin\x20structure'));}var _0x2d2cac=_0x4ab9a1[_0x2c84('0x76')](function(_0x108323){return _0x108323===_0x2c84('0x77');});if(!_0x2d2cac){return _0x20d314(new Error(_0x2c84('0x78')));}var _0x139586=fs[_0x2c84('0x79')](path[_0x2c84('0x6f')](_0x483f2e,_0x116bb[0x0],_0x2c84('0x77')));var _0xcb999e=JSON[_0x2c84('0x7a')](_0x139586);if(_0x2c84('0x26')==typeof _0xcb999e[_0x2c84('0x33')]){return _0x20d314(new Error(_0x2c84('0x7b')));}if(_0x2c84('0x26')==typeof _0xcb999e['type']){return _0x20d314(new Error(_0x2c84('0x7c')));}if('undefined'==typeof _0xcb999e[_0x2c84('0x7d')]){return _0x20d314(new Error(_0x2c84('0x7e')));}if(_0x2c84('0x26')==typeof _0xcb999e[_0x2c84('0x7f')]){return _0x20d314(new Error(_0x2c84('0x80')));}if(_0xcb999e[_0x2c84('0x39')]==='html'){if('undefined'==typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')]){return _0x20d314(new Error(_0x2c84('0x82')));}if(_0x2c84('0x26')==typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x83')]&&_0x2c84('0x26')==typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x84')]){return _0x20d314(new Error(_0x2c84('0x85')));}}else if(_0xcb999e[_0x2c84('0x39')]===_0x2c84('0x86')){if(_0x2c84('0x26')==typeof _0xcb999e['parameters'][_0x2c84('0x87')]){return _0x20d314(new Error(_0x2c84('0x88')));}if(_0x2c84('0x26')==typeof _0xcb999e['parameters'][_0x2c84('0x89')]){return _0x20d314(new Error(_0x2c84('0x8a')));}}else{return _0x20d314(new Error(_0x2c84('0x8b')));}var _0x40bce1=_0xcb999e[_0x2c84('0x33')];var _0x226c2a=_0xcb999e[_0x2c84('0x8c')];var _0x40a4a5=_0xcb999e[_0x2c84('0x39')];var _0x31890e=_0xcb999e[_0x2c84('0x8d')]?_0xcb999e[_0x2c84('0x8d')]:_0x2c84('0x8e');var _0x48fa9b=_0xcb999e['icon']?_0xcb999e[_0x2c84('0x8f')]:_0x2c84('0x90');var _0x3fbb86='';var _0x373f94='';var _0x3e5b0f='';var _0x146720='';var _0x44c1cd=_0xcb999e[_0x2c84('0x7d')];if(_0x40a4a5===_0x2c84('0x91')){if('undefined'!=typeof _0xcb999e['parameters'][_0x2c84('0x81')][_0x2c84('0x83')]){var _0x344be0=_0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x83')];if(!/^(f|ht)tps?:\/\//i[_0x2c84('0x92')](_0x344be0)){_0x3fbb86=path[_0x2c84('0x6f')](_0x2c84('0x93'),_0xe5de21,_0x116bb[0x0],_0x344be0);}else{_0x3fbb86=_0x344be0;}}else{logger[_0x2c84('0x6a')](_0x2c84('0x94'));}if('undefined'!=typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x84')]){var _0x4ea772=_0xcb999e[_0x2c84('0x7f')]['views'][_0x2c84('0x84')];if(!/^(f|ht)tps?:\/\//i[_0x2c84('0x92')](_0x4ea772)){_0x373f94=path[_0x2c84('0x6f')](_0x2c84('0x93'),_0xe5de21,_0x116bb[0x0],_0x4ea772);}else{_0x373f94=_0x4ea772;}}else{logger['info'](_0x2c84('0x95'));}}else if(_0x40a4a5==='script'){_0x3e5b0f=_0xcb999e[_0x2c84('0x7f')][_0x2c84('0x87')];_0x146720=_0xcb999e[_0x2c84('0x7f')]['scriptPath'];if(_0x2c84('0x26')!=typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')]){if('undefined'!=typeof _0xcb999e[_0x2c84('0x7f')]['views'][_0x2c84('0x83')]){var _0x344be0=_0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x83')];if(!/^(f|ht)tps?:\/\//i[_0x2c84('0x92')](_0x344be0)){_0x3fbb86=path[_0x2c84('0x6f')](_0x2c84('0x93'),_0xe5de21,_0x116bb[0x0],_0x344be0);}else{_0x3fbb86=_0x344be0;}}if('undefined'!=typeof _0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')][_0x2c84('0x84')]){var _0x4ea772=_0xcb999e[_0x2c84('0x7f')][_0x2c84('0x81')]['agent'];if(!/^(f|ht)tps?:\/\//i[_0x2c84('0x92')](_0x4ea772)){_0x373f94=path[_0x2c84('0x6f')](_0x2c84('0x93'),_0xe5de21,_0x116bb[0x0],_0x4ea772);}else{_0x373f94=_0x4ea772;}}}}var _0x2183bd={'name':_0x40bce1,'description':_0x226c2a,'path':path[_0x2c84('0x6f')](_0xe5de21,_0x116bb[0x0]),'type':_0x40a4a5,'sidebar':_0x31890e,'icon':_0x48fa9b,'adminUrl':_0x3fbb86,'agentUrl':_0x373f94,'scriptName':_0x3e5b0f,'scriptPath':_0x146720,'version':_0x44c1cd};removeReferences(_0x5a8f7f,null);return db[_0x2c84('0x37')][_0x2c84('0x96')](_0x2183bd)['then'](function(_0x268f89){var _0x5de7d8={'role':_0x11a5ef[_0x2c84('0x97')][_0x2c84('0x98')],'userProfileId':_0x11a5ef[_0x2c84('0x97')][_0x2c84('0x99')]};if(!_0x5de7d8)throw new Error(_0x2c84('0x9a'));if(_0x5de7d8[_0x2c84('0x98')]===_0x2c84('0x9b')){var _0xd22c4c=_0x268f89['get']({'plain':!![]});return db['UserProfileSection'][_0x2c84('0x55')]({'where':{'name':_0x2c84('0x9c'),'userProfileId':_0x5de7d8['userProfileId']},'raw':!![]})['then'](function(_0x55a6bf){if(_0x55a6bf&&_0x55a6bf[_0x2c84('0x9d')]===0x0){return db['UserProfileResource'][_0x2c84('0x96')]({'name':_0xd22c4c['name'],'resourceId':_0xd22c4c['id'],'type':_0x55a6bf[_0x2c84('0x33')],'sectionId':_0x55a6bf['id']},{})['then'](function(){return _0x268f89;});}else{return _0x268f89;}})[_0x2c84('0x51')](function(_0x2a565a){logger['error'](_0x2c84('0x9e'),_0x2a565a);throw _0x2a565a;});}return _0x268f89;})[_0x2c84('0x2e')](respondWithResult(_0xbdcf38,null))['catch'](handleError(_0xbdcf38,null));}});}catch(_0x17e20c){_0xbdcf38[_0x2c84('0x22')](0x1f4)[_0x2c84('0x34')](_0x17e20c);}};function removeReferences(_0x331150,_0x3439e6){try{if(_0x331150){fs[_0x2c84('0x69')](_0x331150);logger[_0x2c84('0x6a')](_0x2c84('0x9f'));}if(_0x3439e6){rimraf(_0x3439e6,function(){});logger['info'](_0x2c84('0xa0'));}}catch(_0x1c363d){logger[_0x2c84('0x32')](_0x1c363d);}}exports[_0x2c84('0x2d')]=function(_0x45abb1,_0x3a89d5,_0x31334e){return db[_0x2c84('0x37')][_0x2c84('0x55')]({'where':{'id':_0x45abb1[_0x2c84('0x53')]['id']}})[_0x2c84('0x2e')](handleEntityNotFound(_0x3a89d5,null))[_0x2c84('0x2e')](saveUpdates(_0x45abb1[_0x2c84('0x97')],null))['then'](respondWithResult(_0x3a89d5,null))[_0x2c84('0x51')](handleError(_0x3a89d5,null));};exports['delete']=function(_0x535054,_0x536ac5,_0xf5d23d){return db[_0x2c84('0x37')][_0x2c84('0x55')]({'where':{'id':_0x535054[_0x2c84('0x53')]['id']}})['then'](function(_0x53ded7){if(_0x53ded7){return _0x53ded7['destroy']();}})[_0x2c84('0x2e')](function(_0x4c8274){rimraf(path['join'](config['root'],'server/files/plugins',path[_0x2c84('0x62')](_0x4c8274[_0x2c84('0x6')])),function(){});return _0x4c8274;})[_0x2c84('0x2e')](handleEntityNotFound(_0x536ac5,null))[_0x2c84('0x2e')](respondWithStatusCode(_0x536ac5,null))['catch'](handleError(_0x536ac5,null));};exports[_0x2c84('0xa1')]=function(_0x2a61b0,_0x1f3f53,_0xe6983a){return BPromise[_0x2c84('0xa2')]()[_0x2c84('0x2e')](function(){if(!_0x2a61b0['query']['path']){throw new Error(_0x2c84('0xa3'));}if(!_0x2a61b0['query'][_0x2c84('0xa4')]){throw new Error(_0x2c84('0xa5'));}var _0x3511ce=_0x2a61b0[_0x2c84('0x3f')][_0x2c84('0xa6')]?_0x2a61b0[_0x2c84('0x3f')]['hostname']+':'+_0x2a61b0[_0x2c84('0x3f')]['port']:_0x2c84('0xa7')+_0x2a61b0[_0x2c84('0x3f')][_0x2c84('0xa4')];var _0x4c3955=_0x2a61b0[_0x2c84('0x3f')][_0x2c84('0x24')]?_0x2a61b0[_0x2c84('0x3f')]['json']:!![];var _0x26b75e=_0x2a61b0[_0x2c84('0x3f')]['encoding']?_0x2a61b0[_0x2c84('0x3f')][_0x2c84('0xa8')]:null;var _0x55b360={'method':_0x2a61b0[_0x2c84('0xa9')],'uri':util[_0x2c84('0x58')](_0x2c84('0xaa'),_0x3511ce,_0x2a61b0[_0x2c84('0x3f')]['path']),'json':_0x4c3955,'resolveWithFullResponse':!![],'encoding':_0x26b75e,'qs':_0x2a61b0['query']};if(_0x2a61b0[_0x2c84('0xab')]){_0x55b360[_0x2c84('0xab')]=_0x2a61b0[_0x2c84('0xab')];if(_0x55b360['headers'][_0x2c84('0xac')]){delete _0x55b360[_0x2c84('0xab')][_0x2c84('0xac')];}}if(_0x55b360[_0x2c84('0xab')][_0x2c84('0xad')]){delete _0x55b360['headers'][_0x2c84('0xad')];}return rp(_0x55b360);})['then'](function(_0x3d4fbd){if(_0x3d4fbd){_0x1f3f53[_0x2c84('0x29')](_0x3d4fbd[_0x2c84('0xab')]);logger[_0x2c84('0x6a')](_0x3d4fbd[_0x2c84('0x97')]);if(_[_0x2c84('0xae')](_0x2a61b0[_0x2c84('0x3f')][_0x2c84('0x6')],'download')&&_0x3d4fbd[_0x2c84('0xaf')]==0x1f4){return _0x1f3f53[_0x2c84('0x21')](_0x3d4fbd[_0x2c84('0xaf')]);}else{return _0x1f3f53[_0x2c84('0x22')](_0x3d4fbd[_0x2c84('0xaf')])[_0x2c84('0x34')](_0x3d4fbd[_0x2c84('0x97')]);}}else{return _0x1f3f53[_0x2c84('0x21')](0xc8);}})[_0x2c84('0x51')](handleError(_0x1f3f53,null));};exports['webhookPost']=function(_0x1a61aa,_0x3ba920,_0x215215){return BPromise[_0x2c84('0xa2')]()[_0x2c84('0x2e')](function(){if(!_0x1a61aa['query']['path']){throw new Error(_0x2c84('0xa3'));}if(!_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0xa4')]){throw new Error(_0x2c84('0xa5'));}var _0x7a76a4=_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0xa6')]?_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0xa6')]+':'+_0x1a61aa['query'][_0x2c84('0xa4')]:_0x2c84('0xa7')+_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0xa4')];var _0x46f9ed=_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0x24')]?_0x1a61aa['query'][_0x2c84('0x24')]:!![];var _0x275bd5=_0x1a61aa['query']['encoding']?_0x1a61aa[_0x2c84('0x3f')][_0x2c84('0xa8')]:null;var _0x4bf67e={'method':_0x1a61aa[_0x2c84('0xa9')],'uri':util[_0x2c84('0x58')]('%s%s',_0x7a76a4,_0x1a61aa['query'][_0x2c84('0x6')]),'json':_0x46f9ed,'resolveWithFullResponse':!![],'encoding':_0x275bd5,'body':_0x1a61aa['body']};if(_0x1a61aa['headers']){_0x4bf67e[_0x2c84('0xab')]=_0x1a61aa[_0x2c84('0xab')];if(_0x4bf67e[_0x2c84('0xab')][_0x2c84('0xac')]){delete _0x4bf67e[_0x2c84('0xab')][_0x2c84('0xac')];}}if(_0x4bf67e[_0x2c84('0xab')][_0x2c84('0xad')]){delete _0x4bf67e[_0x2c84('0xab')]['content-type'];}return rp(_0x4bf67e);})['then'](function(_0x11afa9){if(_0x11afa9){_0x3ba920['set'](_0x11afa9[_0x2c84('0xab')]);logger[_0x2c84('0x6a')](_0x11afa9['body']);return _0x3ba920[_0x2c84('0x22')](_0x11afa9[_0x2c84('0xaf')])['send'](_0x11afa9[_0x2c84('0x97')]);}else{return _0x3ba920[_0x2c84('0x21')](0xc8);}})[_0x2c84('0x51')](handleError(_0x3ba920,null));};
\ No newline at end of file