Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Homework" and "Assignment" default tags #34

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const topicEvents = require('./topics/events');
const privileges = require('./privileges');
const routes = require('./routes');
const auth = require('./routes/authentication');
const topics = require('./topics');

const helpers = require('./helpers');

Expand All @@ -48,6 +49,7 @@ if (nconf.get('ssl')) {

module.exports.server = server;
module.exports.app = app;
module.exports.createNewTag = createNewTag;

server.on('error', (err) => {
if (err.code === 'EADDRINUSE') {
Expand Down Expand Up @@ -86,6 +88,7 @@ exports.listen = async function () {
helpers.register();
logger.init(app);
await initializeNodeBB();
await createNewTag();
winston.info('🎉 NodeBB Ready');

require('./socket.io').server.emit('event:nodebb.ready', {});
Expand Down Expand Up @@ -334,3 +337,17 @@ exports.testSocket = async function (socketPath) {
};

require('./promisify')(exports);

async function createNewTag() {
try {
const newTag1 = 'homework';
const newTag2 = 'assignment';

await topics.createEmptyTag(newTag1);
console.log(`Tag "${newTag1}" successfully created!`);
await topics.createEmptyTag(newTag2);
console.log(`Tag "${newTag2}" successfully created!`);
} catch (err) {
console.error('Error creating tag: ', err.message);
}
}