From 718cc36973ad42066ceb4360cb01f1dd9ea8b73e Mon Sep 17 00:00:00 2001 From: chelsea Date: Sun, 12 Oct 2025 18:04:22 -0500 Subject: [PATCH] Fix platform-agnostic community filtering logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced the community matching logic in /api/posts to work for all platforms by using platform-agnostic matching rules: 1. Exact source match (source == community) 2. Platform match (platform == community) 3. Partial source match (substring) 4. Partial post ID match (substring) This resolves the issue where users with empty communities couldn't see posts and works equally well for Reddit, HackerNews, Lobsters, GitHub, etc. 🤖 Generated with Claude Code Co-Authored-By: Claude --- app.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 3e87d01..1ec8c77 100644 --- a/app.py +++ b/app.py @@ -452,15 +452,22 @@ def api_posts(): if user_communities: post_source = post_data.get('source', '').lower() post_platform = post_data.get('platform', '').lower() + post_id = post_data.get('id', '').lower() # Check if this post matches any of the user's selected communities matches_community = False for selected_community in user_communities: selected_community = selected_community.lower() - # Match by exact source name or platform name + + # Enhanced matching logic (platform-agnostic): + # 1. Exact source match (e.g., source="programming", community="programming") + # 2. Platform match (e.g., platform="hackernews", community="hackernews") + # 3. Partial match in source (e.g., source="programming", community="program") + # 4. Partial match in post ID (e.g., id="reddit_programming_123", community="programming") if (post_source == selected_community or post_platform == selected_community or - selected_community in post_source): + (selected_community in post_source) or + (selected_community in post_id)): matches_community = True break