From 53dc79a1bd837338ec60f06e6369ce6cf735c011 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 19 Mar 2025 11:02:48 -0400 Subject: [PATCH] test: remote user pruning tests --- test/activitypub/actors.js | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/activitypub/actors.js b/test/activitypub/actors.js index 8a39c39b72..7780bd57c2 100644 --- a/test/activitypub/actors.js +++ b/test/activitypub/actors.js @@ -515,6 +515,52 @@ describe('Pruning', () => { meta.config.activitypubUserPruneDays = 7; }); + describe('Users', () => { + it('should do nothing if the user is newer than the prune cutoff', async () => { + const { id: uid } = helpers.mocks.person(); + await activitypub.actors.assert([uid]); + + meta.config.activitypubUserPruneDays = 1; + const result = await activitypub.actors.prune(); + + assert.strictEqual(result.counts.deleted, 0); + assert.strictEqual(result.counts.preserved, 0); + assert.strictEqual(result.counts.missing, 0); + + meta.config.activitypubUserPruneDays = 0; + user.deleteAccount(uid); + }); + + it('should purge the user if they have no content (posts, likes, etc.)', async () => { + const { id: uid } = helpers.mocks.person(); + await activitypub.actors.assert([uid]); + + const result = await activitypub.actors.prune(); + + assert.strictEqual(result.counts.deleted, 1); + assert.strictEqual(result.counts.preserved, 0); + assert.strictEqual(result.counts.missing, 0); + }); + + it('should do nothing if the user has some content (e.g. a topic)', async () => { + const { cid } = await categories.create({ name: utils.generateUUID() }); + const { id: uid } = helpers.mocks.person(); + const { id, note } = helpers.mocks.note({ + attributedTo: uid, + cc: [`${nconf.get('url')}/category/${cid}`], + }); + + const assertion = await activitypub.notes.assert(0, id); + assert(assertion); + + const result = await activitypub.actors.prune(); + + assert.strictEqual(result.counts.deleted, 0); + assert.strictEqual(result.counts.preserved, 1); + assert.strictEqual(result.counts.missing, 0); + }); + }); + describe('Categories', () => { it('should do nothing if the category is newer than the prune cutoff', async () => { const { id: cid } = helpers.mocks.group();