From 831b3d4ee2866b23d435416a2dafdc4c36817546 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 2 Dec 2023 20:25:36 +0900 Subject: [PATCH] fix: filter featured collection Co-authored-by: naskya --- packages/backend/src/server/activitypub/featured.ts | 12 +++++++++--- packages/backend/src/services/i/pin.ts | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts index a5131777de..b88e0d8b87 100644 --- a/packages/backend/src/server/activitypub/featured.ts +++ b/packages/backend/src/server/activitypub/featured.ts @@ -28,13 +28,19 @@ export default async (ctx: Router.RouterContext) => { return; } - const pinings = await UserNotePinings.find({ + const pinning = await UserNotePinings.find({ where: { userId: user.id }, order: { id: "DESC" }, }); - const pinnedNotes = await Promise.all( - pinings.map((pining) => Notes.findOneByOrFail({ id: pining.noteId })), + const pinnedNotes = ( + await Promise.all( + pinning.map((pinnedNote) => + this.notesRepository.findOneByOrFail({ id: pinnedNote.noteId }), + ), + ) + ).filter( + (note) => !note.localOnly && ["public", "home"].includes(note.visibility), ); const renderedNotes = await Promise.all( diff --git a/packages/backend/src/services/i/pin.ts b/packages/backend/src/services/i/pin.ts index e23f669f12..3926f72302 100644 --- a/packages/backend/src/services/i/pin.ts +++ b/packages/backend/src/services/i/pin.ts @@ -57,7 +57,11 @@ export async function addPinned( } as UserNotePining); // Deliver to remote followers - if (Users.isLocalUser(user)) { + if ( + Users.isLocalUser(user) && + !note.localOnly && + ["public", "home"].includes(note.visibility) + ) { deliverPinnedChange(user.id, note.id, true); } } @@ -90,7 +94,11 @@ export async function removePinned( }); // Deliver to remote followers - if (Users.isLocalUser(user)) { + if ( + Users.isLocalUser(user) && + !note.localOnly && + ["public", "home"].includes(note.visibility) + ) { deliverPinnedChange(user.id, noteId, false); } }