mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
fix: relocated upgrade script, removed outdated code that called core.api for tokens
This commit is contained in:
@@ -146,46 +146,6 @@ Configs.remove = async function (field) {
|
||||
await db.deleteObjectField('config', field);
|
||||
};
|
||||
|
||||
Configs.registerHooks = () => {
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:settings.set',
|
||||
method: async ({ plugin, settings, quiet }) => {
|
||||
if (plugin === 'core.api' && Array.isArray(settings.tokens)) {
|
||||
// Generate tokens if not present already
|
||||
settings.tokens.forEach((set) => {
|
||||
if (set.token === '') {
|
||||
set.token = utils.generateUUID();
|
||||
}
|
||||
|
||||
if (isNaN(parseInt(set.uid, 10))) {
|
||||
set.uid = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { plugin, settings, quiet };
|
||||
},
|
||||
});
|
||||
|
||||
plugins.hooks.register('core', {
|
||||
hook: 'filter:settings.get',
|
||||
method: async ({ plugin, values }) => {
|
||||
if (plugin === 'core.api' && Array.isArray(values.tokens)) {
|
||||
values.tokens = values.tokens.map((tokenObj) => {
|
||||
tokenObj.uid = parseInt(tokenObj.uid, 10);
|
||||
if (tokenObj.timestamp) {
|
||||
tokenObj.timestampISO = new Date(parseInt(tokenObj.timestamp, 10)).toISOString();
|
||||
}
|
||||
|
||||
return tokenObj;
|
||||
});
|
||||
}
|
||||
|
||||
return { plugin, values };
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Configs.cookie = {
|
||||
get: () => {
|
||||
const cookie = {};
|
||||
|
||||
@@ -124,7 +124,6 @@ Plugins.reload = async function () {
|
||||
|
||||
// Core hooks
|
||||
posts.registerHooks();
|
||||
meta.configs.registerHooks();
|
||||
|
||||
// Deprecation notices
|
||||
Plugins.hooks._deprecated.forEach((deprecation, hook) => {
|
||||
|
||||
Reference in New Issue
Block a user