mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: closes #12795, don't crash if there is an error in auto approve from queue
This commit is contained in:
@@ -14,8 +14,12 @@ const slugify = require('../slugify');
|
|||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
new cronJob('0 * * * *', (() => {
|
new cronJob('0 * * * *', (async () => {
|
||||||
User.autoApprove();
|
try {
|
||||||
|
await User.autoApprove();
|
||||||
|
} catch (err) {
|
||||||
|
winston.error(err.stack);
|
||||||
|
}
|
||||||
}), null, true);
|
}), null, true);
|
||||||
|
|
||||||
User.addToApprovalQueue = async function (userData) {
|
User.addToApprovalQueue = async function (userData) {
|
||||||
@@ -160,8 +164,14 @@ module.exports = function (User) {
|
|||||||
const users = await db.getSortedSetRevRangeWithScores('registration:queue', 0, -1);
|
const users = await db.getSortedSetRevRangeWithScores('registration:queue', 0, -1);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const user of users.filter(user => now - user.score >= meta.config.autoApproveTime * 3600000)) {
|
for (const user of users.filter(user => now - user.score >= meta.config.autoApproveTime * 3600000)) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
try {
|
||||||
await User.acceptRegistration(user.value);
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await User.acceptRegistration(user.value);
|
||||||
|
} catch (err) {
|
||||||
|
winston.error(err.stack);
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await removeFromQueue(user.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user