fix: #7844, add uid to events, log plugin install/uninstall events

v1.18.x
Barış Soner Uşaklı 6 years ago
parent b1c0beb713
commit 592d9c82c5

@ -14,6 +14,8 @@ const events = module.exports;
events.types = [
'plugin-activate',
'plugin-deactivate',
'plugin-install',
'plugin-uninstall',
'restart',
'build',
'config-change',

@ -11,7 +11,6 @@ const util = require('util');
const db = require('../database');
const meta = require('../meta');
const pubsub = require('../pubsub');
const events = require('../events');
const statAsync = util.promisify(fs.stat);
@ -57,10 +56,6 @@ module.exports = function (Plugins) {
}
meta.reloadRequired = true;
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', { id: id });
await events.log({
type: 'plugin-' + (isActive ? 'deactivate' : 'activate'),
text: id,
});
return { id: id, active: !isActive };
};

@ -129,14 +129,27 @@ SocketAdmin.themes.set = function (socket, data, callback) {
], callback);
};
SocketAdmin.plugins.toggleActive = function (socket, plugin_id, callback) {
SocketAdmin.plugins.toggleActive = async function (socket, plugin_id) {
require('../posts/cache').reset();
plugins.toggleActive(plugin_id, callback);
const data = await plugins.toggleActive(plugin_id);
await events.log({
type: 'plugin-' + (data.active ? 'activate' : 'deactivate'),
text: plugin_id,
uid: socket.uid,
});
return data;
};
SocketAdmin.plugins.toggleInstall = function (socket, data, callback) {
SocketAdmin.plugins.toggleInstall = async function (socket, data) {
require('../posts/cache').reset();
plugins.toggleInstall(data.id, data.version, callback);
const pluginData = await plugins.toggleInstall(data.id, data.version);
await events.log({
type: 'plugin-' + (pluginData.installed ? 'install' : 'uninstall'),
text: data.id,
version: data.version,
uid: socket.uid,
});
return pluginData;
};
SocketAdmin.plugins.getActive = function (socket, data, callback) {
@ -398,3 +411,5 @@ SocketAdmin.uploads.delete = function (socket, pathToFile, callback) {
};
module.exports = SocketAdmin;
require('../promisify')(SocketAdmin);

Loading…
Cancel
Save