Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / plugin / plugin.controller.js
index 33f348f..0df8c7a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x979f=['\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','%s%s','headers','content-length','content-type','endsWith','statusCode','webhookPost','resolve','method','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','extract-zip','archiver','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','redis','localhost','socket.io-emitter','./plugin.socket','register','end','status','json','count','offset','set','Content-Range','apply','reject','update','then','destroy','get','Plugins','UserProfileResource','sendStatus','error','stack','name','send','index','map','Plugin','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','filters','pick','filter','VIRTUAL','merge','where','includeAll','include','catch','show','params','options','server/files/plugins','%s.zip','basename','createWriteStream','zip','code','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','join','root','attachments/**/*','finalize','close','existsSync','Plugin\x20not\x20found','format','unlinkSync','info','Temporary\x20file\x20removed','upload','file','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','readdirSync','Invalid\x20plugin\x20structure','lstatSync','some','Plugin\x20manifest\x20missing','manifest.json','parse','undefined','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','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','sidebar','always','icon','icon-apps','html','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','create','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','find','Extracted\x20folder\x20removed','body','delete','dirname','webhookGet'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x979f,0x15d));var _0xf979=function(_0x11d153,_0xe9684e){_0x11d153=_0x11d153-0x0;var _0x5cd743=_0x979f[_0x11d153];return _0x5cd743;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf979('0x0'));var rimraf=require(_0xf979('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf979('0x2'));var rp=require(_0xf979('0x3'));var moment=require(_0xf979('0x4'));var BPromise=require(_0xf979('0x5'));var Mustache=require(_0xf979('0x6'));var util=require(_0xf979('0x7'));var path=require(_0xf979('0x8'));var sox=require(_0xf979('0x9'));var csv=require(_0xf979('0xa'));var ejs=require(_0xf979('0xb'));var fs=require('fs');var _=require(_0xf979('0xc'));var squel=require(_0xf979('0xd'));var crypto=require(_0xf979('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf979('0xf'));var toCsv=require(_0xf979('0xa'));var querystring=require('querystring');var Papa=require(_0xf979('0x10'));var extract=require(_0xf979('0x11'));var rimraf=require('rimraf');var archiver=require(_0xf979('0x12'));var Redis=require(_0xf979('0x13'));var authService=require('../../components/auth/service');var qs=require(_0xf979('0x14'));var as=require(_0xf979('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf979('0x16'));var utils=require(_0xf979('0x17'));var config=require('../../config/environment');var db=require(_0xf979('0x18'))['db'];config['redis']=_['defaults'](config[_0xf979('0x19')],{'host':_0xf979('0x1a'),'port':0x18eb});var socket=require(_0xf979('0x1b'))(new Redis(config[_0xf979('0x19')]));require(_0xf979('0x1c'))[_0xf979('0x1d')](socket);function respondWithStatusCode(_0x571161,_0x2f62a8){_0x2f62a8=_0x2f62a8||0xcc;return function(_0xd9daf0){if(_0xd9daf0){return _0x571161['sendStatus'](_0x2f62a8);}return _0x571161['status'](_0x2f62a8)[_0xf979('0x1e')]();};}function respondWithResult(_0x5073cc,_0x59a590){_0x59a590=_0x59a590||0xc8;return function(_0x2fdfa2){if(_0x2fdfa2){return _0x5073cc[_0xf979('0x1f')](_0x59a590)[_0xf979('0x20')](_0x2fdfa2);}};}function respondWithFilteredResult(_0x3c2593,_0x25d8bf){return function(_0xa7d2d6){if(_0xa7d2d6){var _0x1c03cf=_0xa7d2d6[_0xf979('0x21')],_0x121450=_0x25d8bf[_0xf979('0x22')],_0x4df2e7=_0x25d8bf[_0xf979('0x22')]+_0x25d8bf['limit'],_0x2b3bb1;if(_0x4df2e7>=_0x1c03cf){_0x4df2e7=_0x1c03cf;_0x2b3bb1=0xc8;}else{_0x2b3bb1=0xce;}_0x3c2593[_0xf979('0x1f')](_0x2b3bb1);return _0x3c2593[_0xf979('0x23')](_0xf979('0x24'),_0x121450+'-'+_0x4df2e7+'/'+_0x1c03cf)[_0xf979('0x20')](_0xa7d2d6);}return null;};}function patchUpdates(_0x2a6db1){return function(_0x410bf0){try{jsonpatch[_0xf979('0x25')](_0x410bf0,_0x2a6db1,!![]);}catch(_0x1ac0b2){return BPromise[_0xf979('0x26')](_0x1ac0b2);}return _0x410bf0['save']();};}function saveUpdates(_0x4dd784,_0x195291){return function(_0x1b548d){if(_0x1b548d){return _0x1b548d[_0xf979('0x27')](_0x4dd784)[_0xf979('0x28')](function(_0x593ba6){return _0x593ba6;});}return null;};}function removeEntity(_0xfd3b7c,_0x3e4948){return function(_0x15111e){if(_0x15111e){return _0x15111e[_0xf979('0x29')]()['then'](function(){var _0x33c243=_0x15111e[_0xf979('0x2a')]({'plain':!![]});var _0x4ef47d=_0xf979('0x2b');return db[_0xf979('0x2c')][_0xf979('0x29')]({'where':{'type':_0x4ef47d,'resourceId':_0x33c243['id']}})[_0xf979('0x28')](function(){return _0x15111e;});})[_0xf979('0x28')](function(){_0xfd3b7c['status'](0xcc)[_0xf979('0x1e')]();});}};}function handleEntityNotFound(_0x16eade,_0x1520b2){return function(_0x358e9c){if(!_0x358e9c){_0x16eade[_0xf979('0x2d')](0x194);}return _0x358e9c;};}function handleError(_0x138f9b,_0x28d388){_0x28d388=_0x28d388||0x1f4;return function(_0x2c1eba){logger[_0xf979('0x2e')](_0x2c1eba[_0xf979('0x2f')]);if(_0x2c1eba['name']){delete _0x2c1eba[_0xf979('0x30')];}_0x138f9b[_0xf979('0x1f')](_0x28d388)[_0xf979('0x31')](_0x2c1eba);};}exports[_0xf979('0x32')]=function(_0x35b13e,_0x6fdf4e){var _0x4a6b65={},_0x56f47f={},_0x19602c={'count':0x0,'rows':[]};var _0x5770b0=_[_0xf979('0x33')](db[_0xf979('0x34')][_0xf979('0x35')],function(_0x2602f7){return{'name':_0x2602f7[_0xf979('0x36')],'type':_0x2602f7[_0xf979('0x37')][_0xf979('0x38')]};});_0x56f47f[_0xf979('0x39')]=_[_0xf979('0x33')](_0x5770b0,_0xf979('0x30'));_0x56f47f[_0xf979('0x3a')]=_[_0xf979('0x3b')](_0x35b13e['query']);_0x56f47f['filters']=_[_0xf979('0x3c')](_0x56f47f['model'],_0x56f47f[_0xf979('0x3a')]);_0x4a6b65[_0xf979('0x3d')]=_[_0xf979('0x3c')](_0x56f47f[_0xf979('0x39')],qs[_0xf979('0x3e')](_0x35b13e[_0xf979('0x3a')]['fields']));_0x4a6b65['attributes']=_0x4a6b65[_0xf979('0x3d')][_0xf979('0x3f')]?_0x4a6b65['attributes']:_0x56f47f['model'];if(!_0x35b13e[_0xf979('0x3a')][_0xf979('0x40')](_0xf979('0x41'))){_0x4a6b65[_0xf979('0x42')]=qs[_0xf979('0x42')](_0x35b13e['query']['limit']);_0x4a6b65[_0xf979('0x22')]=qs[_0xf979('0x22')](_0x35b13e[_0xf979('0x3a')][_0xf979('0x22')]);}_0x4a6b65[_0xf979('0x43')]=qs[_0xf979('0x44')](_0x35b13e[_0xf979('0x3a')]['sort']);_0x4a6b65['where']=qs[_0xf979('0x45')](_[_0xf979('0x46')](_0x35b13e[_0xf979('0x3a')],_0x56f47f[_0xf979('0x45')]));if(_0x35b13e[_0xf979('0x3a')][_0xf979('0x47')]){_0x4a6b65['where']=_['merge'](_0x4a6b65['where'],{'$or':_[_0xf979('0x33')](_0x5770b0,function(_0x190edf){if(_0x190edf[_0xf979('0x37')]!==_0xf979('0x48')){var _0x385d68={};_0x385d68[_0x190edf[_0xf979('0x30')]]={'$like':'%'+_0x35b13e['query']['filter']+'%'};return _0x385d68;}})});}_0x4a6b65=_[_0xf979('0x49')]({},_0x4a6b65,_0x35b13e['options']);var _0x4e78c6={'where':_0x4a6b65[_0xf979('0x4a')]};return db['Plugin'][_0xf979('0x21')](_0x4e78c6)[_0xf979('0x28')](function(_0x463b8c){_0x19602c[_0xf979('0x21')]=_0x463b8c;if(_0x35b13e[_0xf979('0x3a')][_0xf979('0x4b')]){_0x4a6b65[_0xf979('0x4c')]=[{'all':!![]}];}return db['Plugin']['findAll'](_0x4a6b65);})[_0xf979('0x28')](function(_0x3c1ee4){_0x19602c['rows']=_0x3c1ee4;return _0x19602c;})['then'](respondWithFilteredResult(_0x6fdf4e,_0x4a6b65))[_0xf979('0x4d')](handleError(_0x6fdf4e,null));};exports[_0xf979('0x4e')]=function(_0x34eed2,_0x4c0234){var _0x34117a={'raw':!![],'where':{'id':_0x34eed2[_0xf979('0x4f')]['id']}},_0x2492f6={};_0x2492f6[_0xf979('0x39')]=_['keys'](db[_0xf979('0x34')][_0xf979('0x35')]);_0x2492f6[_0xf979('0x3a')]=_[_0xf979('0x3b')](_0x34eed2[_0xf979('0x3a')]);_0x2492f6[_0xf979('0x45')]=_[_0xf979('0x3c')](_0x2492f6['model'],_0x2492f6[_0xf979('0x3a')]);_0x34117a['attributes']=_['intersection'](_0x2492f6[_0xf979('0x39')],qs[_0xf979('0x3e')](_0x34eed2['query'][_0xf979('0x3e')]));_0x34117a[_0xf979('0x3d')]=_0x34117a['attributes'][_0xf979('0x3f')]?_0x34117a[_0xf979('0x3d')]:_0x2492f6['model'];if(_0x34eed2[_0xf979('0x3a')][_0xf979('0x4b')]){_0x34117a[_0xf979('0x4c')]=[{'all':!![]}];}_0x34117a=_['merge']({},_0x34117a,_0x34eed2[_0xf979('0x50')]);return db[_0xf979('0x34')]['find'](_0x34117a)['then'](handleEntityNotFound(_0x4c0234,null))[_0xf979('0x28')](respondWithResult(_0x4c0234,null))['catch'](handleError(_0x4c0234,null));};exports['download']=function(_0x5e89a7,_0x3362de,_0x212f1e){return db['Plugin']['find']({'where':{'id':_0x5e89a7['params']['id']},'attributes':['name',_0xf979('0x8')],'raw':!![]})[_0xf979('0x28')](handleEntityNotFound(_0x3362de,null))[_0xf979('0x28')](function(_0x5eccf7){if(_0x5eccf7){var _0x18b72b=path['join'](config['root'],_0xf979('0x51'),util['format'](_0xf979('0x52'),path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')])));var _0x205dce=fs[_0xf979('0x54')](_0x18b72b);var _0x3db7d9=archiver(_0xf979('0x55'),{'zlib':{'level':0x9}});_0x3db7d9['on']('warning',function(_0x4a9e0b){if(_0x4a9e0b[_0xf979('0x56')]==='ENOENT'){logger[_0xf979('0x2e')](_0x4a9e0b);}else{throw new db[(_0xf979('0x57'))][(_0xf979('0x58'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0x3db7d9['on'](_0xf979('0x2e'),function(_0x41dbde){throw new db[(_0xf979('0x57'))]['Error'](_0xf979('0x59'));});_0x3db7d9['pipe'](_0x205dce);_0x3db7d9[_0xf979('0x5a')]('**/*',{'cwd':path[_0xf979('0x5b')](config[_0xf979('0x5c')],'server/files/plugins',path['dirname'](_0x5eccf7[_0xf979('0x8')])),'ignore':[path[_0xf979('0x5b')](path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')]),'node_modules/**/*'),path[_0xf979('0x5b')](path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')]),_0xf979('0x5d'))],'nodir':!![]})[_0xf979('0x5e')]();_0x205dce['on'](_0xf979('0x5f'),function(){if(!fs[_0xf979('0x60')](_0x18b72b)){throw new db[(_0xf979('0x57'))]['Error'](_0xf979('0x61'));}return _0x3362de['download'](_0x18b72b,util[_0xf979('0x62')](_0xf979('0x52'),path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')])),function(_0x235e55){if(_0x235e55){throw new db[(_0xf979('0x57'))][(_0xf979('0x58'))]('Error\x20while\x20downloading\x20the\x20plugin');}fs[_0xf979('0x63')](_0x18b72b);logger[_0xf979('0x64')]('Download\x20completed');logger[_0xf979('0x64')](_0xf979('0x65'));});});}return null;})[_0xf979('0x4d')](handleError(_0x3362de,null));};exports[_0xf979('0x66')]=function(_0x3322d8,_0x53d159,_0x4fb868){var _0x3bd1c8=path[_0xf979('0x53')](_0x3322d8[_0xf979('0x67')][_0xf979('0x68')],path['extname'](_0x3322d8[_0xf979('0x67')]['filename']));var _0xfe6033=path[_0xf979('0x5b')](config[_0xf979('0x5c')],_0xf979('0x51'),_0x3322d8[_0xf979('0x67')][_0xf979('0x68')]);var _0x5c27c4=path['join'](config['root'],_0xf979('0x51'),_0x3bd1c8);logger[_0xf979('0x64')](_0xf979('0x69'),_0xfe6033);logger['info'](_0xf979('0x6a'),_0x5c27c4);try{fs[_0xf979('0x6b')](_0xfe6033,parseInt('0777',0x8));extract(_0xfe6033,{'dir':_0x5c27c4},function(_0x142589){if(_0x142589){logger[_0xf979('0x2e')](_0x142589);handleError(_0x142589,!![]);};var _0x571556=fs[_0xf979('0x6c')](_0x5c27c4);if(_0x571556[_0xf979('0x3f')]>0x1){removeReferences(_0xfe6033,_0x5c27c4);logger[_0xf979('0x2e')](_0xf979('0x6d'));return _0x4fb868(new Error('Invalid\x20plugin\x20structure'));}var _0x2f2511=fs[_0xf979('0x6e')](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0]));if(_0x2f2511['isFile']()){removeReferences(_0xfe6033,_0x5c27c4);logger['error'](_0xf979('0x6d'));return _0x4fb868(new Error(_0xf979('0x6d')));}if(_0x2f2511['isDirectory']()){var _0x1e0aa7=fs['readdirSync'](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0]));if(_0x1e0aa7[_0xf979('0x3f')]===0x0){removeReferences(_0xfe6033,_0x5c27c4);logger['error'](_0xf979('0x6d'));return _0x4fb868(new Error('Invalid\x20plugin\x20structure'));}var _0xcb6425=_0x1e0aa7[_0xf979('0x6f')](function(_0x3649ce){return _0x3649ce==='manifest.json';});if(!_0xcb6425){return _0x4fb868(new Error(_0xf979('0x70')));}var _0x312542=fs['readFileSync'](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0],_0xf979('0x71')));var _0x1ba182=JSON[_0xf979('0x72')](_0x312542);if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x30')]){return _0x4fb868(new Error(_0xf979('0x74')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x37')]){return _0x4fb868(new Error(_0xf979('0x75')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x76')]){return _0x4fb868(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')]){return _0x4fb868(new Error(_0xf979('0x78')));}if(_0x1ba182['type']==='html'){if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]){return _0x4fb868(new Error(_0xf979('0x7a')));}if('undefined'==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7b')]&&_0xf979('0x73')==typeof _0x1ba182['parameters'][_0xf979('0x79')][_0xf979('0x7c')]){return _0x4fb868(new Error(_0xf979('0x7d')));}}else if(_0x1ba182['type']===_0xf979('0x7e')){if('undefined'==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x7f')]){return _0x4fb868(new Error(_0xf979('0x80')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x81')]){return _0x4fb868(new Error(_0xf979('0x82')));}}else{return _0x4fb868(new Error(_0xf979('0x83')));}var _0xbdfb32=_0x1ba182[_0xf979('0x30')];var _0x69ec3a=_0x1ba182['description'];var _0x51fe7c=_0x1ba182[_0xf979('0x37')];var _0x3684bb=_0x1ba182[_0xf979('0x84')]?_0x1ba182[_0xf979('0x84')]:_0xf979('0x85');var _0x23c417=_0x1ba182[_0xf979('0x86')]?_0x1ba182['icon']:_0xf979('0x87');var _0x2988aa='';var _0x52f3ba='';var _0x46eb89='';var _0x53418f='';var _0x35ef4b=_0x1ba182[_0xf979('0x76')];if(_0x51fe7c===_0xf979('0x88')){if('undefined'!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7b')]){var _0x1e716f=_0x1ba182['parameters']['views'][_0xf979('0x7b')];if(!/^(f|ht)tps?:\/\//i[_0xf979('0x89')](_0x1e716f)){_0x2988aa=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x1e716f);}else{_0x2988aa=_0x1e716f;}}else{logger[_0xf979('0x64')](_0xf979('0x8b'));}if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7c')]){var _0x84e5eb=_0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7c')];if(!/^(f|ht)tps?:\/\//i['test'](_0x84e5eb)){_0x52f3ba=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x84e5eb);}else{_0x52f3ba=_0x84e5eb;}}else{logger[_0xf979('0x64')](_0xf979('0x8c'));}}else if(_0x51fe7c===_0xf979('0x7e')){_0x46eb89=_0x1ba182[_0xf979('0x77')][_0xf979('0x7f')];_0x53418f=_0x1ba182[_0xf979('0x77')][_0xf979('0x81')];if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]){if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]['admin']){var _0x1e716f=_0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7b')];if(!/^(f|ht)tps?:\/\//i['test'](_0x1e716f)){_0x2988aa=path['join'](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x1e716f);}else{_0x2988aa=_0x1e716f;}}if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7c')]){var _0x84e5eb=_0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7c')];if(!/^(f|ht)tps?:\/\//i[_0xf979('0x89')](_0x84e5eb)){_0x52f3ba=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x84e5eb);}else{_0x52f3ba=_0x84e5eb;}}}}var _0x20a102={'name':_0xbdfb32,'description':_0x69ec3a,'path':path[_0xf979('0x5b')](_0x3bd1c8,_0x571556[0x0]),'type':_0x51fe7c,'sidebar':_0x3684bb,'icon':_0x23c417,'adminUrl':_0x2988aa,'agentUrl':_0x52f3ba,'scriptName':_0x46eb89,'scriptPath':_0x53418f,'version':_0x35ef4b};removeReferences(_0xfe6033,null);return db[_0xf979('0x34')][_0xf979('0x8d')](_0x20a102)[_0xf979('0x28')](function(_0xd3f024){var _0x1a5ceb={'role':_0x3322d8['body'][_0xf979('0x8e')],'userProfileId':_0x3322d8['body']['userProfileId']};if(!_0x1a5ceb)throw new Error(_0xf979('0x8f'));if(_0x1a5ceb[_0xf979('0x8e')]===_0xf979('0x90')){var _0x25e255=_0xd3f024['get']({'plain':!![]});return db[_0xf979('0x91')][_0xf979('0x92')]({'where':{'name':_0xf979('0x2b'),'userProfileId':_0x1a5ceb['userProfileId']},'raw':!![]})[_0xf979('0x28')](function(_0x31bc79){if(_0x31bc79&&_0x31bc79['autoAssociation']===0x0){return db[_0xf979('0x2c')][_0xf979('0x8d')]({'name':_0x25e255[_0xf979('0x30')],'resourceId':_0x25e255['id'],'type':_0x31bc79['name'],'sectionId':_0x31bc79['id']},{})[_0xf979('0x28')](function(){return _0xd3f024;});}else{return _0xd3f024;}})[_0xf979('0x4d')](function(_0x39c732){logger[_0xf979('0x2e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x39c732);throw _0x39c732;});}return _0xd3f024;})[_0xf979('0x28')](respondWithResult(_0x53d159,null))['catch'](handleError(_0x53d159,null));}});}catch(_0x392af6){_0x53d159['status'](0x1f4)[_0xf979('0x31')](_0x392af6);}};function removeReferences(_0x2e8aa7,_0x26fa7d){try{if(_0x2e8aa7){fs[_0xf979('0x63')](_0x2e8aa7);logger[_0xf979('0x64')]('Zip\x20archive\x20removed');}if(_0x26fa7d){rimraf(_0x26fa7d,function(){});logger['info'](_0xf979('0x93'));}}catch(_0x368629){logger[_0xf979('0x2e')](_0x368629);}}exports[_0xf979('0x27')]=function(_0x2ce53b,_0x20500d,_0x2a84bb){return db[_0xf979('0x34')][_0xf979('0x92')]({'where':{'id':_0x2ce53b[_0xf979('0x4f')]['id']}})[_0xf979('0x28')](handleEntityNotFound(_0x20500d,null))['then'](saveUpdates(_0x2ce53b[_0xf979('0x94')],null))['then'](respondWithResult(_0x20500d,null))[_0xf979('0x4d')](handleError(_0x20500d,null));};exports[_0xf979('0x95')]=function(_0x419bf3,_0x47da6a,_0x422852){return db[_0xf979('0x34')][_0xf979('0x92')]({'where':{'id':_0x419bf3['params']['id']}})[_0xf979('0x28')](function(_0x24631e){if(_0x24631e){return _0x24631e[_0xf979('0x29')]();}})[_0xf979('0x28')](function(_0x1b4766){rimraf(path[_0xf979('0x5b')](config[_0xf979('0x5c')],_0xf979('0x51'),path[_0xf979('0x96')](_0x1b4766['path'])),function(){});return _0x1b4766;})['then'](handleEntityNotFound(_0x47da6a,null))[_0xf979('0x28')](respondWithStatusCode(_0x47da6a,null))[_0xf979('0x4d')](handleError(_0x47da6a,null));};exports[_0xf979('0x97')]=function(_0x436b5b,_0x2a8a1d,_0x1fa842){return BPromise['resolve']()[_0xf979('0x28')](function(){if(!_0x436b5b[_0xf979('0x3a')][_0xf979('0x8')]){throw new Error(_0xf979('0x98'));}if(!_0x436b5b[_0xf979('0x3a')][_0xf979('0x99')]){throw new Error(_0xf979('0x9a'));}var _0x523aee=_0x436b5b[_0xf979('0x3a')][_0xf979('0x9b')]?_0x436b5b[_0xf979('0x3a')][_0xf979('0x9b')]+':'+_0x436b5b[_0xf979('0x3a')]['port']:_0xf979('0x9c')+_0x436b5b[_0xf979('0x3a')]['port'];var _0x573c42=_0x436b5b['query'][_0xf979('0x20')]?_0x436b5b[_0xf979('0x3a')][_0xf979('0x20')]:!![];var _0x1c1818=_0x436b5b[_0xf979('0x3a')]['encoding']?_0x436b5b[_0xf979('0x3a')][_0xf979('0x9d')]:null;var _0x339e0b={'method':_0x436b5b['method'],'uri':util[_0xf979('0x62')](_0xf979('0x9e'),_0x523aee,_0x436b5b[_0xf979('0x3a')][_0xf979('0x8')]),'json':_0x573c42,'resolveWithFullResponse':!![],'encoding':_0x1c1818,'qs':_0x436b5b[_0xf979('0x3a')]};if(_0x436b5b[_0xf979('0x9f')]){_0x339e0b[_0xf979('0x9f')]=_0x436b5b[_0xf979('0x9f')];if(_0x339e0b['headers'][_0xf979('0xa0')]){delete _0x339e0b[_0xf979('0x9f')][_0xf979('0xa0')];}}if(_0x339e0b['headers'][_0xf979('0xa1')]){delete _0x339e0b[_0xf979('0x9f')]['content-type'];}return rp(_0x339e0b);})[_0xf979('0x28')](function(_0x4a7ff2){if(_0x4a7ff2){_0x2a8a1d['set'](_0x4a7ff2[_0xf979('0x9f')]);logger['info'](_0x4a7ff2[_0xf979('0x94')]);if(_[_0xf979('0xa2')](_0x436b5b['query']['path'],'download')&&_0x4a7ff2[_0xf979('0xa3')]==0x1f4){return _0x2a8a1d[_0xf979('0x2d')](_0x4a7ff2[_0xf979('0xa3')]);}else{return _0x2a8a1d['status'](_0x4a7ff2[_0xf979('0xa3')])['send'](_0x4a7ff2[_0xf979('0x94')]);}}else{return _0x2a8a1d['sendStatus'](0xc8);}})[_0xf979('0x4d')](handleError(_0x2a8a1d,null));};exports[_0xf979('0xa4')]=function(_0x3c2071,_0xc9f796,_0x25d5e0){return BPromise[_0xf979('0xa5')]()[_0xf979('0x28')](function(){if(!_0x3c2071[_0xf979('0x3a')][_0xf979('0x8')]){throw new Error(_0xf979('0x98'));}if(!_0x3c2071['query'][_0xf979('0x99')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x57782=_0x3c2071[_0xf979('0x3a')]['hostname']?_0x3c2071[_0xf979('0x3a')]['hostname']+':'+_0x3c2071[_0xf979('0x3a')][_0xf979('0x99')]:_0xf979('0x9c')+_0x3c2071['query'][_0xf979('0x99')];var _0x2ec4f8=_0x3c2071['query'][_0xf979('0x20')]?_0x3c2071[_0xf979('0x3a')]['json']:!![];var _0x5a221b=_0x3c2071[_0xf979('0x3a')][_0xf979('0x9d')]?_0x3c2071[_0xf979('0x3a')][_0xf979('0x9d')]:null;var _0x110d43={'method':_0x3c2071[_0xf979('0xa6')],'uri':util['format']('%s%s',_0x57782,_0x3c2071[_0xf979('0x3a')][_0xf979('0x8')]),'json':_0x2ec4f8,'resolveWithFullResponse':!![],'encoding':_0x5a221b,'body':_0x3c2071[_0xf979('0x94')]};if(_0x3c2071['headers']){_0x110d43[_0xf979('0x9f')]=_0x3c2071[_0xf979('0x9f')];if(_0x110d43[_0xf979('0x9f')][_0xf979('0xa0')]){delete _0x110d43[_0xf979('0x9f')][_0xf979('0xa0')];}}if(_0x110d43[_0xf979('0x9f')]['content-type']){delete _0x110d43[_0xf979('0x9f')][_0xf979('0xa1')];}return rp(_0x110d43);})[_0xf979('0x28')](function(_0x151ba5){if(_0x151ba5){_0xc9f796[_0xf979('0x23')](_0x151ba5['headers']);logger[_0xf979('0x64')](_0x151ba5['body']);return _0xc9f796[_0xf979('0x1f')](_0x151ba5[_0xf979('0xa3')])['send'](_0x151ba5['body']);}else{return _0xc9f796[_0xf979('0x2d')](0xc8);}})[_0xf979('0x4d')](handleError(_0xc9f796,null));};
\ No newline at end of file
+var _0xfad2=['nolimit','sort','pick','filter','merge','includeAll','include','findAll','rows','catch','params','find','root','server/files/plugins','format','%s.zip','basename','createWriteStream','zip','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','**/*','join','dirname','node_modules/**/*','finalize','existsSync','Plugin\x20not\x20found','download','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Download\x20completed','upload','extname','filename','file','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync','Invalid\x20plugin\x20structure','isFile','isDirectory','some','manifest.json','readFileSync','parse','Invalid\x20manifest:\x20type\x20missing','Invalid\x20manifest:\x20version\x20not\x20specified','parameters','Invalid\x20manifest:\x20parameters\x20missing','html','views','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','version','script','test','plugins','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','send','Extracted\x20folder\x20removed','webhookGet','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','port','encoding','%s%s','headers','content-length','content-type','endsWith','statusCode','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','http://localhost:','method','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','archiver','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','defaults','localhost','socket.io-emitter','redis','sendStatus','status','json','offset','undefined','limit','count','set','update','then','destroy','get','Plugins','end','error','stack','name','index','map','Plugin','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty'];(function(_0x347ef6,_0x3e5570){var _0x56d2c0=function(_0x37f8d2){while(--_0x37f8d2){_0x347ef6['push'](_0x347ef6['shift']());}};_0x56d2c0(++_0x3e5570);}(_0xfad2,0x1ab));var _0x2fad=function(_0x408d78,_0x23a521){_0x408d78=_0x408d78-0x0;var _0x59841c=_0xfad2[_0x408d78];return _0x59841c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x2fad('0x0'));var zipdir=require(_0x2fad('0x1'));var jsonpatch=require(_0x2fad('0x2'));var rp=require(_0x2fad('0x3'));var moment=require(_0x2fad('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x2fad('0x5'));var util=require(_0x2fad('0x6'));var path=require(_0x2fad('0x7'));var sox=require(_0x2fad('0x8'));var csv=require(_0x2fad('0x9'));var ejs=require(_0x2fad('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x2fad('0xb'));var squel=require(_0x2fad('0xc'));var crypto=require('crypto');var jsforce=require(_0x2fad('0xd'));var deskjs=require(_0x2fad('0xe'));var toCsv=require('to-csv');var querystring=require(_0x2fad('0xf'));var Papa=require(_0x2fad('0x10'));var extract=require('extract-zip');var rimraf=require(_0x2fad('0x0'));var archiver=require(_0x2fad('0x11'));var Redis=require(_0x2fad('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x2fad('0x13'));var as=require(_0x2fad('0x14'));var hardwareService=require(_0x2fad('0x15'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x2fad('0x16'));var licenseUtil=require(_0x2fad('0x17'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x2fad('0x18')](config['redis'],{'host':_0x2fad('0x19'),'port':0x18eb});var socket=require(_0x2fad('0x1a'))(new Redis(config[_0x2fad('0x1b')]));require('./plugin.socket')['register'](socket);function respondWithStatusCode(_0x13138a,_0x198b39){_0x198b39=_0x198b39||0xcc;return function(_0x808274){if(_0x808274){return _0x13138a[_0x2fad('0x1c')](_0x198b39);}return _0x13138a[_0x2fad('0x1d')](_0x198b39)['end']();};}function respondWithResult(_0x43f9d4,_0x59dc3e){_0x59dc3e=_0x59dc3e||0xc8;return function(_0x29ff19){if(_0x29ff19){return _0x43f9d4[_0x2fad('0x1d')](_0x59dc3e)[_0x2fad('0x1e')](_0x29ff19);}};}function respondWithFilteredResult(_0x396803,_0x287eef){return function(_0x2f8ddc){if(_0x2f8ddc){var _0x2a29f5=typeof _0x287eef[_0x2fad('0x1f')]===_0x2fad('0x20')&&typeof _0x287eef[_0x2fad('0x21')]==='undefined';var _0x55acfa=_0x2f8ddc[_0x2fad('0x22')];var _0x356652=_0x2a29f5?0x0:_0x287eef['offset'];var _0x3441c1=_0x2a29f5?_0x2f8ddc[_0x2fad('0x22')]:_0x287eef[_0x2fad('0x1f')]+_0x287eef['limit'];var _0x4653f0;if(_0x3441c1>=_0x55acfa){_0x3441c1=_0x55acfa;_0x4653f0=0xc8;}else{_0x4653f0=0xce;}_0x396803['status'](_0x4653f0);return _0x396803[_0x2fad('0x23')]('Content-Range',_0x356652+'-'+_0x3441c1+'/'+_0x55acfa)[_0x2fad('0x1e')](_0x2f8ddc);}return null;};}function patchUpdates(_0x19e767){return function(_0x5ad4ca){try{jsonpatch['apply'](_0x5ad4ca,_0x19e767,!![]);}catch(_0xb3b81e){return BPromise['reject'](_0xb3b81e);}return _0x5ad4ca['save']();};}function saveUpdates(_0x2da45c,_0x350057){return function(_0x4feab0){if(_0x4feab0){return _0x4feab0[_0x2fad('0x24')](_0x2da45c)[_0x2fad('0x25')](function(_0xea335c){return _0xea335c;});}return null;};}function removeEntity(_0x1c61e1,_0xb2bee4){return function(_0x17aa85){if(_0x17aa85){return _0x17aa85[_0x2fad('0x26')]()[_0x2fad('0x25')](function(){var _0x522ede=_0x17aa85[_0x2fad('0x27')]({'plain':!![]});var _0x110fb1=_0x2fad('0x28');return db['UserProfileResource']['destroy']({'where':{'type':_0x110fb1,'resourceId':_0x522ede['id']}})[_0x2fad('0x25')](function(){return _0x17aa85;});})[_0x2fad('0x25')](function(){_0x1c61e1[_0x2fad('0x1d')](0xcc)[_0x2fad('0x29')]();});}};}function handleEntityNotFound(_0x3701f4,_0x2c601f){return function(_0x571b28){if(!_0x571b28){_0x3701f4['sendStatus'](0x194);}return _0x571b28;};}function handleError(_0x53349b,_0x346133){_0x346133=_0x346133||0x1f4;return function(_0xeb0485){logger[_0x2fad('0x2a')](_0xeb0485[_0x2fad('0x2b')]);if(_0xeb0485[_0x2fad('0x2c')]){delete _0xeb0485[_0x2fad('0x2c')];}_0x53349b['status'](_0x346133)['send'](_0xeb0485);};}exports[_0x2fad('0x2d')]=function(_0x426d11,_0x2b8d53){var _0x7a1148={},_0x55126f={},_0x5e43a5={'count':0x0,'rows':[]};var _0x294165=_[_0x2fad('0x2e')](db[_0x2fad('0x2f')]['rawAttributes'],function(_0x4a28fa){return{'name':_0x4a28fa['fieldName'],'type':_0x4a28fa[_0x2fad('0x30')][_0x2fad('0x31')]};});_0x55126f[_0x2fad('0x32')]=_[_0x2fad('0x2e')](_0x294165,_0x2fad('0x2c'));_0x55126f[_0x2fad('0x33')]=_[_0x2fad('0x34')](_0x426d11[_0x2fad('0x33')]);_0x55126f[_0x2fad('0x35')]=_[_0x2fad('0x36')](_0x55126f['model'],_0x55126f[_0x2fad('0x33')]);_0x7a1148[_0x2fad('0x37')]=_[_0x2fad('0x36')](_0x55126f[_0x2fad('0x32')],qs[_0x2fad('0x38')](_0x426d11[_0x2fad('0x33')]['fields']));_0x7a1148[_0x2fad('0x37')]=_0x7a1148[_0x2fad('0x37')][_0x2fad('0x39')]?_0x7a1148[_0x2fad('0x37')]:_0x55126f['model'];if(!_0x426d11[_0x2fad('0x33')][_0x2fad('0x3a')](_0x2fad('0x3b'))){_0x7a1148['limit']=qs[_0x2fad('0x21')](_0x426d11[_0x2fad('0x33')][_0x2fad('0x21')]);_0x7a1148['offset']=qs[_0x2fad('0x1f')](_0x426d11[_0x2fad('0x33')][_0x2fad('0x1f')]);}_0x7a1148['order']=qs[_0x2fad('0x3c')](_0x426d11[_0x2fad('0x33')][_0x2fad('0x3c')]);_0x7a1148['where']=qs[_0x2fad('0x35')](_[_0x2fad('0x3d')](_0x426d11['query'],_0x55126f[_0x2fad('0x35')]),_0x294165);if(_0x426d11[_0x2fad('0x33')][_0x2fad('0x3e')]){_0x7a1148['where']=_[_0x2fad('0x3f')](_0x7a1148['where'],{'$or':_[_0x2fad('0x2e')](_0x294165,function(_0x1e9d9d){if(_0x1e9d9d[_0x2fad('0x30')]!=='VIRTUAL'){var _0xe27759={};_0xe27759[_0x1e9d9d['name']]={'$like':'%'+_0x426d11[_0x2fad('0x33')][_0x2fad('0x3e')]+'%'};return _0xe27759;}})});}_0x7a1148=_[_0x2fad('0x3f')]({},_0x7a1148,_0x426d11['options']);var _0x39a520={'where':_0x7a1148['where']};return db[_0x2fad('0x2f')][_0x2fad('0x22')](_0x39a520)['then'](function(_0x22ea8f){_0x5e43a5['count']=_0x22ea8f;if(_0x426d11[_0x2fad('0x33')][_0x2fad('0x40')]){_0x7a1148[_0x2fad('0x41')]=[{'all':!![]}];}return db['Plugin'][_0x2fad('0x42')](_0x7a1148);})['then'](function(_0x8b48a5){_0x5e43a5[_0x2fad('0x43')]=_0x8b48a5;return _0x5e43a5;})['then'](respondWithFilteredResult(_0x2b8d53,_0x7a1148))[_0x2fad('0x44')](handleError(_0x2b8d53,null));};exports['show']=function(_0x1e5345,_0x3f6f79){var _0x26b6ed={'raw':!![],'where':{'id':_0x1e5345[_0x2fad('0x45')]['id']}},_0x49946a={};_0x49946a['model']=_[_0x2fad('0x34')](db['Plugin']['rawAttributes']);_0x49946a[_0x2fad('0x33')]=_['keys'](_0x1e5345[_0x2fad('0x33')]);_0x49946a[_0x2fad('0x35')]=_[_0x2fad('0x36')](_0x49946a[_0x2fad('0x32')],_0x49946a[_0x2fad('0x33')]);_0x26b6ed[_0x2fad('0x37')]=_['intersection'](_0x49946a['model'],qs[_0x2fad('0x38')](_0x1e5345[_0x2fad('0x33')][_0x2fad('0x38')]));_0x26b6ed[_0x2fad('0x37')]=_0x26b6ed['attributes'][_0x2fad('0x39')]?_0x26b6ed[_0x2fad('0x37')]:_0x49946a[_0x2fad('0x32')];if(_0x1e5345[_0x2fad('0x33')][_0x2fad('0x40')]){_0x26b6ed[_0x2fad('0x41')]=[{'all':!![]}];}_0x26b6ed=_[_0x2fad('0x3f')]({},_0x26b6ed,_0x1e5345['options']);return db[_0x2fad('0x2f')]['find'](_0x26b6ed)[_0x2fad('0x25')](handleEntityNotFound(_0x3f6f79,null))[_0x2fad('0x25')](respondWithResult(_0x3f6f79,null))['catch'](handleError(_0x3f6f79,null));};exports['download']=function(_0xeff101,_0x4c444a,_0x30ffdf){return db['Plugin'][_0x2fad('0x46')]({'where':{'id':_0xeff101[_0x2fad('0x45')]['id']},'attributes':[_0x2fad('0x2c'),_0x2fad('0x7')],'raw':!![]})[_0x2fad('0x25')](handleEntityNotFound(_0x4c444a,null))[_0x2fad('0x25')](function(_0xb13493){if(_0xb13493){var _0x504376=path['join'](config[_0x2fad('0x47')],_0x2fad('0x48'),util[_0x2fad('0x49')](_0x2fad('0x4a'),path[_0x2fad('0x4b')](_0xb13493[_0x2fad('0x7')])));var _0x5ba6ca=fs[_0x2fad('0x4c')](_0x504376);var _0x114c4a=archiver(_0x2fad('0x4d'),{'zlib':{'level':0x9}});_0x114c4a['on'](_0x2fad('0x4e'),function(_0x52de9a){if(_0x52de9a[_0x2fad('0x4f')]===_0x2fad('0x50')){logger[_0x2fad('0x2a')](_0x52de9a);}else{throw new db[(_0x2fad('0x51'))][(_0x2fad('0x52'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0x114c4a['on'](_0x2fad('0x2a'),function(_0x18f7ef){throw new db[(_0x2fad('0x51'))][(_0x2fad('0x52'))](_0x2fad('0x53'));});_0x114c4a['pipe'](_0x5ba6ca);_0x114c4a[_0x2fad('0x54')](_0x2fad('0x55'),{'cwd':path[_0x2fad('0x56')](config[_0x2fad('0x47')],_0x2fad('0x48'),path[_0x2fad('0x57')](_0xb13493[_0x2fad('0x7')])),'ignore':[path[_0x2fad('0x56')](path[_0x2fad('0x4b')](_0xb13493[_0x2fad('0x7')]),_0x2fad('0x58')),path[_0x2fad('0x56')](path[_0x2fad('0x4b')](_0xb13493[_0x2fad('0x7')]),'attachments/**/*')],'nodir':!![]})[_0x2fad('0x59')]();_0x5ba6ca['on']('close',function(){if(!fs[_0x2fad('0x5a')](_0x504376)){throw new db['Sequelize'][(_0x2fad('0x52'))](_0x2fad('0x5b'));}return _0x4c444a[_0x2fad('0x5c')](_0x504376,util[_0x2fad('0x49')]('%s.zip',path[_0x2fad('0x4b')](_0xb13493[_0x2fad('0x7')])),function(_0x208c59){if(_0x208c59){throw new db['Sequelize'][(_0x2fad('0x52'))](_0x2fad('0x5d'));}fs[_0x2fad('0x5e')](_0x504376);logger[_0x2fad('0x5f')](_0x2fad('0x60'));logger['info']('Temporary\x20file\x20removed');});});}return null;})['catch'](handleError(_0x4c444a,null));};exports[_0x2fad('0x61')]=function(_0x3b480b,_0x3e8271,_0x118e99){var _0x589b59=path[_0x2fad('0x4b')](_0x3b480b['file']['filename'],path[_0x2fad('0x62')](_0x3b480b['file'][_0x2fad('0x63')]));var _0x585856=path[_0x2fad('0x56')](config[_0x2fad('0x47')],'server/files/plugins',_0x3b480b[_0x2fad('0x64')][_0x2fad('0x63')]);var _0x4704ea=path[_0x2fad('0x56')](config[_0x2fad('0x47')],_0x2fad('0x48'),_0x589b59);logger[_0x2fad('0x5f')](_0x2fad('0x65'),_0x585856);logger[_0x2fad('0x5f')](_0x2fad('0x66'),_0x4704ea);try{fs[_0x2fad('0x67')](_0x585856,parseInt(_0x2fad('0x68'),0x8));extract(_0x585856,{'dir':_0x4704ea},function(_0x1a0c99){if(_0x1a0c99){logger[_0x2fad('0x2a')](_0x1a0c99);handleError(_0x1a0c99,!![]);};var _0x25f620=fs[_0x2fad('0x69')](_0x4704ea);if(_0x25f620[_0x2fad('0x39')]>0x1){removeReferences(_0x585856,_0x4704ea);logger[_0x2fad('0x2a')](_0x2fad('0x6a'));return _0x118e99(new Error(_0x2fad('0x6a')));}var _0x4a2aa8=fs['lstatSync'](path['join'](_0x4704ea,_0x25f620[0x0]));if(_0x4a2aa8[_0x2fad('0x6b')]()){removeReferences(_0x585856,_0x4704ea);logger['error'](_0x2fad('0x6a'));return _0x118e99(new Error('Invalid\x20plugin\x20structure'));}if(_0x4a2aa8[_0x2fad('0x6c')]()){var _0x4c10b6=fs[_0x2fad('0x69')](path[_0x2fad('0x56')](_0x4704ea,_0x25f620[0x0]));if(_0x4c10b6[_0x2fad('0x39')]===0x0){removeReferences(_0x585856,_0x4704ea);logger[_0x2fad('0x2a')](_0x2fad('0x6a'));return _0x118e99(new Error(_0x2fad('0x6a')));}var _0x2f1716=_0x4c10b6[_0x2fad('0x6d')](function(_0x4e772d){return _0x4e772d===_0x2fad('0x6e');});if(!_0x2f1716){return _0x118e99(new Error('Plugin\x20manifest\x20missing'));}var _0x5bc445=fs[_0x2fad('0x6f')](path[_0x2fad('0x56')](_0x4704ea,_0x25f620[0x0],_0x2fad('0x6e')));var _0x18fa51=JSON[_0x2fad('0x70')](_0x5bc445);if(_0x2fad('0x20')==typeof _0x18fa51[_0x2fad('0x2c')]){return _0x118e99(new Error('Invalid\x20manifest:\x20name\x20missing'));}if('undefined'==typeof _0x18fa51[_0x2fad('0x30')]){return _0x118e99(new Error(_0x2fad('0x71')));}if('undefined'==typeof _0x18fa51['version']){return _0x118e99(new Error(_0x2fad('0x72')));}if(_0x2fad('0x20')==typeof _0x18fa51[_0x2fad('0x73')]){return _0x118e99(new Error(_0x2fad('0x74')));}if(_0x18fa51[_0x2fad('0x30')]===_0x2fad('0x75')){if(_0x2fad('0x20')==typeof _0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')]){return _0x118e99(new Error('Invalid\x20manifest:\x20views\x20missing'));}if(_0x2fad('0x20')==typeof _0x18fa51['parameters']['views'][_0x2fad('0x77')]&&_0x2fad('0x20')==typeof _0x18fa51[_0x2fad('0x73')]['views'][_0x2fad('0x78')]){return _0x118e99(new Error(_0x2fad('0x79')));}}else if(_0x18fa51[_0x2fad('0x30')]==='script'){if('undefined'==typeof _0x18fa51[_0x2fad('0x73')][_0x2fad('0x7a')]){return _0x118e99(new Error(_0x2fad('0x7b')));}if(_0x2fad('0x20')==typeof _0x18fa51['parameters'][_0x2fad('0x7c')]){return _0x118e99(new Error(_0x2fad('0x7d')));}}else{return _0x118e99(new Error(_0x2fad('0x7e')));}var _0x1b6018=_0x18fa51[_0x2fad('0x2c')];var _0x477215=_0x18fa51[_0x2fad('0x7f')];var _0x5a31d9=_0x18fa51[_0x2fad('0x30')];var _0xd850a=_0x18fa51['sidebar']?_0x18fa51[_0x2fad('0x80')]:_0x2fad('0x81');var _0x10f814=_0x18fa51[_0x2fad('0x82')]?_0x18fa51[_0x2fad('0x82')]:_0x2fad('0x83');var _0x196e24='';var _0xf1d284='';var _0x22c0b7='';var _0x485a35='';var _0x1ae7d9=_0x18fa51[_0x2fad('0x84')];if(_0x5a31d9===_0x2fad('0x75')){if(_0x2fad('0x20')!=typeof _0x18fa51['parameters'][_0x2fad('0x76')]['admin']){var _0x5baf10=_0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')][_0x2fad('0x77')];if(!/^(f|ht)tps?:\/\//i['test'](_0x5baf10)){_0x196e24=path[_0x2fad('0x56')]('plugins',_0x589b59,_0x25f620[0x0],_0x5baf10);}else{_0x196e24=_0x5baf10;}}else{logger[_0x2fad('0x5f')]('Warning:\x20admin\x20view\x20not\x20specified');}if('undefined'!=typeof _0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')][_0x2fad('0x78')]){var _0x5039f2=_0x18fa51[_0x2fad('0x73')]['views'][_0x2fad('0x78')];if(!/^(f|ht)tps?:\/\//i['test'](_0x5039f2)){_0xf1d284=path['join']('plugins',_0x589b59,_0x25f620[0x0],_0x5039f2);}else{_0xf1d284=_0x5039f2;}}else{logger[_0x2fad('0x5f')]('Warning:\x20agent\x20view\x20not\x20specified');}}else if(_0x5a31d9===_0x2fad('0x85')){_0x22c0b7=_0x18fa51['parameters'][_0x2fad('0x7a')];_0x485a35=_0x18fa51['parameters']['scriptPath'];if(_0x2fad('0x20')!=typeof _0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')]){if(_0x2fad('0x20')!=typeof _0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')][_0x2fad('0x77')]){var _0x5baf10=_0x18fa51['parameters']['views']['admin'];if(!/^(f|ht)tps?:\/\//i[_0x2fad('0x86')](_0x5baf10)){_0x196e24=path[_0x2fad('0x56')]('plugins',_0x589b59,_0x25f620[0x0],_0x5baf10);}else{_0x196e24=_0x5baf10;}}if('undefined'!=typeof _0x18fa51['parameters'][_0x2fad('0x76')][_0x2fad('0x78')]){var _0x5039f2=_0x18fa51[_0x2fad('0x73')][_0x2fad('0x76')]['agent'];if(!/^(f|ht)tps?:\/\//i[_0x2fad('0x86')](_0x5039f2)){_0xf1d284=path['join'](_0x2fad('0x87'),_0x589b59,_0x25f620[0x0],_0x5039f2);}else{_0xf1d284=_0x5039f2;}}}}var _0xecbee8={'name':_0x1b6018,'description':_0x477215,'path':path[_0x2fad('0x56')](_0x589b59,_0x25f620[0x0]),'type':_0x5a31d9,'sidebar':_0xd850a,'icon':_0x10f814,'adminUrl':_0x196e24,'agentUrl':_0xf1d284,'scriptName':_0x22c0b7,'scriptPath':_0x485a35,'version':_0x1ae7d9};removeReferences(_0x585856,null);return db['Plugin'][_0x2fad('0x88')](_0xecbee8)[_0x2fad('0x25')](function(_0x31e683){var _0x4cdff1={'role':_0x3b480b[_0x2fad('0x89')][_0x2fad('0x8a')],'userProfileId':_0x3b480b[_0x2fad('0x89')][_0x2fad('0x8b')]};if(!_0x4cdff1)throw new Error(_0x2fad('0x8c'));if(_0x4cdff1[_0x2fad('0x8a')]===_0x2fad('0x8d')){var _0x58c2f5=_0x31e683['get']({'plain':!![]});return db[_0x2fad('0x8e')]['find']({'where':{'name':_0x2fad('0x28'),'userProfileId':_0x4cdff1[_0x2fad('0x8b')]},'raw':!![]})['then'](function(_0x2c4d41){if(_0x2c4d41&&_0x2c4d41['autoAssociation']===0x0){return db[_0x2fad('0x8f')][_0x2fad('0x88')]({'name':_0x58c2f5['name'],'resourceId':_0x58c2f5['id'],'type':_0x2c4d41[_0x2fad('0x2c')],'sectionId':_0x2c4d41['id']},{})['then'](function(){return _0x31e683;});}else{return _0x31e683;}})[_0x2fad('0x44')](function(_0x23199b){logger[_0x2fad('0x2a')](_0x2fad('0x90'),_0x23199b);throw _0x23199b;});}return _0x31e683;})[_0x2fad('0x25')](respondWithResult(_0x3e8271,null))[_0x2fad('0x44')](handleError(_0x3e8271,null));}});}catch(_0x5624df){_0x3e8271['status'](0x1f4)[_0x2fad('0x91')](_0x5624df);}};function removeReferences(_0x3b4f46,_0x464157){try{if(_0x3b4f46){fs[_0x2fad('0x5e')](_0x3b4f46);logger[_0x2fad('0x5f')]('Zip\x20archive\x20removed');}if(_0x464157){rimraf(_0x464157,function(){});logger[_0x2fad('0x5f')](_0x2fad('0x92'));}}catch(_0x5b6dfa){logger[_0x2fad('0x2a')](_0x5b6dfa);}}exports[_0x2fad('0x24')]=function(_0x10330a,_0x3443b2,_0x4f8acd){return db[_0x2fad('0x2f')][_0x2fad('0x46')]({'where':{'id':_0x10330a[_0x2fad('0x45')]['id']}})[_0x2fad('0x25')](handleEntityNotFound(_0x3443b2,null))['then'](saveUpdates(_0x10330a['body'],null))[_0x2fad('0x25')](respondWithResult(_0x3443b2,null))[_0x2fad('0x44')](handleError(_0x3443b2,null));};exports['delete']=function(_0x369a45,_0x46fad3,_0x35dd94){return db[_0x2fad('0x2f')]['find']({'where':{'id':_0x369a45[_0x2fad('0x45')]['id']}})[_0x2fad('0x25')](function(_0x58a524){if(_0x58a524){return _0x58a524['destroy']();}})[_0x2fad('0x25')](function(_0x2180ec){rimraf(path['join'](config[_0x2fad('0x47')],'server/files/plugins',path[_0x2fad('0x57')](_0x2180ec['path'])),function(){});return _0x2180ec;})[_0x2fad('0x25')](handleEntityNotFound(_0x46fad3,null))[_0x2fad('0x25')](respondWithStatusCode(_0x46fad3,null))[_0x2fad('0x44')](handleError(_0x46fad3,null));};exports[_0x2fad('0x93')]=function(_0x309c2a,_0x269af0,_0x170268){return BPromise['resolve']()['then'](function(){if(!_0x309c2a[_0x2fad('0x33')][_0x2fad('0x7')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x309c2a['query']['port']){throw new Error(_0x2fad('0x94'));}var _0xc0cc7b=_0x309c2a['query'][_0x2fad('0x95')]?_0x309c2a[_0x2fad('0x33')][_0x2fad('0x95')]+':'+_0x309c2a[_0x2fad('0x33')][_0x2fad('0x96')]:'http://localhost:'+_0x309c2a[_0x2fad('0x33')][_0x2fad('0x96')];var _0x26b1a5=_0x309c2a[_0x2fad('0x33')]['json']?_0x309c2a['query'][_0x2fad('0x1e')]:!![];var _0x2c53ef=_0x309c2a['query']['encoding']?_0x309c2a['query'][_0x2fad('0x97')]:null;var _0x434584={'method':_0x309c2a['method'],'uri':util['format'](_0x2fad('0x98'),_0xc0cc7b,_0x309c2a[_0x2fad('0x33')]['path']),'json':_0x26b1a5,'resolveWithFullResponse':!![],'encoding':_0x2c53ef,'qs':_0x309c2a[_0x2fad('0x33')]};if(_0x309c2a[_0x2fad('0x99')]){_0x434584[_0x2fad('0x99')]=_0x309c2a[_0x2fad('0x99')];if(_0x434584[_0x2fad('0x99')][_0x2fad('0x9a')]){delete _0x434584[_0x2fad('0x99')][_0x2fad('0x9a')];}}if(_0x434584[_0x2fad('0x99')][_0x2fad('0x9b')]){delete _0x434584[_0x2fad('0x99')][_0x2fad('0x9b')];}return rp(_0x434584);})[_0x2fad('0x25')](function(_0x25a31f){if(_0x25a31f){_0x269af0[_0x2fad('0x23')](_0x25a31f[_0x2fad('0x99')]);logger[_0x2fad('0x5f')](_0x25a31f[_0x2fad('0x89')]);if(_[_0x2fad('0x9c')](_0x309c2a[_0x2fad('0x33')][_0x2fad('0x7')],_0x2fad('0x5c'))&&_0x25a31f[_0x2fad('0x9d')]==0x1f4){return _0x269af0[_0x2fad('0x1c')](_0x25a31f[_0x2fad('0x9d')]);}else{return _0x269af0['status'](_0x25a31f[_0x2fad('0x9d')])[_0x2fad('0x91')](_0x25a31f[_0x2fad('0x89')]);}}else{return _0x269af0[_0x2fad('0x1c')](0xc8);}})[_0x2fad('0x44')](handleError(_0x269af0,null));};exports['webhookPost']=function(_0x20f0e6,_0x15dd34,_0x5ddeb2){return BPromise[_0x2fad('0x9e')]()[_0x2fad('0x25')](function(){if(!_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x7')]){throw new Error(_0x2fad('0x9f'));}if(!_0x20f0e6['query']['port']){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x155456=_0x20f0e6['query'][_0x2fad('0x95')]?_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x95')]+':'+_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x96')]:_0x2fad('0xa0')+_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x96')];var _0x2f8b13=_0x20f0e6[_0x2fad('0x33')]['json']?_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x1e')]:!![];var _0x3dec9e=_0x20f0e6['query']['encoding']?_0x20f0e6[_0x2fad('0x33')][_0x2fad('0x97')]:null;var _0xe2533f={'method':_0x20f0e6[_0x2fad('0xa1')],'uri':util['format'](_0x2fad('0x98'),_0x155456,_0x20f0e6['query'][_0x2fad('0x7')]),'json':_0x2f8b13,'resolveWithFullResponse':!![],'encoding':_0x3dec9e,'body':_0x20f0e6[_0x2fad('0x89')]};if(_0x20f0e6[_0x2fad('0x99')]){_0xe2533f['headers']=_0x20f0e6[_0x2fad('0x99')];if(_0xe2533f[_0x2fad('0x99')][_0x2fad('0x9a')]){delete _0xe2533f[_0x2fad('0x99')][_0x2fad('0x9a')];}}if(_0xe2533f[_0x2fad('0x99')][_0x2fad('0x9b')]){delete _0xe2533f[_0x2fad('0x99')]['content-type'];}return rp(_0xe2533f);})['then'](function(_0x4c037c){if(_0x4c037c){_0x15dd34[_0x2fad('0x23')](_0x4c037c[_0x2fad('0x99')]);logger[_0x2fad('0x5f')](_0x4c037c['body']);return _0x15dd34['status'](_0x4c037c[_0x2fad('0x9d')])['send'](_0x4c037c[_0x2fad('0x89')]);}else{return _0x15dd34[_0x2fad('0x1c')](0xc8);}})['catch'](handleError(_0x15dd34,null));};
\ No newline at end of file