mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-05 22:37:22 +02:00
refactor: move plugin hook methods to plugin.hooks.*
This commit is contained in:
@@ -27,7 +27,7 @@ categoriesController.get = async function (req, res, next) {
|
||||
});
|
||||
const selectedCategory = allCategories.find(c => c.selected);
|
||||
|
||||
const data = await plugins.fireHook('filter:admin.category.get', {
|
||||
const data = await plugins.hooks.fire('filter:admin.category.get', {
|
||||
req: req,
|
||||
res: res,
|
||||
category: category,
|
||||
@@ -53,7 +53,7 @@ categoriesController.getAll = async function (req, res) {
|
||||
'color', 'bgColor', 'backgroundImage', 'imageClass',
|
||||
];
|
||||
const categoriesData = await categories.getCategoriesFields(cids, fields);
|
||||
const result = await plugins.fireHook('filter:admin.categories.get', { categories: categoriesData, fields: fields });
|
||||
const result = await plugins.hooks.fire('filter:admin.categories.get', { categories: categoriesData, fields: fields });
|
||||
const tree = categories.getTree(result.categories, 0);
|
||||
res.render('admin/manage/categories', {
|
||||
categories: tree,
|
||||
|
||||
@@ -47,7 +47,7 @@ async function getNotices() {
|
||||
notDoneText: '[[admin/dashboard:restart-required]]',
|
||||
},
|
||||
{
|
||||
done: plugins.hasListeners('filter:search.query'),
|
||||
done: plugins.hooks.hasListeners('filter:search.query'),
|
||||
doneText: '[[admin/dashboard:search-plugin-installed]]',
|
||||
notDoneText: '[[admin/dashboard:search-plugin-not-installed]]',
|
||||
tooltip: '[[admin/dashboard:search-plugin-tooltip]]',
|
||||
@@ -62,7 +62,7 @@ async function getNotices() {
|
||||
});
|
||||
}
|
||||
|
||||
return await plugins.fireHook('filter:admin.notices', notices);
|
||||
return await plugins.hooks.fire('filter:admin.notices', notices);
|
||||
}
|
||||
|
||||
async function getLatestVersion() {
|
||||
|
||||
@@ -237,8 +237,8 @@ function validateUpload(res, uploadedFile, allowedTypes) {
|
||||
async function uploadImage(filename, folder, uploadedFile, req, res, next) {
|
||||
let imageData;
|
||||
try {
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
imageData = await plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid, folder: folder });
|
||||
if (plugins.hooks.hasListeners('filter:uploadImage')) {
|
||||
imageData = await plugins.hooks.fire('filter:uploadImage', { image: uploadedFile, uid: req.uid, folder: folder });
|
||||
} else {
|
||||
imageData = await file.saveFileToLocal(filename, folder, uploadedFile.path);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ usersController.registrationQueue = async function (req, res) {
|
||||
const data = await utils.promiseParallel({
|
||||
registrationQueueCount: db.sortedSetCard('registration:queue'),
|
||||
users: user.getRegistrationQueue(start, stop),
|
||||
customHeaders: plugins.fireHook('filter:admin.registrationQueue.customHeaders', { headers: [] }),
|
||||
customHeaders: plugins.hooks.fire('filter:admin.registrationQueue.customHeaders', { headers: [] }),
|
||||
invites: getInvites(),
|
||||
});
|
||||
var pageCount = Math.max(1, Math.ceil(data.registrationQueueCount / itemsPerPage));
|
||||
|
||||
Reference in New Issue
Block a user