Conversation
Add a dropdown to the quick reply composer that lets TAs and Professors mark posts as visible to instructors only. Also filter role-restricted post teasers from the category listing page for students.
Pull Request Test Coverage Report for Build 22083820104Details
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements role-based post visibility, allowing TAs and Professors to create posts that are only visible to instructors. Students cannot see these posts in any view. The implementation adds a targetRole field to posts and enforces visibility checks across all post-loading paths.
Changes Included
Added
isUserInRole()helper insrc/user/roles.jsto check group membership for visibility checksAdded authorization guard in
src/api/topics.jsthat strips targetRole from the payload if the caller is not an admin, TA, orProfessor
Enforced visibility in
src/privileges/posts.jsin bothfilter()andget()so restricted posts are hidden from students in search, recent posts, and direct API accessAdded role-based filter in
src/topics/posts.jsfor the topic page view andsrc/topics/teaser.jsfor category listing teasersAdded "Everyone / Instructors only" dropdown to the quick reply composer in
public/src/modules/quickreply.js, only visible to TAs and Professors viaisInstructorflag added insrc/controllers/topics.jsUpdated OpenAPI schemas and
src/posts/summary.jsto includetargetRoleso API validation tests passAdded 12 automated tests in
test/role-visibility.jsand user documentation inUserGuide.mdI used the targetRole field directly on posts rather than a separate permissions table. Since NodeBB uses a schemaless Redis store, no migration was needed. The visibility check follows the same pattern as user.blocks.filter() in the existing codebase.
Resolved #22