From 89dd2fb04a3524d2a2d4d356e9b728d6ff600350 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 21 Jun 2024 16:57:59 -0400 Subject: [PATCH] fix: move call to retrieve cid followers out of loop --- src/activitypub/notes.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 94156940dc..4e06ddb40d 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -158,6 +158,8 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { unprocessed.pop(); } + const cidFollowers = await activitypub.notes.getCategoryFollowers(cid); + unprocessed.reverse(); for (const post of unprocessed) { const { to, cc, attachment } = post._activitypub; @@ -170,11 +172,8 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { ]); // Category announce - if (object && object.id === post.pid) { - // eslint-disable-next-line no-await-in-loop - const followers = await activitypub.notes.getCategoryFollowers(cid); - // eslint-disable-next-line no-await-in-loop - await activitypub.send('cid', cid, followers, { + if (cidFollowers.length && object && object.id === post.pid) { + activitypub.send('cid', cid, cidFollowers, { id: `${object.id}#activity/announce/${Date.now()}`, type: 'Announce', to: [`${nconf.get('url')}/category/${cid}/followers`],