From a6f6ddc34e46b9d9754544fb5ec840aa019474be Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 27 Mar 2022 04:57:04 +0000 Subject: [PATCH] limit federation of reactions on direct notes (#8448) --- packages/backend/src/services/note/reaction/create.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/note/reaction/create.ts b/packages/backend/src/services/note/reaction/create.ts index 77de29d794..5a0948bca9 100644 --- a/packages/backend/src/services/note/reaction/create.ts +++ b/packages/backend/src/services/note/reaction/create.ts @@ -124,7 +124,16 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note, const reactee = await Users.findOneBy({ id: note.userId }); dm.addDirectRecipe(reactee as IRemoteUser); } - dm.addFollowersRecipe(); + + if (['public', 'home', 'followers'].includes(note.visibility)) { + dm.addFollowersRecipe(); + } else if (note.visibility === 'specified') { + const visibleUsers = await Promise.all(note.visibleUserIds.map(id => Users.findOneBy({ id }))); + for (const u of visibleUsers.filter(u => u && Users.isRemoteUser(u))) { + dm.addDirectRecipe(u as IRemoteUser); + } + } + dm.execute(); } //#endregion