mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: move plugin hook methods to plugin.hooks.*
This commit is contained in:
@@ -60,7 +60,7 @@ module.exports = function (Posts) {
|
||||
return postData;
|
||||
}
|
||||
|
||||
const data = await plugins.fireHook('filter:parse.post', { postData: postData });
|
||||
const data = await plugins.hooks.fire('filter:parse.post', { postData: postData });
|
||||
data.postData.content = translator.escape(data.postData.content);
|
||||
if (data.postData.pid) {
|
||||
cache.set(pid, data.postData.content);
|
||||
@@ -70,7 +70,7 @@ module.exports = function (Posts) {
|
||||
|
||||
Posts.parseSignature = async function (userData, uid) {
|
||||
userData.signature = sanitizeSignature(userData.signature || '');
|
||||
return await plugins.fireHook('filter:parse.signature', { userData: userData, uid: uid });
|
||||
return await plugins.hooks.fire('filter:parse.signature', { userData: userData, uid: uid });
|
||||
};
|
||||
|
||||
Posts.relativeToAbsolute = function (content, regex) {
|
||||
@@ -121,11 +121,11 @@ module.exports = function (Posts) {
|
||||
});
|
||||
|
||||
// Some plugins might need to adjust or whitelist their own tags...
|
||||
sanitizeConfig = await plugins.fireHook('filter:sanitize.config', sanitizeConfig);
|
||||
sanitizeConfig = await plugins.hooks.fire('filter:sanitize.config', sanitizeConfig);
|
||||
};
|
||||
|
||||
Posts.registerHooks = () => {
|
||||
plugins.registerHook('core', {
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:parse.post',
|
||||
method: async (data) => {
|
||||
data.postData.content = Posts.sanitize(data.postData.content);
|
||||
@@ -133,17 +133,17 @@ module.exports = function (Posts) {
|
||||
},
|
||||
});
|
||||
|
||||
plugins.registerHook('core', {
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:parse.raw',
|
||||
method: async content => Posts.sanitize(content),
|
||||
});
|
||||
|
||||
plugins.registerHook('core', {
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:parse.aboutme',
|
||||
method: async content => Posts.sanitize(content),
|
||||
});
|
||||
|
||||
plugins.registerHook('core', {
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:parse.signature',
|
||||
method: async (data) => {
|
||||
data.userData.signature = Posts.sanitize(data.userData.signature);
|
||||
|
||||
Reference in New Issue
Block a user