2014-03-18 18:15:07 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const fs = require('fs');
|
|
|
|
|
const url = require('url');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const prompt = require('prompt');
|
|
|
|
|
const winston = require('winston');
|
|
|
|
|
const nconf = require('nconf');
|
|
|
|
|
const _ = require('lodash');
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2021-05-28 12:17:48 -04:00
|
|
|
const utils = require('./utils');
|
2023-04-15 01:16:40 +02:00
|
|
|
const { paths } = require('./constants');
|
2020-07-31 12:49:25 -04:00
|
|
|
|
|
|
|
|
const install = module.exports;
|
|
|
|
|
const questions = {};
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2014-04-14 14:10:57 -04:00
|
|
|
questions.main = [
|
|
|
|
|
{
|
2014-11-29 21:54:58 -05:00
|
|
|
name: 'url',
|
2014-05-20 14:44:50 -04:00
|
|
|
description: 'URL used to access this NodeBB',
|
2017-02-18 01:19:20 -07:00
|
|
|
default:
|
2018-05-15 15:25:59 -04:00
|
|
|
nconf.get('url') || 'http://localhost:4567',
|
2014-04-14 14:10:57 -04:00
|
|
|
pattern: /^http(?:s)?:\/\//,
|
|
|
|
|
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'secret',
|
|
|
|
|
description: 'Please enter a NodeBB secret',
|
2017-02-18 01:19:20 -07:00
|
|
|
default: nconf.get('secret') || utils.generateUUID(),
|
2014-04-14 14:10:57 -04:00
|
|
|
},
|
2019-06-07 14:10:44 -04:00
|
|
|
{
|
|
|
|
|
name: 'submitPluginUsage',
|
|
|
|
|
description: 'Would you like to submit anonymous plugin usage to nbbpm?',
|
|
|
|
|
default: 'yes',
|
|
|
|
|
},
|
2014-04-14 14:10:57 -04:00
|
|
|
{
|
|
|
|
|
name: 'database',
|
|
|
|
|
description: 'Which database to use',
|
2017-02-18 01:19:20 -07:00
|
|
|
default: nconf.get('database') || 'mongo',
|
2017-02-17 19:31:21 -07:00
|
|
|
},
|
2014-04-14 14:10:57 -04:00
|
|
|
];
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2015-01-07 10:09:02 -05:00
|
|
|
questions.optional = [
|
|
|
|
|
{
|
|
|
|
|
name: 'port',
|
2017-02-17 19:31:21 -07:00
|
|
|
default: nconf.get('port') || 4567,
|
|
|
|
|
},
|
2015-01-07 10:09:02 -05:00
|
|
|
];
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2022-02-15 19:13:43 +01:00
|
|
|
function checkSetupFlagEnv() {
|
2022-02-17 12:30:03 -05:00
|
|
|
let setupVal = install.values;
|
2022-02-15 19:13:43 +01:00
|
|
|
|
|
|
|
|
const envConfMap = {
|
2023-11-12 19:38:00 +01:00
|
|
|
CONFIG: 'config',
|
|
|
|
|
NODEBB_CONFIG: 'config',
|
2022-02-15 19:13:43 +01:00
|
|
|
NODEBB_URL: 'url',
|
|
|
|
|
NODEBB_PORT: 'port',
|
|
|
|
|
NODEBB_ADMIN_USERNAME: 'admin:username',
|
|
|
|
|
NODEBB_ADMIN_PASSWORD: 'admin:password',
|
|
|
|
|
NODEBB_ADMIN_EMAIL: 'admin:email',
|
|
|
|
|
NODEBB_DB: 'database',
|
|
|
|
|
NODEBB_DB_HOST: 'host',
|
|
|
|
|
NODEBB_DB_PORT: 'port',
|
|
|
|
|
NODEBB_DB_USER: 'username',
|
|
|
|
|
NODEBB_DB_PASSWORD: 'password',
|
|
|
|
|
NODEBB_DB_NAME: 'database',
|
|
|
|
|
NODEBB_DB_SSL: 'ssl',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Set setup values from env vars (if set)
|
2022-02-17 12:30:03 -05:00
|
|
|
const envKeys = Object.keys(process.env);
|
|
|
|
|
if (Object.keys(envConfMap).some(key => envKeys.includes(key))) {
|
|
|
|
|
winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...');
|
|
|
|
|
setupVal = setupVal || {};
|
2022-02-15 19:13:43 +01:00
|
|
|
|
2022-02-17 12:30:03 -05:00
|
|
|
Object.entries(process.env).forEach(([evName, evValue]) => { // get setup values from env
|
|
|
|
|
if (evName.startsWith('NODEBB_DB_')) {
|
|
|
|
|
setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue;
|
|
|
|
|
} else if (evName.startsWith('NODEBB_')) {
|
|
|
|
|
setupVal[envConfMap[evName]] = evValue;
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-02-15 19:13:43 +01:00
|
|
|
|
2022-02-17 12:30:03 -05:00
|
|
|
setupVal['admin:password:confirm'] = setupVal['admin:password'];
|
|
|
|
|
}
|
2016-08-04 20:58:04 +03:00
|
|
|
|
2022-02-15 19:13:43 +01:00
|
|
|
// try to get setup values from json, if successful this overwrites all values set by env
|
|
|
|
|
// TODO: better behaviour would be to support overrides per value, i.e. in order of priority (generic pattern):
|
|
|
|
|
// flag, env, config file, default
|
2014-04-14 14:10:57 -04:00
|
|
|
try {
|
2015-04-23 17:03:31 -04:00
|
|
|
if (nconf.get('setup')) {
|
2022-02-15 19:13:43 +01:00
|
|
|
const setupJSON = JSON.parse(nconf.get('setup'));
|
|
|
|
|
setupVal = { ...setupVal, ...setupJSON };
|
2015-04-23 17:03:31 -04:00
|
|
|
}
|
2020-04-17 13:24:52 -04:00
|
|
|
} catch (err) {
|
2022-02-15 19:13:43 +01:00
|
|
|
winston.error('[install/checkSetupFlagEnv] invalid json in nconf.get(\'setup\'), ignoring setup values from json');
|
2020-04-17 13:24:52 -04:00
|
|
|
}
|
2014-04-08 21:08:51 -04:00
|
|
|
|
2017-12-04 13:49:44 -07:00
|
|
|
if (setupVal && typeof setupVal === 'object') {
|
2014-04-14 14:10:57 -04:00
|
|
|
if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) {
|
|
|
|
|
install.values = setupVal;
|
|
|
|
|
} else {
|
2022-02-15 19:13:43 +01:00
|
|
|
winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:');
|
2014-04-14 14:10:57 -04:00
|
|
|
if (!setupVal['admin:username']) {
|
|
|
|
|
winston.error(' admin:username');
|
2014-04-14 13:54:11 -04:00
|
|
|
}
|
2014-04-14 14:10:57 -04:00
|
|
|
if (!setupVal['admin:password']) {
|
|
|
|
|
winston.error(' admin:password');
|
|
|
|
|
}
|
|
|
|
|
if (!setupVal['admin:password:confirm']) {
|
|
|
|
|
winston.error(' admin:password:confirm');
|
|
|
|
|
}
|
|
|
|
|
if (!setupVal['admin:email']) {
|
|
|
|
|
winston.error(' admin:email');
|
2014-04-14 13:54:11 -04:00
|
|
|
}
|
2014-04-14 12:54:11 -04:00
|
|
|
|
2014-04-14 14:10:57 -04:00
|
|
|
process.exit();
|
|
|
|
|
}
|
2016-08-04 20:58:04 +03:00
|
|
|
} else if (nconf.get('database')) {
|
2017-12-04 13:49:44 -07:00
|
|
|
install.values = install.values || {};
|
|
|
|
|
install.values.database = nconf.get('database');
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
function checkCIFlag() {
|
2021-02-04 00:06:15 -07:00
|
|
|
let ciVals;
|
2014-04-14 14:10:57 -04:00
|
|
|
try {
|
|
|
|
|
ciVals = JSON.parse(nconf.get('ci'));
|
|
|
|
|
} catch (e) {
|
|
|
|
|
ciVals = undefined;
|
|
|
|
|
}
|
2014-04-14 12:48:59 -04:00
|
|
|
|
2014-04-14 14:10:57 -04:00
|
|
|
if (ciVals && ciVals instanceof Object) {
|
|
|
|
|
if (ciVals.hasOwnProperty('host') && ciVals.hasOwnProperty('port') && ciVals.hasOwnProperty('database')) {
|
|
|
|
|
install.ciVals = ciVals;
|
|
|
|
|
} else {
|
2022-02-15 19:13:43 +01:00
|
|
|
winston.error('[install/checkCIFlag] required values are missing for automated CI integration:');
|
2014-04-14 14:10:57 -04:00
|
|
|
if (!ciVals.hasOwnProperty('host')) {
|
|
|
|
|
winston.error(' host');
|
|
|
|
|
}
|
|
|
|
|
if (!ciVals.hasOwnProperty('port')) {
|
|
|
|
|
winston.error(' port');
|
|
|
|
|
}
|
|
|
|
|
if (!ciVals.hasOwnProperty('database')) {
|
|
|
|
|
winston.error(' database');
|
2014-04-14 13:54:11 -04:00
|
|
|
}
|
2013-12-04 17:57:51 -05:00
|
|
|
|
2014-04-14 14:10:57 -04:00
|
|
|
process.exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-04 17:57:51 -05:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function setupConfig() {
|
|
|
|
|
const configureDatabases = require('../install/databases');
|
2013-11-14 12:52:00 -06:00
|
|
|
|
2014-04-14 14:10:57 -04:00
|
|
|
// prompt prepends "prompt: " to questions, let's clear that.
|
|
|
|
|
prompt.start();
|
|
|
|
|
prompt.message = '';
|
|
|
|
|
prompt.delimiter = '';
|
2014-12-28 22:32:02 -05:00
|
|
|
prompt.colors = false;
|
2020-07-31 12:49:25 -04:00
|
|
|
let config = {};
|
|
|
|
|
|
|
|
|
|
if (install.values) {
|
|
|
|
|
// Use provided values, fall back to defaults
|
|
|
|
|
const redisQuestions = require('./database/redis').questions;
|
|
|
|
|
const mongoQuestions = require('./database/mongo').questions;
|
|
|
|
|
const postgresQuestions = require('./database/postgres').questions;
|
2021-02-04 02:07:29 -07:00
|
|
|
const allQuestions = [
|
|
|
|
|
...questions.main,
|
|
|
|
|
...questions.optional,
|
|
|
|
|
...redisQuestions,
|
|
|
|
|
...mongoQuestions,
|
|
|
|
|
...postgresQuestions,
|
|
|
|
|
];
|
2020-07-31 12:49:25 -04:00
|
|
|
|
2021-02-04 00:01:39 -07:00
|
|
|
allQuestions.forEach((question) => {
|
2020-07-31 12:49:25 -04:00
|
|
|
if (install.values.hasOwnProperty(question.name)) {
|
|
|
|
|
config[question.name] = install.values[question.name];
|
|
|
|
|
} else if (question.hasOwnProperty('default')) {
|
|
|
|
|
config[question.name] = question.default;
|
2016-12-08 23:51:56 +03:00
|
|
|
} else {
|
2020-07-31 12:49:25 -04:00
|
|
|
config[question.name] = undefined;
|
2014-04-23 08:51:44 -04:00
|
|
|
}
|
2020-07-31 12:49:25 -04:00
|
|
|
});
|
|
|
|
|
} else {
|
2021-10-18 17:34:26 -04:00
|
|
|
config = await prompt.get(questions.main);
|
2020-07-31 12:49:25 -04:00
|
|
|
}
|
|
|
|
|
await configureDatabases(config);
|
|
|
|
|
await completeConfigSetup(config);
|
2014-04-14 15:03:11 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function completeConfigSetup(config) {
|
2014-04-14 15:03:11 -04:00
|
|
|
// Add CI object
|
|
|
|
|
if (install.ciVals) {
|
2021-02-04 01:34:30 -07:00
|
|
|
config.test_database = { ...install.ciVals };
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
2014-04-14 15:03:11 -04:00
|
|
|
|
2018-04-11 11:53:33 -04:00
|
|
|
// Add package_manager object if set
|
|
|
|
|
if (nconf.get('package_manager')) {
|
|
|
|
|
config.package_manager = nconf.get('package_manager');
|
|
|
|
|
}
|
2024-12-11 11:21:58 -05:00
|
|
|
|
2024-12-20 16:00:24 -05:00
|
|
|
if (install.values && install.values.hasOwnProperty('saas_plan')) {
|
2024-12-11 11:21:58 -05:00
|
|
|
config.saas_plan = install.values.saas_plan;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 15:45:52 -04:00
|
|
|
nconf.overrides(config);
|
2020-07-31 12:49:25 -04:00
|
|
|
const db = require('./database');
|
|
|
|
|
await db.init();
|
2021-01-22 23:59:52 -05:00
|
|
|
if (db.hasOwnProperty('createIndices')) {
|
|
|
|
|
await db.createIndices();
|
|
|
|
|
}
|
2018-05-24 16:01:04 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
// Sanity-check/fix url/port
|
|
|
|
|
if (!/^http(?:s)?:\/\//.test(config.url)) {
|
2021-02-03 23:59:08 -07:00
|
|
|
config.url = `http://${config.url}`;
|
2020-07-31 12:49:25 -04:00
|
|
|
}
|
2021-02-17 10:52:04 -05:00
|
|
|
|
|
|
|
|
// If port is explicitly passed via install vars, use it. Otherwise, glean from url if set.
|
2021-02-04 00:06:15 -07:00
|
|
|
const urlObj = url.parse(config.url);
|
2021-02-16 20:37:52 +01:00
|
|
|
if (urlObj.port && (!install.values || !install.values.hasOwnProperty('port'))) {
|
2020-07-31 12:49:25 -04:00
|
|
|
config.port = urlObj.port;
|
|
|
|
|
}
|
2018-05-15 15:25:59 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
// Remove trailing slash from non-subfolder installs
|
|
|
|
|
if (urlObj.path === '/') {
|
|
|
|
|
urlObj.path = '';
|
|
|
|
|
urlObj.pathname = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config.url = url.format(urlObj);
|
2018-05-15 15:25:59 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
// ref: https://github.com/indexzero/nconf/issues/300
|
|
|
|
|
delete config.type;
|
2018-05-15 15:25:59 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const meta = require('./meta');
|
|
|
|
|
await meta.configs.set('submitPluginUsage', config.submitPluginUsage === 'yes' ? 1 : 0);
|
|
|
|
|
delete config.submitPluginUsage;
|
2019-06-07 14:10:44 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
await install.save(config);
|
2014-07-23 13:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function setupDefaultConfigs() {
|
2017-11-27 13:44:30 -07:00
|
|
|
console.log('Populating database with default configs, if not already set...');
|
2020-07-31 12:49:25 -04:00
|
|
|
const meta = require('./meta');
|
|
|
|
|
const defaults = require(path.join(__dirname, '../', 'install/data/defaults.json'));
|
2014-04-14 14:10:57 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
await meta.configs.setOnEmpty(defaults);
|
|
|
|
|
await meta.configs.init();
|
2014-06-29 14:29:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function enableDefaultTheme() {
|
|
|
|
|
const meta = require('./meta');
|
2014-04-14 14:10:57 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const id = await meta.configs.get('theme:id');
|
|
|
|
|
if (id) {
|
|
|
|
|
console.log('Previous theme detected, skipping enabling default theme');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
const defaultTheme = nconf.get('defaultTheme') || 'nodebb-theme-harmony';
|
2021-02-03 23:59:08 -07:00
|
|
|
console.log(`Enabling default theme: ${defaultTheme}`);
|
2020-07-31 12:49:25 -04:00
|
|
|
await meta.themes.set({
|
|
|
|
|
type: 'local',
|
|
|
|
|
id: defaultTheme,
|
2014-08-07 16:02:18 -04:00
|
|
|
});
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 10:30:46 -05:00
|
|
|
async function createDefaultUserGroups() {
|
|
|
|
|
const groups = require('./groups');
|
|
|
|
|
async function createGroup(name) {
|
|
|
|
|
await groups.create({
|
|
|
|
|
name: name,
|
|
|
|
|
hidden: 1,
|
|
|
|
|
private: 1,
|
|
|
|
|
system: 1,
|
|
|
|
|
disableLeave: 1,
|
|
|
|
|
disableJoinRequests: 1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [verifiedExists, unverifiedExists, bannedExists] = await groups.exists([
|
|
|
|
|
'verified-users', 'unverified-users', 'banned-users',
|
|
|
|
|
]);
|
|
|
|
|
if (!verifiedExists) {
|
|
|
|
|
await createGroup('verified-users');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!unverifiedExists) {
|
|
|
|
|
await createGroup('unverified-users');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bannedExists) {
|
|
|
|
|
await createGroup('banned-users');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createAdministrator() {
|
|
|
|
|
const Groups = require('./groups');
|
|
|
|
|
const memberCount = await Groups.getMemberCount('administrators');
|
|
|
|
|
if (memberCount > 0) {
|
|
|
|
|
console.log('Administrator found, skipping Admin setup');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return await createAdmin();
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
2013-11-14 12:52:00 -06:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createAdmin() {
|
|
|
|
|
const User = require('./user');
|
|
|
|
|
const Groups = require('./groups');
|
|
|
|
|
let password;
|
2013-09-07 15:49:23 -04:00
|
|
|
|
2015-04-22 10:27:54 -04:00
|
|
|
winston.warn('No administrators have been detected, running initial user setup\n');
|
2013-11-14 12:52:00 -06:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
let questions = [{
|
2017-02-17 20:20:42 -07:00
|
|
|
name: 'username',
|
|
|
|
|
description: 'Administrator username',
|
|
|
|
|
required: true,
|
|
|
|
|
type: 'string',
|
|
|
|
|
}, {
|
|
|
|
|
name: 'email',
|
|
|
|
|
description: 'Administrator email address',
|
|
|
|
|
pattern: /.+@.+/,
|
|
|
|
|
required: true,
|
|
|
|
|
}];
|
2020-07-31 12:49:25 -04:00
|
|
|
const passwordQuestions = [{
|
2017-02-17 20:20:42 -07:00
|
|
|
name: 'password',
|
|
|
|
|
description: 'Password',
|
|
|
|
|
required: true,
|
|
|
|
|
hidden: true,
|
|
|
|
|
type: 'string',
|
|
|
|
|
}, {
|
|
|
|
|
name: 'password:confirm',
|
|
|
|
|
description: 'Confirm Password',
|
|
|
|
|
required: true,
|
|
|
|
|
hidden: true,
|
|
|
|
|
type: 'string',
|
|
|
|
|
}];
|
2020-07-31 12:49:25 -04:00
|
|
|
|
|
|
|
|
async function success(results) {
|
2017-02-17 20:20:42 -07:00
|
|
|
if (!results) {
|
2020-07-31 12:49:25 -04:00
|
|
|
throw new Error('aborted');
|
2017-02-17 20:20:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (results['password:confirm'] !== results.password) {
|
2017-02-18 01:56:23 -07:00
|
|
|
winston.warn('Passwords did not match, please try again');
|
2020-07-31 12:49:25 -04:00
|
|
|
return await retryPassword(results);
|
2017-02-17 20:20:42 -07:00
|
|
|
}
|
2017-02-18 01:27:46 -07:00
|
|
|
|
2020-07-30 22:48:24 -04:00
|
|
|
try {
|
|
|
|
|
User.isPasswordValid(results.password);
|
|
|
|
|
} catch (err) {
|
2022-10-11 20:30:54 -04:00
|
|
|
const [namespace, key] = err.message.slice(2, -2).split(':', 2);
|
|
|
|
|
if (namespace && key && err.message.startsWith('[[') && err.message.endsWith(']]')) {
|
|
|
|
|
const lang = require(path.join(__dirname, `../public/language/en-GB/${namespace}`));
|
|
|
|
|
if (lang && lang[key]) {
|
|
|
|
|
err.message = lang[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 23:59:08 -07:00
|
|
|
winston.warn(`Password error, please try again. ${err.message}`);
|
2020-07-31 12:49:25 -04:00
|
|
|
return await retryPassword(results);
|
2017-02-17 20:20:42 -07:00
|
|
|
}
|
2017-02-18 01:27:46 -07:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const adminUid = await User.create({
|
|
|
|
|
username: results.username,
|
|
|
|
|
password: results.password,
|
|
|
|
|
email: results.email,
|
2017-02-17 20:20:42 -07:00
|
|
|
});
|
2020-07-31 12:49:25 -04:00
|
|
|
await Groups.join('administrators', adminUid);
|
|
|
|
|
await Groups.show('administrators');
|
|
|
|
|
await Groups.ownership.grant(adminUid, 'administrators');
|
|
|
|
|
|
|
|
|
|
return password ? results : undefined;
|
2017-02-17 20:20:42 -07:00
|
|
|
}
|
2020-07-31 12:49:25 -04:00
|
|
|
|
|
|
|
|
async function retryPassword(originalResults) {
|
2021-10-18 17:34:26 -04:00
|
|
|
const results = await prompt.get(passwordQuestions);
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
originalResults.password = results.password;
|
|
|
|
|
originalResults['password:confirm'] = results['password:confirm'];
|
2017-02-17 20:20:42 -07:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
return await success(originalResults);
|
2017-02-17 20:20:42 -07:00
|
|
|
}
|
2014-04-14 13:54:11 -04:00
|
|
|
|
|
|
|
|
questions = questions.concat(passwordQuestions);
|
|
|
|
|
|
|
|
|
|
if (!install.values) {
|
2021-10-18 17:34:26 -04:00
|
|
|
const results = await prompt.get(questions);
|
2020-07-31 12:49:25 -04:00
|
|
|
return await success(results);
|
|
|
|
|
}
|
2024-12-09 14:40:49 -05:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
if (!install.values.hasOwnProperty('admin:password') && !nconf.get('admin:password')) {
|
|
|
|
|
console.log('Password was not provided during automated setup, generating one...');
|
|
|
|
|
password = utils.generateUUID().slice(0, 8);
|
|
|
|
|
}
|
2015-04-22 10:27:54 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const results = {
|
|
|
|
|
username: install.values['admin:username'] || nconf.get('admin:username') || 'admin',
|
|
|
|
|
email: install.values['admin:email'] || nconf.get('admin:email') || '',
|
|
|
|
|
password: install.values['admin:password'] || nconf.get('admin:password') || password,
|
|
|
|
|
'password:confirm': install.values['admin:password:confirm'] || nconf.get('admin:password') || password,
|
|
|
|
|
};
|
2014-04-14 13:54:11 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
return await success(results);
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createGlobalModeratorsGroup() {
|
|
|
|
|
const groups = require('./groups');
|
|
|
|
|
const exists = await groups.exists('Global Moderators');
|
|
|
|
|
if (exists) {
|
|
|
|
|
winston.info('Global Moderators group found, skipping creation!');
|
|
|
|
|
} else {
|
|
|
|
|
await groups.create({
|
|
|
|
|
name: 'Global Moderators',
|
|
|
|
|
userTitle: 'Global Moderator',
|
|
|
|
|
description: 'Forum wide moderators',
|
|
|
|
|
hidden: 0,
|
|
|
|
|
private: 1,
|
|
|
|
|
disableJoinRequests: 1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
await groups.show('Global Moderators');
|
2016-01-25 13:36:10 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function giveGlobalPrivileges() {
|
|
|
|
|
const privileges = require('./privileges');
|
|
|
|
|
const defaultPrivileges = [
|
2020-05-26 21:57:38 -04:00
|
|
|
'groups:chat', 'groups:upload:post:image', 'groups:signature', 'groups:search:content',
|
|
|
|
|
'groups:search:users', 'groups:search:tags', 'groups:view:users', 'groups:view:tags', 'groups:view:groups',
|
|
|
|
|
'groups:local:login',
|
2018-09-29 06:49:41 -04:00
|
|
|
];
|
2020-07-31 12:49:25 -04:00
|
|
|
await privileges.global.give(defaultPrivileges, 'registered-users');
|
|
|
|
|
await privileges.global.give(defaultPrivileges.concat([
|
|
|
|
|
'groups:ban', 'groups:upload:post:file', 'groups:view:users:info',
|
|
|
|
|
]), 'Global Moderators');
|
|
|
|
|
await privileges.global.give(['groups:view:users', 'groups:view:tags', 'groups:view:groups'], 'guests');
|
|
|
|
|
await privileges.global.give(['groups:view:users', 'groups:view:tags', 'groups:view:groups'], 'spiders');
|
2024-02-26 11:39:32 -05:00
|
|
|
await privileges.global.give(['groups:view:users'], 'fediverse');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function giveWorldPrivileges() {
|
|
|
|
|
// should match privilege assignment logic in src/categories/create.js EXCEPT commented one liner below
|
|
|
|
|
const privileges = require('./privileges');
|
|
|
|
|
const defaultPrivileges = [
|
|
|
|
|
'groups:find',
|
|
|
|
|
'groups:read',
|
|
|
|
|
'groups:topics:read',
|
|
|
|
|
'groups:topics:create',
|
|
|
|
|
'groups:topics:reply',
|
|
|
|
|
'groups:topics:tag',
|
|
|
|
|
'groups:posts:edit',
|
|
|
|
|
'groups:posts:history',
|
|
|
|
|
'groups:posts:delete',
|
|
|
|
|
'groups:posts:upvote',
|
|
|
|
|
'groups:posts:downvote',
|
|
|
|
|
'groups:topics:delete',
|
|
|
|
|
];
|
|
|
|
|
const modPrivileges = defaultPrivileges.concat([
|
|
|
|
|
'groups:topics:schedule',
|
|
|
|
|
'groups:posts:view_deleted',
|
|
|
|
|
'groups:purge',
|
|
|
|
|
]);
|
|
|
|
|
const guestPrivileges = ['groups:find', 'groups:read', 'groups:topics:read'];
|
|
|
|
|
|
|
|
|
|
await privileges.categories.give(defaultPrivileges, -1, ['registered-users']);
|
2024-03-08 20:53:13 -05:00
|
|
|
await privileges.categories.give(defaultPrivileges.slice(2), -1, ['fediverse']); // different priv set for fediverse
|
2024-02-26 11:39:32 -05:00
|
|
|
await privileges.categories.give(modPrivileges, -1, ['administrators', 'Global Moderators']);
|
|
|
|
|
await privileges.categories.give(guestPrivileges, -1, ['guests', 'spiders']);
|
2017-12-20 15:19:22 -05:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createCategories() {
|
|
|
|
|
const Categories = require('./categories');
|
|
|
|
|
const db = require('./database');
|
|
|
|
|
const cids = await db.getSortedSetRange('categories:cid', 0, -1);
|
|
|
|
|
if (Array.isArray(cids) && cids.length) {
|
2021-02-03 23:59:08 -07:00
|
|
|
console.log(`Categories OK. Found ${cids.length} categories.`);
|
2020-07-31 12:49:25 -04:00
|
|
|
return;
|
|
|
|
|
}
|
2014-07-02 21:55:05 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
console.log('No categories found, populating instance with default categories');
|
2014-07-02 21:55:05 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const default_categories = JSON.parse(
|
|
|
|
|
await fs.promises.readFile(path.join(__dirname, '../', 'install/data/categories.json'), 'utf8')
|
|
|
|
|
);
|
|
|
|
|
for (const categoryData of default_categories) {
|
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
|
await Categories.create(categoryData);
|
|
|
|
|
}
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createMenuItems() {
|
|
|
|
|
const db = require('./database');
|
2015-02-25 13:26:09 -05:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const exists = await db.exists('navigation:enabled');
|
|
|
|
|
if (exists) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const navigation = require('./navigation/admin');
|
|
|
|
|
const data = require('../install/data/navigation.json');
|
|
|
|
|
await navigation.save(data);
|
2015-02-25 13:26:09 -05:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function createWelcomePost() {
|
|
|
|
|
const db = require('./database');
|
|
|
|
|
const Topics = require('./topics');
|
|
|
|
|
|
|
|
|
|
const [content, numTopics] = await Promise.all([
|
|
|
|
|
fs.promises.readFile(path.join(__dirname, '../', 'install/data/welcome.md'), 'utf8'),
|
|
|
|
|
db.getObjectField('global', 'topicCount'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (!parseInt(numTopics, 10)) {
|
|
|
|
|
console.log('Creating welcome post!');
|
|
|
|
|
await Topics.post({
|
|
|
|
|
uid: 1,
|
|
|
|
|
cid: 2,
|
|
|
|
|
title: 'Welcome to your NodeBB!',
|
|
|
|
|
content: content,
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-10-22 13:21:37 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function enableDefaultPlugins() {
|
2017-11-27 13:44:30 -07:00
|
|
|
console.log('Enabling default plugins');
|
2014-04-14 14:10:57 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
let defaultEnabled = [
|
2017-02-17 20:20:42 -07:00
|
|
|
'nodebb-plugin-composer-default',
|
|
|
|
|
'nodebb-plugin-markdown',
|
|
|
|
|
'nodebb-plugin-mentions',
|
2024-09-20 14:04:45 -04:00
|
|
|
'nodebb-plugin-web-push',
|
2017-02-17 20:20:42 -07:00
|
|
|
'nodebb-widget-essentials',
|
|
|
|
|
'nodebb-rewards-essentials',
|
2017-11-28 09:10:47 -07:00
|
|
|
'nodebb-plugin-emoji',
|
|
|
|
|
'nodebb-plugin-emoji-android',
|
2017-02-17 20:20:42 -07:00
|
|
|
];
|
2020-07-31 12:49:25 -04:00
|
|
|
let customDefaults = nconf.get('defaultplugins') || nconf.get('defaultPlugins');
|
2015-08-13 14:23:09 -04:00
|
|
|
|
2022-02-21 20:12:45 -05:00
|
|
|
winston.info(`[install/defaultPlugins] customDefaults ${String(customDefaults)}`);
|
2015-09-02 18:17:58 -04:00
|
|
|
|
2015-08-13 14:23:09 -04:00
|
|
|
if (customDefaults && customDefaults.length) {
|
|
|
|
|
try {
|
2018-03-22 18:33:35 -04:00
|
|
|
customDefaults = Array.isArray(customDefaults) ? customDefaults : JSON.parse(customDefaults);
|
2015-08-13 14:23:09 -04:00
|
|
|
defaultEnabled = defaultEnabled.concat(customDefaults);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// Invalid value received
|
2018-03-22 18:33:35 -04:00
|
|
|
winston.info('[install/enableDefaultPlugins] Invalid defaultPlugins value received. Ignoring.');
|
2015-08-13 14:23:09 -04:00
|
|
|
}
|
2015-08-13 12:47:59 -04:00
|
|
|
}
|
|
|
|
|
|
2018-10-20 14:40:48 -04:00
|
|
|
defaultEnabled = _.uniq(defaultEnabled);
|
2015-08-13 12:47:59 -04:00
|
|
|
|
2015-09-02 18:17:58 -04:00
|
|
|
winston.info('[install/enableDefaultPlugins] activating default plugins', defaultEnabled);
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
const db = require('./database');
|
|
|
|
|
const order = defaultEnabled.map((plugin, index) => index);
|
|
|
|
|
await db.sortedSetAdd('plugins:active', order, defaultEnabled);
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function setCopyrightWidget() {
|
|
|
|
|
const db = require('./database');
|
|
|
|
|
const [footerJSON, footer] = await Promise.all([
|
|
|
|
|
fs.promises.readFile(path.join(__dirname, '../', 'install/data/footer.json'), 'utf8'),
|
|
|
|
|
db.getObjectField('widgets:global', 'footer'),
|
|
|
|
|
]);
|
2015-04-23 17:03:31 -04:00
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
if (!footer && footerJSON) {
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
await db.setObjectField('widgets:global', 'sidebar-footer', footerJSON);
|
2020-07-31 12:49:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-06 18:22:59 -04:00
|
|
|
async function copyFavicon() {
|
|
|
|
|
const file = require('./file');
|
|
|
|
|
const pathToIco = path.join(nconf.get('upload_path'), 'system', 'favicon.ico');
|
|
|
|
|
const defaultIco = path.join(nconf.get('base_dir'), 'public', 'favicon.ico');
|
|
|
|
|
const targetExists = await file.exists(pathToIco);
|
|
|
|
|
const defaultExists = await file.exists(defaultIco);
|
|
|
|
|
|
|
|
|
|
if (defaultExists && !targetExists) {
|
|
|
|
|
try {
|
|
|
|
|
await fs.promises.copyFile(defaultIco, pathToIco);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
winston.error(`Cannot copy favicon.ico\n${err.stack}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
async function checkUpgrade() {
|
|
|
|
|
const upgrade = require('./upgrade');
|
|
|
|
|
try {
|
|
|
|
|
await upgrade.check();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (err.message === 'schema-out-of-date') {
|
|
|
|
|
await upgrade.run();
|
|
|
|
|
return;
|
2015-02-12 15:03:46 -05:00
|
|
|
}
|
2020-07-31 12:49:25 -04:00
|
|
|
throw err;
|
|
|
|
|
}
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-15 01:16:40 +02:00
|
|
|
async function installPlugins() {
|
|
|
|
|
const pluginInstall = require('./plugins');
|
|
|
|
|
const nbbVersion = require(paths.currentPackage).version;
|
|
|
|
|
await Promise.all((await pluginInstall.getActive()).map(async (id) => {
|
|
|
|
|
if (await pluginInstall.isInstalled(id)) return;
|
|
|
|
|
const version = await pluginInstall.suggest(id, nbbVersion);
|
|
|
|
|
await pluginInstall.toggleInstall(id, version.version);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
install.setup = async function () {
|
|
|
|
|
try {
|
2022-02-15 19:13:43 +01:00
|
|
|
checkSetupFlagEnv();
|
2020-07-31 12:49:25 -04:00
|
|
|
checkCIFlag();
|
|
|
|
|
await setupConfig();
|
|
|
|
|
await setupDefaultConfigs();
|
|
|
|
|
await enableDefaultTheme();
|
|
|
|
|
await createCategories();
|
2022-02-07 10:30:46 -05:00
|
|
|
await createDefaultUserGroups();
|
2020-07-31 12:49:25 -04:00
|
|
|
const adminInfo = await createAdministrator();
|
|
|
|
|
await createGlobalModeratorsGroup();
|
|
|
|
|
await giveGlobalPrivileges();
|
2024-02-26 11:39:32 -05:00
|
|
|
await giveWorldPrivileges();
|
2020-07-31 12:49:25 -04:00
|
|
|
await createMenuItems();
|
|
|
|
|
await createWelcomePost();
|
|
|
|
|
await enableDefaultPlugins();
|
|
|
|
|
await setCopyrightWidget();
|
2021-04-06 18:22:59 -04:00
|
|
|
await copyFavicon();
|
2023-04-15 01:16:40 +02:00
|
|
|
if (nconf.get('plugins:autoinstall')) await installPlugins();
|
2020-07-31 12:49:25 -04:00
|
|
|
await checkUpgrade();
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
...adminInfo,
|
|
|
|
|
};
|
|
|
|
|
return data;
|
|
|
|
|
} catch (err) {
|
2014-04-14 14:10:57 -04:00
|
|
|
if (err) {
|
2021-02-03 23:59:08 -07:00
|
|
|
winston.warn(`NodeBB Setup Aborted.\n ${err.stack}`);
|
2018-01-15 15:05:33 -05:00
|
|
|
process.exit(1);
|
2014-04-14 14:10:57 -04:00
|
|
|
}
|
2020-07-31 12:49:25 -04:00
|
|
|
}
|
2014-04-14 13:54:11 -04:00
|
|
|
};
|
|
|
|
|
|
2020-07-31 12:49:25 -04:00
|
|
|
install.save = async function (server_conf) {
|
|
|
|
|
let serverConfigPath = path.join(__dirname, '../config.json');
|
2014-04-14 13:54:11 -04:00
|
|
|
|
|
|
|
|
if (nconf.get('config')) {
|
|
|
|
|
serverConfigPath = path.resolve(__dirname, '../', nconf.get('config'));
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 16:20:39 -05:00
|
|
|
let currentConfig = {};
|
|
|
|
|
try {
|
|
|
|
|
currentConfig = require(serverConfigPath);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:21:58 -05:00
|
|
|
await fs.promises.writeFile(serverConfigPath, JSON.stringify({
|
|
|
|
|
...currentConfig,
|
|
|
|
|
...server_conf,
|
|
|
|
|
}, null, 4));
|
2020-07-31 12:49:25 -04:00
|
|
|
console.log('Configuration Saved OK');
|
|
|
|
|
nconf.file({
|
|
|
|
|
file: serverConfigPath,
|
2014-04-14 13:54:11 -04:00
|
|
|
});
|
|
|
|
|
};
|
2024-02-26 14:22:35 -05:00
|
|
|
|
|
|
|
|
install.giveWorldPrivileges = giveWorldPrivileges; // exported for upgrade script and test runner
|