Node.js based forum software built for the modern web
fix(activitypub): do not prune banned remote users
Julian Lam0ead3e378203
diff --git a/src/activitypub/actors.js b/src/activitypub/actors.jsindex c77b2f8193..f964afa324 100644--- a/src/activitypub/actors.js+++ b/src/activitypub/actors.js@@ -645,17 +645,18 @@ Actors.prune = async () => {cids = Array.from(cids);// Remote users- const [postCounts, roomCounts, followCounts] = await Promise.all([+ const [postCounts, roomCounts, followCounts, isBanned] = await Promise.all([db.sortedSetsCard(uids.map(uid => `uid:${uid}:posts`)),db.sortedSetsCard(uids.map(uid => `uid:${uid}:chat:rooms`)),Actors.getLocalFollowCounts(uids),+ user.bans.isBanned(uids),]);await Promise.all(uids.map(async (uid, idx) => {const { followers, following } = followCounts[idx];const postCount = postCounts[idx];const roomCount = roomCounts[idx];- if ([postCount, roomCount, followers, following].every(metric => metric < 1)) {+ if (!isBanned[idx] && [postCount, roomCount, followers, following].every(metric => metric < 1)) {try {await user.deleteAccount(uid);deletionCount += 1;diff --git a/test/activitypub/actors.js b/test/activitypub/actors.jsindex 470601b38c..4adf161447 100644--- a/test/activitypub/actors.js+++ b/test/activitypub/actors.js@@ -783,6 +783,20 @@ describe('Pruning', () => {assert.strictEqual(result.counts.preserved, this.current.counts.preserved + 1);assert.strictEqual(result.counts.missing, 0);});++ it('should not purge a banned user even if they have no content', async () => {+ const { id: uid } = helpers.mocks.person();+ await activitypub.actors.assert([uid]);+ await user.bans.ban(uid);++ const result = await activitypub.actors.prune();++ assert.strictEqual(result.counts.deleted, 0);+ assert(result.preserved.has(uid));++ await user.bans.unban(uid);+ await user.deleteAccount(uid);+ });});describe('Categories', () => {