-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Add Advanced Tag-Based Post Filtering with Multi-Tag & Comment Controls #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: sumit1642 <159118374+sumit1642@users.noreply.github.com>
Co-authored-by: sumit1642 <159118374+sumit1642@users.noreply.github.com>
Co-authored-by: sumit1642 <159118374+sumit1642@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements advanced tag-based post filtering with multi-tag support, comment controls, and guest user restrictions. The changes enable more sophisticated content discovery through AND/OR tag filtering logic, allow post authors to disable comments on their posts, and provide optional limits on content visibility for unauthenticated users.
Key Changes:
- Added multi-tag filtering endpoint (
GET /api/tags/posts) with configurable AND/OR logic modes - Implemented
commentsEnabledfield on posts with validation checks preventing comments on disabled posts - Added guest user restrictions via environment variables (
GUEST_POST_LIMIT,GUEST_COMMENT_LIMIT)
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/tag.service.js | Added getPostsByMultipleTags function and guest post limits to existing tag queries |
| services/post.service.js | Added commentsEnabled parameter to post creation and guest post limits to queries |
| services/interaction.service.js | Added comment enabled validation and guest comment limits |
| routes/tag.routes.js | Added new multi-tag filtering route |
| routes/interaction.routes.js | Changed comment fetching route to use optional authentication |
| prisma/schema.prisma | Added commentsEnabled boolean field to Post model |
| controllers/tag.controller.js | Implemented multi-tag filtering controller with validation |
| controllers/post.controller.js | Added commentsEnabled support to create and update operations |
| controllers/interaction.controller.js | Added disabled comments error handling and optional auth support |
| README.md | Documented new endpoints, fields, and environment variables |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| title: post.title, | ||
| content: post.content, | ||
| published: post.published, | ||
| commentsEnabled: post.commentsEnabled ?? true, |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback value ?? true is unnecessary since the database field has a default value of true. This fallback should only be used if dealing with legacy data that might have null values. If all posts are guaranteed to have this field set, remove the nullish coalescing to simplify the code.
| commentsEnabled: post.commentsEnabled ?? true, | |
| commentsEnabled: post.commentsEnabled, |
| title: post.title, | ||
| content: post.content, | ||
| published: post.published, | ||
| commentsEnabled: post.commentsEnabled ?? true, |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback value ?? true is unnecessary since the database field has a default value of true. This fallback should only be used if dealing with legacy data that might have null values. If all posts are guaranteed to have this field set, remove the nullish coalescing to simplify the code.
| commentsEnabled: post.commentsEnabled ?? true, | |
| commentsEnabled: post.commentsEnabled, |
| title: post.title, | ||
| content: post.content, | ||
| published: post.published, | ||
| commentsEnabled: post.commentsEnabled ?? true, |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback value ?? true is unnecessary since the database field has a default value of true. This fallback should only be used if dealing with legacy data that might have null values. If all posts are guaranteed to have this field set, remove the nullish coalescing to simplify the code.
| commentsEnabled: post.commentsEnabled ?? true, | |
| commentsEnabled: post.commentsEnabled, |
Overview
This PR implements the complete "Advanced Tag-Based Post Filtering with Multi-Tag & Comment Controls" feature epic, adding three major enhancements to improve post discovery and interaction:
🎯 Features
1. Multi-Tag Filtering
A new endpoint allows filtering posts by multiple tags with flexible logic:
Use cases:
2. Comment Controls
Post authors can now control whether comments are allowed on their posts:
Use cases:
The API returns
403 Forbiddenwhen attempting to comment on posts with disabled comments.3. Guest User Restrictions
Optional environment variables to limit what unauthenticated users can see:
Use cases:
🔄 Database Migration
A new
commentsEnabledfield has been added to the Post table:Or using Prisma:
All existing posts will default to
commentsEnabled: true, maintaining current behavior.📊 Technical Details
API Changes
New Endpoints:
GET /api/tags/posts?tags=<ids>&mode=<any|all>- Multi-tag filteringModified Responses:
All post objects now include:
{ "commentsEnabled": true, ... }New Error Responses:
403 Forbidden- "Comments are disabled for this post"404 Not Found- "One or more tags not found"Files Changed
Code Statistics
✅ Quality Assurance
📚 Documentation
Comprehensive updates to README.md including:
🚀 Deployment
npx prisma migrate dev --name add_comments_enabled_to_postGUEST_POST_LIMITandGUEST_COMMENT_LIMITenvironment variables🔒 Security
Example Usage
Backward Compatibility ✅
All changes are fully backward compatible:
commentsEnabled: trueCloses #[issue-number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint.prisma.io/usr/local/bin/node /home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child {"product":"prisma","version":"6.14.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-09T15:04:36Z","project_hash":"86700263","cli_path":"/home/REDACTED/work/Backend/Backend/node_modules/.bin/prisma","cli_path_hash":"a595029d","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate --postinstall \"UNABLE_TO_FIND_POSTINSTALL_TRIGGER__ENVAR_MISSING\"","schema_providers":["mysql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-a595029d","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)/usr/local/bin/node /home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child {"product":"prisma","version":"6.14.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-09T15:06:09Z","project_hash":"86700263","cli_path":"/home/REDACTED/work/Backend/Backend/node_modules/.bin/prisma","cli_path_hash":"a595029d","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"migrate dev --name [redacted]","schema_providers":["mysql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-a595029d","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)/usr/local/bin/node /home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child {"product":"prisma","version":"6.14.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-09T15:06:19Z","project_hash":"86700263","cli_path":"/home/REDACTED/work/Backend/Backend/node_modules/.bin/prisma","cli_path_hash":"a595029d","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["mysql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-a595029d","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/Backend/Backend/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #13
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.