Skip to content
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

Added anonymous checkbox option for users when quick replying and adjusted the published post to be set to a default, masked display if anonymous #18

Merged
merged 26 commits into from
Feb 27, 2025

Conversation

kmakarska
Copy link
Contributor

@kmakarska kmakarska commented Feb 11, 2025

Context
Currently, when users reply to a post under a topic, there is no built-in mechanism for marking them as anonymous. This feature aims to allow users to quick reply under a post anonymously by clicking a checkbox. Under these conditions, the user's avatar, username, and all links to their profile will be masked to keep their identity fully private. This change is particularly useful for students who might feel embarrassed when asking questions, and it creates a safer learning environment overall.

Description
A checkbox labeled as "anonymous" was added next to the expand and submit buttons within the quick reply section of the page; This allows the user to toggle whether they want their quick reply post to be anonymous or not. The post is then edited so that the anonymous attribute is set to 'true' if the checkbox was marked upon submission of the post and set to 'false' if unmarked. If the anonymous attribute is set to 'true' in that post's data, the published post will have the username set to a default "Anonymous" and the avatar will be a default light gray circle; additionally, all links the the poster's profile (via their avatar or username) will be removed. If the anonymous attribute is set to 'false' in that post's data, the published post will display normally with all user information intact.

File Changes
src/posts/create.js


  • Set the postData anonymous attribute to true or false depending on the user input given by the replyData (that looked at the checkbox on the frontend).
  • Inserted console log message to confirm attribute assignment just for testing purposes.

public/src/modules/quickreply.js

  • Added backend validation to check if the anonymous box was marked on the frontend.
  • Added this extra attribute to the replyData on the backend.

nodebb-theme-harmony/templates/partials/topic/post.tpl

  • Added a blank default avatar to posts submitted with the anonymous attribute set to true.
  • Added a default "Anonymous" username to posts submitted with the anonymous attribute set to true.
  • Removed any user profile urls from the avatar or username on posts submitted with the anonymous attribute set to true.

Testing

  • For the initial backend test, we used console.log statements to verify that the anonymous attribute is correctly assigned when a post is created and the checkbox is marked on the frontend. Then, we ran the application in development mode (./nodebb dev) and monitored logs (./nodebb log).
  • To test frontend and backend changes as a whole, we added automated testing to test/topics.js. These tests were exhaustive and tested both cases: the post being anonymous and the post being non-anonymous. One test checks that a quick reply post made with the anonymous checkbox marked on the frontend indeed sets the post's anonymous attribute to 'true' on the backend and runs with no errors. The other test checks that a quick reply post made with the anonymous checkbox not marked on the frontend indeed sets the post's anonymous attribute to 'false' on the backend and runs with no errors.
  • We also performed extensive user testing on the UI directly to check if the anonymous posts were correctly masking and displaying as intended.

Resolves Issue #7 #19 #6

@RyanChernoff
Copy link
Contributor

RyanChernoff commented Feb 11, 2025

Most of your code looks fine but I don't think dump.rdb should be a part of any commits and should be removed. Also, your modification to src/posts/create.js line 37 will cause a lint error and should be reverted. Lastly, the log statements are unnecessary since your modifications appear to work. They should also be removed.

As for the PR, you neglect to mention your changes to src/topics/create.js. Also, since all posts are being modified with the anonymous attribute, the feature is not complete and the PR should be labeled with WIP. You should also add the issue you are resolving to the end of the PR.

@RyanChernoff RyanChernoff self-assigned this Feb 11, 2025
@kmakarska kmakarska changed the title Added anonymous attribute to new posts in src/posts/create.js
 WIP: Added anonymous attribute to new posts (src/posts/create.js
) and topics (src/topics/create.js) Feb 11, 2025
@RyanChernoff RyanChernoff removed their assignment Feb 26, 2025
@RyanChernoff RyanChernoff self-requested a review February 26, 2025 19:10
@rmurugan58 rmurugan58 changed the title WIP: Added anonymous attribute to new posts (src/posts/create.js
) and topics (src/topics/create.js) WIP: Added anonymous checkbox option for users when quick replying and adjusted the published post to be set to a default, masked display if anonymous Feb 26, 2025
@rmurugan58 rmurugan58 changed the title WIP: Added anonymous checkbox option for users when quick replying and adjusted the published post to be set to a default, masked display if anonymous Added anonymous checkbox option for users when quick replying and adjusted the published post to be set to a default, masked display if anonymous Feb 26, 2025
@rmurugan58 rmurugan58 requested a review from jonassoh February 26, 2025 19:13
…used anonymous attribute was added in the worng place
@coveralls
Copy link

coveralls commented Feb 27, 2025

Pull Request Test Coverage Report for Build 13572575047

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 9 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 82.692%

Files with Coverage Reduction New Missed Lines %
src/posts/edit.js 4 94.74%
src/privileges/posts.js 5 88.04%
Totals Coverage Status
Change from base Build 13271607482: 0.02%
Covered Lines: 22347
Relevant Lines: 25606

💛 - Coveralls

Copy link
Contributor

@RyanChernoff RyanChernoff left a comment

Choose a reason for hiding this comment

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

The PR looks good and is very descriptive and the code looks perfectly fine to me. Unfortunately, dump.rdb is a relic of the local database and needs to be removed before you can commit to main. This should also be resolving issue #6 as well, right? Other than that you should be fine.

@jonassoh
Copy link
Contributor

The PR looks good and follows guidelines. The changes Ryan mentioned have been made and the code is well organized and tested.

@RyanChernoff RyanChernoff self-requested a review February 27, 2025 19:03
Copy link
Contributor

@RyanChernoff RyanChernoff left a comment

Choose a reason for hiding this comment

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

Looks good now

Copy link
Contributor

@jonassoh jonassoh left a comment

Choose a reason for hiding this comment

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

code is clear and well organized and passes the lint test. looks good

@RyanChernoff RyanChernoff merged commit 4d72094 into main Feb 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants