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 feature that adds a flag icon to all replies that contain curse words #15

Merged
merged 13 commits into from
Feb 11, 2025

Conversation

RyanChernoff
Copy link
Contributor

@RyanChernoff RyanChernoff commented Feb 9, 2025

Context:
The current model is to treat thread owners as teachers and repliers as students. Therefore, it is important that teachers have tools to moderate their threads. A simple tool to accomplish this is a flagging feature on inappropriate content. This feature is able to analyze any new reply in a thread and test weather or not contains any banned words. Similarly, students shouldn't be able to update their messages to circumvent the flag so replies are rescanned on edit. Lastly, the teacher needs some way to recognize any flagged messages so an icon gets added to all flagged replies. Lastly, replies that are made as threads both avoid the flag feature (as they are in a new thread) but also undermine the priority model. Therefore, this feature has been removed. Together this creates a useful tool for teachers in moderating their students.

Description:
The content of every new post is run through a small script that checks if any single word in the post is a curse word. The contentFlag attribute is added and set to true on any post found to contain one of these words. Whenever the content is changed this script is run again and the attribute updated. A small orange flag icon is added to all replies that have their contentFlag attribute set to true. The reply as topic feature button was removed from the front end. Functions that extend functionality to the button were also removed.

Major Changes:

  • Added flag function to search through replies
  • Call flag function and add flagContent attribute on truthy return on reply creation
  • Call flag function and update flagContent attribute on post edit
  • Add flag icon to all replies with true flagContent attribute
  • Removed reply as topic feature

File Changes:

src/posts/flagContent.js:

  • Added banned words list consisting of curse words in hex
  • Added flagContent function to search through a string for any words in banned words list

src/topics/create.js:

  • Run flagContent on new replies in the Topics.reply function
  • Add flagContent attribute if flagContent function returns true

src/posts/create.js

  • Extract flagContent attribute from input if exists
  • Forward flagContent attribute to the new post in the Posts.create function

src/posts/edit.js:

  • Rerun flagContent on edited replies where content was changed in getEditPostData function

nodebb-theme-harmony/templates/partials/topic/reply-button.tpl:

  • Removed the reply as topic button from the front end

public/src/client/topic/postTools.js:

  • Removed onClick event from reply as thread button

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

  • Added flag icon to replies with true flagContent attribute

Testing:
Testing was completed through the coverage suit and lint tests as well as some manual testing locally by creating and editing replies both with and without banned words. Users can simulate this by creating a reply to a thread with a curse word such as the F word.

Screenshot of Feature:
image

Resolves #8 and all of its sub issues (#13 & #14)

@kmakarska kmakarska self-assigned this Feb 10, 2025
@kmakarska
Copy link
Contributor

Overall code LGTM!

A few things about the PR description:

  • Make sure to review this document the professor sent about best practice in PRs
  • I think it would really help to follow those bullet points line by line and add headings for them for the most descriptive PRs

Some specific feedback on your description:

  • "Good PRs usually include bulleted lists of changes done to specific functions/ files. List the major changes made in this pull request." -> yours did not include a bulleted list which made it difficult to read
  • "This is where including file paths along with changes made in each file could deem very useful" --> yours did not include file paths
  • Although you touched on your testing methods, I think you could be a little clearer on "describe how the feature can be tested/noticed by a user, (Screenshots would be helpful)"

@RyanChernoff RyanChernoff assigned jonassoh and unassigned kmakarska and jonassoh Feb 11, 2025
@jonassoh
Copy link
Contributor

jonassoh commented Feb 11, 2025

Looks good! Code is clear and easy to understand. The changes to the PR made it much easier to read and the commit messages are very clear and descriptive.

@RyanChernoff RyanChernoff merged commit efc2876 into main Feb 11, 2025
1 of 2 checks passed
@RyanChernoff RyanChernoff deleted the flagPostsFeature branch February 11, 2025 17:37
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13247395746

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

  • 10 of 10 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 82.677%

Totals Coverage Status
Change from base Build 12997714559: 0.006%
Covered Lines: 22333
Relevant Lines: 25592

💛 - Coveralls

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.

Add flag icon to all posts with banned words
4 participants