Node.js based forum software built for the modern web
refactor: if user.delete fails in actor prune
Barış Soner Uşaklıd5f6d158f49a
diff --git a/src/activitypub/actors.js b/src/activitypub/actors.jsindex d48acda82b..50ddafaac2 100644--- a/src/activitypub/actors.js+++ b/src/activitypub/actors.js@@ -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 categorieslet counts = await categories.getCategoriesFields(cids, ['topic_count']);counts = counts.map(count => count.topic_count);