mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-27 13:06:09 +02:00
Fix up some deprecated config refs
This commit is contained in:
parent
eb4f933285
commit
dd2a6258d5
5 changed files with 27 additions and 26 deletions
|
@ -175,10 +175,11 @@ function initialize(cb) {
|
||||||
async.series(
|
async.series(
|
||||||
[
|
[
|
||||||
function createMissingDirectories(callback) {
|
function createMissingDirectories(callback) {
|
||||||
async.each(Object.keys(conf.config.paths), function entry(pathKey, next) {
|
const Config = conf.get();
|
||||||
mkdirs(conf.config.paths[pathKey], function dirCreated(err) {
|
async.each(Object.keys(Config.paths), function entry(pathKey, next) {
|
||||||
|
mkdirs(Config.paths[pathKey], function dirCreated(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.error('Could not create path: ' + conf.config.paths[pathKey] + ': ' + err.toString());
|
console.error('Could not create path: ' + Config.paths[pathKey] + ': ' + err.toString());
|
||||||
}
|
}
|
||||||
return next(err);
|
return next(err);
|
||||||
});
|
});
|
||||||
|
|
|
@ -106,9 +106,7 @@ function mergeValidateAndFinalize(config, cb) {
|
||||||
return callback(null, mergedConfig);
|
return callback(null, mergedConfig);
|
||||||
},
|
},
|
||||||
function setIt(mergedConfig, callback) {
|
function setIt(mergedConfig, callback) {
|
||||||
// :TODO: .config property is to be deprecated once conversions are done
|
currentConfiguration = mergedConfig;
|
||||||
exports.config = currentConfiguration = mergedConfig;
|
|
||||||
|
|
||||||
exports.get = () => currentConfiguration;
|
exports.get = () => currentConfiguration;
|
||||||
return callback(null);
|
return callback(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// ENiGMA½
|
// ENiGMA½
|
||||||
const conf = require('./config.js');
|
const conf = require('./config');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const sqlite3 = require('sqlite3');
|
const sqlite3 = require('sqlite3');
|
||||||
|
@ -30,7 +30,8 @@ function getTransactionDatabase(db) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDatabasePath(name) {
|
function getDatabasePath(name) {
|
||||||
return paths.join(conf.config.paths.db, `${name}.sqlite3`);
|
const Config = conf.get();
|
||||||
|
return paths.join(Config.paths.db, `${name}.sqlite3`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModDatabasePath(moduleInfo, suffix) {
|
function getModDatabasePath(moduleInfo, suffix) {
|
||||||
|
@ -53,7 +54,8 @@ function getModDatabasePath(moduleInfo, suffix) {
|
||||||
(full.split('.').length > 1 && HOST_RE.test(full)),
|
(full.split('.').length > 1 && HOST_RE.test(full)),
|
||||||
'packageName must follow Reverse Domain Name Notation - https://en.wikipedia.org/wiki/Reverse_domain_name_notation');
|
'packageName must follow Reverse Domain Name Notation - https://en.wikipedia.org/wiki/Reverse_domain_name_notation');
|
||||||
|
|
||||||
return paths.join(conf.config.paths.modsDb, `${full}.sqlite3`);
|
const Config = conf.get();
|
||||||
|
return paths.join(Config.paths.modsDb, `${full}.sqlite3`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadDatabaseForMod(modInfo, cb) {
|
function loadDatabaseForMod(modInfo, cb) {
|
||||||
|
@ -162,9 +164,9 @@ const DB_INIT_TABLE = {
|
||||||
enableForeignKeys(dbs.user);
|
enableForeignKeys(dbs.user);
|
||||||
|
|
||||||
dbs.user.run(
|
dbs.user.run(
|
||||||
`CREATE TABLE IF NOT EXISTS user (
|
`CREATE TABLE IF NOT EXISTS user (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
user_name VARCHAR NOT NULL,
|
user_name VARCHAR NOT NULL,
|
||||||
UNIQUE(user_name)
|
UNIQUE(user_name)
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
@ -177,13 +179,13 @@ const DB_INIT_TABLE = {
|
||||||
prop_name VARCHAR NOT NULL,
|
prop_name VARCHAR NOT NULL,
|
||||||
prop_value VARCHAR,
|
prop_value VARCHAR,
|
||||||
UNIQUE(user_id, prop_name),
|
UNIQUE(user_id, prop_name),
|
||||||
FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE
|
FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
|
||||||
dbs.user.run(
|
dbs.user.run(
|
||||||
`CREATE TABLE IF NOT EXISTS user_group_member (
|
`CREATE TABLE IF NOT EXISTS user_group_member (
|
||||||
group_name VARCHAR NOT NULL,
|
group_name VARCHAR NOT NULL,
|
||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
UNIQUE(group_name, user_id)
|
UNIQUE(group_name, user_id)
|
||||||
);`
|
);`
|
||||||
|
@ -227,9 +229,9 @@ const DB_INIT_TABLE = {
|
||||||
|
|
||||||
dbs.message.run(
|
dbs.message.run(
|
||||||
`CREATE TABLE IF NOT EXISTS message (
|
`CREATE TABLE IF NOT EXISTS message (
|
||||||
message_id INTEGER PRIMARY KEY,
|
message_id INTEGER PRIMARY KEY,
|
||||||
area_tag VARCHAR NOT NULL,
|
area_tag VARCHAR NOT NULL,
|
||||||
message_uuid VARCHAR(36) NOT NULL,
|
message_uuid VARCHAR(36) NOT NULL,
|
||||||
reply_to_message_id INTEGER,
|
reply_to_message_id INTEGER,
|
||||||
to_user_name VARCHAR NOT NULL,
|
to_user_name VARCHAR NOT NULL,
|
||||||
from_user_name VARCHAR NOT NULL,
|
from_user_name VARCHAR NOT NULL,
|
||||||
|
@ -237,7 +239,7 @@ const DB_INIT_TABLE = {
|
||||||
message, /* FTS @ message_fts */
|
message, /* FTS @ message_fts */
|
||||||
modified_timestamp DATETIME NOT NULL,
|
modified_timestamp DATETIME NOT NULL,
|
||||||
view_count INTEGER NOT NULL DEFAULT 0,
|
view_count INTEGER NOT NULL DEFAULT 0,
|
||||||
UNIQUE(message_uuid)
|
UNIQUE(message_uuid)
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -284,7 +286,7 @@ const DB_INIT_TABLE = {
|
||||||
meta_category INTEGER NOT NULL,
|
meta_category INTEGER NOT NULL,
|
||||||
meta_name VARCHAR NOT NULL,
|
meta_name VARCHAR NOT NULL,
|
||||||
meta_value VARCHAR NOT NULL,
|
meta_value VARCHAR NOT NULL,
|
||||||
UNIQUE(message_id, meta_category, meta_name, meta_value),
|
UNIQUE(message_id, meta_category, meta_name, meta_value),
|
||||||
FOREIGN KEY(message_id) REFERENCES message(message_id) ON DELETE CASCADE
|
FOREIGN KEY(message_id) REFERENCES message(message_id) ON DELETE CASCADE
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
@ -342,7 +344,7 @@ const DB_INIT_TABLE = {
|
||||||
file_name, /* FTS @ file_fts */
|
file_name, /* FTS @ file_fts */
|
||||||
storage_tag VARCHAR NOT NULL,
|
storage_tag VARCHAR NOT NULL,
|
||||||
desc, /* FTS @ file_fts */
|
desc, /* FTS @ file_fts */
|
||||||
desc_long, /* FTS @ file_fts */
|
desc_long, /* FTS @ file_fts */
|
||||||
upload_timestamp DATETIME NOT NULL
|
upload_timestamp DATETIME NOT NULL
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
@ -395,7 +397,7 @@ const DB_INIT_TABLE = {
|
||||||
file_id INTEGER NOT NULL,
|
file_id INTEGER NOT NULL,
|
||||||
meta_name VARCHAR NOT NULL,
|
meta_name VARCHAR NOT NULL,
|
||||||
meta_value VARCHAR NOT NULL,
|
meta_value VARCHAR NOT NULL,
|
||||||
UNIQUE(file_id, meta_name, meta_value),
|
UNIQUE(file_id, meta_name, meta_value),
|
||||||
FOREIGN KEY(file_id) REFERENCES file(file_id) ON DELETE CASCADE
|
FOREIGN KEY(file_id) REFERENCES file(file_id) ON DELETE CASCADE
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
@ -404,7 +406,7 @@ const DB_INIT_TABLE = {
|
||||||
`CREATE TABLE IF NOT EXISTS hash_tag (
|
`CREATE TABLE IF NOT EXISTS hash_tag (
|
||||||
hash_tag_id INTEGER PRIMARY KEY,
|
hash_tag_id INTEGER PRIMARY KEY,
|
||||||
hash_tag VARCHAR NOT NULL,
|
hash_tag VARCHAR NOT NULL,
|
||||||
|
|
||||||
UNIQUE(hash_tag)
|
UNIQUE(hash_tag)
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
@ -413,7 +415,7 @@ const DB_INIT_TABLE = {
|
||||||
`CREATE TABLE IF NOT EXISTS file_hash_tag (
|
`CREATE TABLE IF NOT EXISTS file_hash_tag (
|
||||||
hash_tag_id INTEGER NOT NULL,
|
hash_tag_id INTEGER NOT NULL,
|
||||||
file_id INTEGER NOT NULL,
|
file_id INTEGER NOT NULL,
|
||||||
|
|
||||||
UNIQUE(hash_tag_id, file_id)
|
UNIQUE(hash_tag_id, file_id)
|
||||||
);`
|
);`
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// ENiGMA½
|
// ENiGMA½
|
||||||
const conf = require('./config.js');
|
const Config = require('./config').get;
|
||||||
const logger = require('./logger.js');
|
const logger = require('./logger.js');
|
||||||
const ServerModule = require('./server_module.js').ServerModule;
|
const ServerModule = require('./server_module.js').ServerModule;
|
||||||
const clientConns = require('./client_connections.js');
|
const clientConns = require('./client_connections.js');
|
||||||
|
@ -28,7 +28,7 @@ module.exports = class LoginServerModule extends ServerModule {
|
||||||
//
|
//
|
||||||
// Choose initial theme before we have user context
|
// Choose initial theme before we have user context
|
||||||
//
|
//
|
||||||
const preLoginTheme = _.get(conf.config, 'theme.preLogin');
|
const preLoginTheme = _.get(Config(), 'theme.preLogin');
|
||||||
if('*' === preLoginTheme) {
|
if('*' === preLoginTheme) {
|
||||||
client.user.properties[UserProps.ThemeId] = theme.getRandomTheme() || '';
|
client.user.properties[UserProps.ThemeId] = theme.getRandomTheme() || '';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -433,10 +433,10 @@ function getThemeArt(options, cb) {
|
||||||
const config = Config();
|
const config = Config();
|
||||||
if(!options.themeId && _.has(options, [ 'client', 'user', 'properties', UserProps.ThemeId ])) {
|
if(!options.themeId && _.has(options, [ 'client', 'user', 'properties', UserProps.ThemeId ])) {
|
||||||
options.themeId = options.client.user.properties[UserProps.ThemeId];
|
options.themeId = options.client.user.properties[UserProps.ThemeId];
|
||||||
} else {
|
|
||||||
options.themeId = config.theme.default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.themeId = options.themeId || config.theme.default;
|
||||||
|
|
||||||
// :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ...
|
// :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ...
|
||||||
// :TODO: Some of these options should only be set if not provided!
|
// :TODO: Some of these options should only be set if not provided!
|
||||||
options.asAnsi = true; // always convert to ANSI
|
options.asAnsi = true; // always convert to ANSI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue