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
This commit is contained in:
@@ -148,14 +148,10 @@ export async function fetchSwarmTimeline(
|
|||||||
// Always include our own posts
|
// Always include our own posts
|
||||||
const ourDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost';
|
const ourDomain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost';
|
||||||
|
|
||||||
// Filter out NSFW nodes if not including NSFW content
|
// Always query all nodes - we filter posts, not nodes
|
||||||
const eligibleNodes = includeNsfw
|
|
||||||
? nodes
|
|
||||||
: nodes.filter(n => !n.isNsfw);
|
|
||||||
|
|
||||||
const nodesToQuery = [
|
const nodesToQuery = [
|
||||||
ourDomain,
|
ourDomain,
|
||||||
...eligibleNodes.map(n => n.domain).filter(d => d !== ourDomain)
|
...nodes.map(n => n.domain).filter(d => d !== ourDomain)
|
||||||
].slice(0, maxNodes);
|
].slice(0, maxNodes);
|
||||||
|
|
||||||
// Fetch from all nodes in parallel
|
// Fetch from all nodes in parallel
|
||||||
@@ -181,7 +177,8 @@ export async function fetchSwarmTimeline(
|
|||||||
error: result.error,
|
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
|
const filteredPosts = includeNsfw
|
||||||
? result.posts
|
? result.posts
|
||||||
: result.posts.filter(p => !p.isNsfw);
|
: result.posts.filter(p => !p.isNsfw);
|
||||||
|
|||||||
Reference in New Issue
Block a user