Skip to content

feat: support anonymous replies (storage + masking + tests)#40

Open
JoshuaNam wants to merge 6 commits intomainfrom
feat/anonymous-replies-fix-clean
Open

feat: support anonymous replies (storage + masking + tests)#40
JoshuaNam wants to merge 6 commits intomainfrom
feat/anonymous-replies-fix-clean

Conversation

@JoshuaNam
Copy link

Replaces #39 (moved branch to main repo for auto-deployment)

Changes (Issue #29 + #6)

  • Added backend support for marking replies/posts as anonymous
  • Persisted anonymous flag (0/1) on posts in the database
  • Masked poster identity for non-admin users (uid set to 0, username/display name set to "Anonymous", generic avatar)
  • Preserved real author visibility for admins via post.anonymous field
  • Extracted shared Posts.anonymizePost() helper to DRY up masking logic
  • Added anonymous masking to postsAPI.getReplies() for "Show Replies" flow
  • Ensured non-anonymous posts are unaffected
  • Added unit tests covering storage, API masking, admin visibility, topic-level masking, and regression cases

Testing

  1. Run the full backend test suite:
    npm run lint
    npm run test

  2. Verify:

  • Anonymous posts store anonymous=1
  • Regular users see masked identity (uid=0, username "Anonymous")
  • Admins see real author with anonymous=1
  • "Show Replies" on anonymous posts masks author for non-admins
  • Non-anonymous posts behave normally
  1. Confirm all existing tests pass with no regressions

Related Issues

Resolves #6
Resolves #29

@railway-app
Copy link

railway-app bot commented Feb 14, 2026

🚅 Deployed to the nodebb-spring-26-clean-cod-pr-40 environment in Clean Code Team (nodebb)

Service Status Web Updated (UTC)
nodebb-spring-26-clean-code ✅ Success (View Logs) Web Feb 14, 2026 at 6:18 pm

@coveralls
Copy link

Pull Request Test Coverage Report for Build 22022037038

Details

  • 19 of 19 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 78.901%

Totals Coverage Status
Change from base Build 21973002465: 0.02%
Covered Lines: 25409
Relevant Lines: 30378

💛 - Coveralls

Comment on lines +98 to +103
Posts.anonymizePost = function (post, isAdmin) {
if (post && post.anonymous === 1 && !isAdmin) {
post.uid = 0;
post.user = {
uid: 0,
username: 'Anonymous',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good function extraction here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Anonymous Replies Store anonymous flag in database

3 participants

Comments