fix: init topic events from webserver.js

v1.18.x
Julian Lam 4 years ago
parent 6074a0fbbf
commit b81508c4e2

@ -43,16 +43,11 @@ Events._types = {
},
};
async function init() {
if (!plugins.hooks) {
return setImmediate(init);
}
Events.init = async () => {
// Allow plugins to define additional topic event types
const { types } = await plugins.hooks.fire('filter:topicEvents.init', { types: Events._types });
Events._types = types;
}
init();
};
Events.get = async (tid) => {
const topics = require('.');

@ -31,6 +31,7 @@ const meta = require('./meta');
const logger = require('./logger');
const plugins = require('./plugins');
const flags = require('./flags');
const topicEvents = require('./topics/events');
const routes = require('./routes');
const auth = require('./routes/authentication');
@ -106,6 +107,7 @@ async function initializeNodeBB() {
await meta.blacklist.load();
await flags.init();
await analytics.init();
await topicEvents.init();
}
function setupExpressApp(app) {

@ -55,24 +55,6 @@ describe('Topic Events', () => {
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()', () => {

Loading…
Cancel
Save