refactor: if user.delete fails in actor prune

remove from ap sets/keys
This commit is contained in:
Barış Soner Uşaklı
2025-08-01 11:50:13 -04:00
parent e851a52390
commit d5f6d158f4

View File

@@ -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);