mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	feat: upon plugin installation via ACP, check against nbbpm first
This commit is contained in:
		| @@ -7,6 +7,7 @@ const nconf = require('nconf'); | ||||
| const os = require('os'); | ||||
| const cproc = require('child_process'); | ||||
| const util = require('util'); | ||||
| const request = require('request-promise-native'); | ||||
|  | ||||
| const db = require('../database'); | ||||
| const meta = require('../meta'); | ||||
| @@ -66,6 +67,20 @@ module.exports = function (Plugins) { | ||||
| 		return { id: id, active: !isActive }; | ||||
| 	}; | ||||
|  | ||||
| 	Plugins.checkWhitelist = async function (id, version) { | ||||
| 		const body = await request({ | ||||
| 			method: 'GET', | ||||
| 			url: `https://packages.nodebb.org/api/v1/plugins/${encodeURIComponent(id)}`, | ||||
| 			json: true, | ||||
| 		}); | ||||
|  | ||||
| 		if (body && body.code === 'ok' && (version === 'latest' || body.payload.valid.includes(version))) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		throw new Error('[[error:plugin-not-whitelisted]]'); | ||||
| 	}; | ||||
|  | ||||
| 	Plugins.toggleInstall = async function (id, version) { | ||||
| 		pubsub.publish('plugins:toggleInstall', { hostname: os.hostname(), id: id, version: version }); | ||||
| 		return await toggleInstall(id, version); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user