mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
refactor: if user.delete fails in actor prune
remove from ap sets/keys
This commit is contained in:
@@ -609,6 +609,8 @@ Actors.prune = async () => {
|
||||
let deletionCountNonExisting = 0;
|
||||
let notDeletedDueToLocalContent = 0;
|
||||
const preservedIds = [];
|
||||
const cleanupUids = [];
|
||||
|
||||
await batch.processArray(ids, async (ids) => {
|
||||
const exists = await Promise.all([
|
||||
db.exists(ids.map(id => `userRemote:${id}`)),
|
||||
@@ -656,6 +658,9 @@ Actors.prune = async () => {
|
||||
deletionCount += 1;
|
||||
} catch (err) {
|
||||
winston.error(`Failed to delete user with uid ${uid}: ${err.stack}`);
|
||||
if (err.message === '[[error:no-user]]') {
|
||||
cleanupUids.push(uid);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notDeletedDueToLocalContent += 1;
|
||||
@@ -663,6 +668,14 @@ Actors.prune = async () => {
|
||||
}
|
||||
}));
|
||||
|
||||
if (cleanupUids.length) {
|
||||
await Promise.all([
|
||||
db.sortedSetRemove('usersRemote:lastCrawled', cleanupUids),
|
||||
db.deleteAll(cleanupUids.map(uid => `userRemote:${uid}`)),
|
||||
]);
|
||||
winston.info(`[actors/prune] Cleaned up ${cleanupUids.length} remote users that were not found in the database.`);
|
||||
}
|
||||
|
||||
// Remote categories
|
||||
let counts = await categories.getCategoriesFields(cids, ['topic_count']);
|
||||
counts = counts.map(count => count.topic_count);
|
||||
|
||||
Reference in New Issue
Block a user