mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: init topic events from webserver.js
This commit is contained in:
@@ -43,16 +43,11 @@ Events._types = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
async function init() {
|
Events.init = async () => {
|
||||||
if (!plugins.hooks) {
|
|
||||||
return setImmediate(init);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow plugins to define additional topic event types
|
// Allow plugins to define additional topic event types
|
||||||
const { types } = await plugins.hooks.fire('filter:topicEvents.init', { types: Events._types });
|
const { types } = await plugins.hooks.fire('filter:topicEvents.init', { types: Events._types });
|
||||||
Events._types = types;
|
Events._types = types;
|
||||||
}
|
};
|
||||||
init();
|
|
||||||
|
|
||||||
Events.get = async (tid) => {
|
Events.get = async (tid) => {
|
||||||
const topics = require('.');
|
const topics = require('.');
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const meta = require('./meta');
|
|||||||
const logger = require('./logger');
|
const logger = require('./logger');
|
||||||
const plugins = require('./plugins');
|
const plugins = require('./plugins');
|
||||||
const flags = require('./flags');
|
const flags = require('./flags');
|
||||||
|
const topicEvents = require('./topics/events');
|
||||||
const routes = require('./routes');
|
const routes = require('./routes');
|
||||||
const auth = require('./routes/authentication');
|
const auth = require('./routes/authentication');
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ async function initializeNodeBB() {
|
|||||||
await meta.blacklist.load();
|
await meta.blacklist.load();
|
||||||
await flags.init();
|
await flags.init();
|
||||||
await analytics.init();
|
await analytics.init();
|
||||||
|
await topicEvents.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupExpressApp(app) {
|
function setupExpressApp(app) {
|
||||||
|
|||||||
@@ -55,24 +55,6 @@ describe('Topic Events', () => {
|
|||||||
quux: 'quux',
|
quux: 'quux',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing if called a second time', async () => {
|
|
||||||
await plugins.hooks.register('core', {
|
|
||||||
hook: 'filter:topicEvents.init',
|
|
||||||
method: async ({ types }) => {
|
|
||||||
types.bar = {
|
|
||||||
icon: 'bar',
|
|
||||||
text: 'baz',
|
|
||||||
quux: 'quux',
|
|
||||||
};
|
|
||||||
|
|
||||||
return { types };
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await topics.events.init();
|
|
||||||
assert(!topics.events._types.bar); // bar is explicitly not available
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.log()', () => {
|
describe('.log()', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user