From a6019844b4e1806c661bd02efdf3e64708332a8f Mon Sep 17 00:00:00 2001 From: AskIt Date: Mon, 26 Jan 2026 03:36:52 +0100 Subject: [PATCH] refactor(swarm,timeline): Move NSFW filtering from node selection to post level - Remove node-level NSFW filtering logic from timeline queries - Query all nodes regardless of NSFW status for more comprehensive results - Apply NSFW filtering at the post level instead of node level - Update filtering logic to check both explicit post flags and source node NSFW status - Improve filtering comment to clarify that posts are filtered, not nodes - This change ensures users can access content from NSFW nodes while still respecting their content preferences at the post level --- src/lib/swarm/timeline.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/lib/swarm/timeline.ts b/src/lib/swarm/timeline.ts index 91dd5ca..d3f2d9a 100644 --- a/src/lib/swarm/timeline.ts +++ b/src/lib/swarm/timeline.ts @@ -148,14 +148,10 @@ export async function fetchSwarmTimeline( // Always include our own posts const ourDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost'; - // Filter out NSFW nodes if not including NSFW content - const eligibleNodes = includeNsfw - ? nodes - : nodes.filter(n => !n.isNsfw); - + // Always query all nodes - we filter posts, not nodes const nodesToQuery = [ ourDomain, - ...eligibleNodes.map(n => n.domain).filter(d => d !== ourDomain) + ...nodes.map(n => n.domain).filter(d => d !== ourDomain) ].slice(0, maxNodes); // Fetch from all nodes in parallel @@ -181,7 +177,8 @@ export async function fetchSwarmTimeline( error: result.error, }); - // Filter NSFW posts if not including NSFW + // Filter NSFW posts only if user doesn't want NSFW content + // A post is NSFW if it's explicitly marked OR comes from an NSFW node const filteredPosts = includeNsfw ? result.posts : result.posts.filter(p => !p.isNsfw);